@@ -51,36 +51,59 @@ Returns true if the PCF8574 is on the I2C bus.
5151- ** void readInitialState()** read the initial state of the 4 rotary encoders.
5252Typically called in setup only, or after a sleep e.g. in combination with ** setValue()**
5353- ** bool checkChange()** polling to see if one or more RE have changed,
54- without updating the counters.
54+ without updating the internal counters.
5555- ** void update()** update the internal counters of the RE.
56- These will add +1 or -1 depending on direction.
56+ The counters will add +1 or -1 depending on rotation direction.
57+ Need 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).
5759- ** void updateSingle()** update the internal counters of the RE.
58- This will add +1 +2 or +3 as it assumes that the rotary encoder
60+ This will add +1 +2 or +3 as it assumes that the rotary encoder
5961only goes into a single direction.
6062
6163
6264#### Counters
6365
6466- ** uint32_t getValue(uint8_r re)** returns the RE counter.
65- - ** void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value,
66- default 0
67+ - ** void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value, default 0
68+
69+
70+ #### Read1 - Write1 - experimental
71+
72+ Warning the ** write1(pin, value)** might alter the state of the rotary encoder pins.
73+ So this functionality should be tested thoroughly for your application.
74+ Especially the ** write()** is ** experimental** , see issue #10 , feedback welcome.
75+
76+
77+ ** Read1()** and ** write1()** are functions to access the pins of the PCF8574 that
78+ are not used for rotary encoders.
79+ The user must guard that especially writing the pins do not interfere with the rotary encoder pins.
80+
81+ - ** uint8_t read1(uint8_t pin)** reads a single pin (0..7).
82+ Returns HIGH or LOW.
83+ - ** bool write1(uint8_t pin, uint8_t value)** writes a single pin (0..7).
84+ Value should be LOW (0) or HIGH (other values).
85+ - ** uint8_t read8()** read all pins in one I2C IO action. When one need to access multiple
86+ input pins this is faster but need some bit masking.
87+ - ** bool write8(uint8_t value)** writes to multiple pins at once, e.g. to control multiple
88+ LEDs in one IO action. As said before the user must guard not to interfere with the
89+ rotary encoder pins.
6790
6891
6992#### Debugging
7093
71- - ** int8_t getLastPosition(uint8_r re)** returns last position.
94+ - ** int8_t getLastPosition(uint8_r re)** Returns last position.
7295
7396
7497## Performance
7598
7699As the decoder is based upon a PCF8574, a I2C device, the performance is affected by the
77- clock speed of the I2C bus. All four core functions have one call to ** \_ read8() ** which
78- is the most expensive part.
100+ clock speed of the I2C bus.
101+ All four core functions have one call to ** \read8() ** which is the most expensive part.
79102
80103Early tests gave the following indicative times (Arduino UNO) for the ** update()**
81104function (with no updates it is ~ 8 us faster).
82- Note that above 500 KHz the gain becomes less while reliability of signal decreases.
83- (500 KHz is about ~ 3x faster than 100 KHz in practice.)
105+ Note that above 500 KHz the gain becomes less while reliability of signal decreases.
106+ (500 KHz is about 3x faster than 100 KHz in practice.)
84107As 400 KHz is a standard I2C clock speed it is the preferred one.
85108
86109
@@ -95,20 +118,15 @@ As 400 KHz is a standard I2C clock speed it is the preferred one.
95118| 700 KHz | 73 | 6 | 8% |
96119
97120
98- At @ 400KHz it can update 4 rotary encoders in ~ 100us.
121+ At 400 KHz it can update 4 rotary encoders in ~ 100us.
99122At a 50% update percentage this implies a max of about
100- 5000 ** update()** calls per second in theory
123+ 5000 ** update()** calls per second in theory.
101124** to be tested in practice**
102125
103126Note that a high speed drill goes up to 30000 RPM = 500 RPS = 2000 interrupts per second,
104127assuming 4 pulses == 360°. (not tested)
105128
106129
107- ## Operational
108-
109- See examples..
110-
111-
112130## Future
113131
114132#### Must
0 commit comments