@@ -39,7 +39,8 @@ pins to GND so you will not get unintended interrupts.
3939
4040#### Constructor
4141
42- - ** rotaryDecoder(const int8_t address, TwoWire \* wire = Wire);**
42+ - ** rotaryDecoder(const int8_t address, TwoWire \* wire = Wire)**
43+ constructor to set the address and optional the Wire bus.
4344- ** bool begin(uint8_t count = 4)** UNO ea. initializes the class.
4445count is the number of rotary encoders connected. (Max 4 per PCF8574)
4546Returns true if the PCF8574 is on the I2C bus.
@@ -48,23 +49,31 @@ Returns true if the PCF8574 is on the I2C bus.
4849
4950#### Core functions
5051
51- - ** void readInitialState()** read the initial state of the 4 rotary encoders.
52- Typically called in setup only, or after a sleep e.g. in combination with ** setValue()**
53- - ** bool checkChange()** polling to see if one or more RE have changed,
54- without updating the internal counters.
55- - ** void update()** update the internal counters of the RE.
52+ - ** uint8_t readInitialState()** read the initial state of the 4 rotary encoders.
53+ Typically called in setup only, or after a sleep e.g. in combination with ** setValue()** .
54+ Since 0.3.1 this function returns the read state, saves an additional read8() call.
55+ - ** bool checkChange()** used for polling to see if one or more RE have changed.
56+ This function does NOT update the internal counters.
57+ - ** bool update()** returns true if there is a change detected.
58+ It updates the internal counters of the RE.
5659The counters will add +1 or -1 depending on rotation direction.
5760Need to be called before ** getValue()** or before ** getKeyPressed()** .
58- Note that ** update()** must be called as soon as possible after the interrupt occurs (or as often as possible when polling).
59- - ** void updateSingle()** update the internal counters of the RE.
60- This will add +1 +2 or +3 as it assumes that the rotary encoder
61- only goes into a single direction.
61+ Note that ** update()** must be called as soon as possible after the interrupt occurs
62+ or as often as possible when polling.
63+ Returns false if there is no change since last read.
64+ - ** bool updateSingle()** returns true if there is a change detected.
65+ It updates the internal counters of the RE.
66+ This will add +1, +2 or +3 as it assumes that the rotary encoder
67+ only goes into a single direction.
68+ Returns false if there is no change since last read.
6269
6370
6471#### Counters
6572
66- - ** uint32_t getValue(uint8_r re)** returns the RE counter.
67- - ** void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value, default 0
73+ - ** int32_t getValue(uint8_r re)** returns the RE counter.
74+ If the parameter re > 3 then 0 is returned.
75+ - ** bool setValue(uint8_r re, int32_t value = 0)** (re)set the internal counter to value, default 0.
76+ If the parameter re > 3 then false is returned, true otherwise.
6877
6978
7079#### Read1 - Write1 - experimental
@@ -73,6 +82,7 @@ Warning the **write1(pin, value)** might alter the state of the rotary encoder p
7382So this functionality should be tested thoroughly for your application.
7483Especially the ** write()** is ** experimental** , see issue #10 , feedback welcome.
7584
85+ See example ** rotaryDecoder_demo_RE_IO.ino** (since 0.3.1).
7686
7787** Read1()** and ** write1()** are functions to access the pins of the PCF8574 that
7888are not used for rotary encoders.
@@ -98,7 +108,7 @@ rotary encoder pins.
98108
99109As the decoder is based upon a PCF8574, a I2C device, the performance is affected by the
100110clock speed of the I2C bus.
101- All four core functions have one call to ** \ read8()** which is the most expensive part.
111+ All four core functions have one call to ** read8()** which is the most expensive part.
102112
103113Early tests gave the following indicative times (Arduino UNO) for the ** update()**
104114function (with no updates it is ~ 8 us faster).
0 commit comments