Skip to content

Commit 2d3ab4a

Browse files
Update the readme
1 parent 90e6b6c commit 2d3ab4a

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ To be sure that the encoder is polled frequently enough, it is probably best to
8888
}
8989
}
9090

91-
In this example the TimerOne library is used to generate an interrupt every 1000 microseconds (1kHz). Changes are accumulated in the service routine and processed as needed by the main program loop. This works well even on switches with a lot of bounce. The entire function is compact and could be faster with hard coded pin reads or by using digitalReadFast if you wanted to modify the library source code.
91+
In this example the TimerOne library is used to generate an interrupt every 1000 microseconds (1kHz). Changes are accumulated in the service routine and processed as needed by the main program loop. This works well even on switches with a lot of bounce. The entire function is compact and could be faster with hard coded pin reads or by using digitalReadFast if you wanted to modify the library source code.
9292

9393
## Reading changes
9494

@@ -127,14 +127,7 @@ https://www.mikrocontroller.net/articles/Drehgeber
127127
https://playground.arduino.cc/Main/PinChangeInterrupt/
128128
https://thewanderingengineer.com/2014/08/11/arduino-pin-change-interrupts/
129129

130+
## Multiple Encoders
130131

132+
The library should work with multiple encoder instances. There is an example `two-encoders` that demonstrates this using a timer interrupt for polling. Pin-change interrupt implementations may also be fine if the encoders are in different groups though that has not yet been tested.
131133

132-
## A note about the service method
133-
134-
If you are inclide to examine the code to see how this all works, you might be upset by the way the service method is writte.
135-
136-
You will see a static variable that retains the previous state of the input pins. Static variables, of course, retain their value from call to call because they are really stored in global memory space but are not visible to any code outside the function. These static variables can be initialised to any value. The initialisation is performed only the very first time the function is called. The compiler keeps an extra guard variable that allow it to detect that first use and perform the initialisation.
137-
138-
Normally, you might expect to see this static variable definition and its initialisation at the start of a function. While not so common, this can be done anywhere that is convenient. Here, it is important that the previous state is set to be the same as the current state the first time the function is called to make sure that the encoder change is zero first time around.
139-
140-
That is why the ```previous_state``` variable is not defined until _after_ the current pin state has been read.

0 commit comments

Comments
 (0)