You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**bool begin(uint8_t sda, uint8_t scl, uint8_t cnt = 4)** ESP32 ea initializes the class.
20
-
sets I2C pins.
21
-
cnt is the number of rotary encoders connected.
22
-
returns true if the PCF8574 is on the I2C bus.
23
-
-**bool begin(uint8_t cnt = 4)** UNO ea. initializes the class.
24
-
cnt is the number of rotary encoders connected.
25
-
returns true if the PCF8574 is on the I2C bus.
28
+
-**bool begin(uint8_t sda, uint8_t scl, uint8_t count = 4)** ESP32 ea initializes the class
29
+
by setting the I2C sda and scl pins.
30
+
count is the number of rotary encoders connected. (Max 4 per PCF8574)
31
+
Returns true if the PCF8574 is on the I2C bus.
32
+
-**bool begin(uint8_t count = 4)** UNO ea. initializes the class.
33
+
count is the number of rotary encoders connected. (Max 4 per PCF8574)
34
+
Returns true if the PCF8574 is on the I2C bus.
26
35
-**bool isConnected()** returns true if the PCF8574 is on the I2C bus.
27
36
37
+
28
38
## Core functions
29
39
30
-
-**void readInitialState()** read the inital state of the 4 rotary encoders. typically called in setup only, or after a sleep e.g. in combination with **setValue()**
40
+
-**void readInitialState()** read the initial state of the 4 rotary encoders.
41
+
Typically called in setup only, or after a sleep e.g. in combination with **setValue()**
31
42
-**bool checkChange()** polling to see if one or more RE have changed, without updating the counters.
32
43
-**void update()** update the internal counters of the RE. These will add +1 or -1 depending on direction.
33
-
-**void updateSingle()** update the internal counters of the RE. This will add +1 +2 or +3 as it assumes that the rotary encoder only goes into a single direction.
44
+
-**void updateSingle()** update the internal counters of the RE. This will add +1 +2 or +3
45
+
as it assumes that the rotary encoder only goes into a single direction.
46
+
34
47
35
48
## Counters
36
49
37
50
-**uint32_t getValue(uint8_r re)** returns the RE counter.
38
-
-**void setValue(uint8_r re, uint32_t val = 0)** (re)set the internal counter to val, default 0
51
+
-**void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value, default 0
39
52
40
53
41
54
## Debugging
42
55
43
-
-**int8_t getLastPosition(uint8_r re)**
56
+
-**int8_t getLastPosition(uint8_r re)** returns last position.
44
57
45
58
46
59
## Performance
47
60
48
61
As the decoder is based upon a PCF8574, a I2C device, the performance is affected by the
49
-
clockspeed of the I2C bus. All four core functions have one call to **\_read()** which is the most expensive part.
62
+
clock speed of the I2C bus. All four core functions have one call to **\_read8()** which
63
+
is the most expensive part.
50
64
51
65
Early tests gave the following indicative times (Arduino UNO) for the **update()**
52
66
function (with no updates it is ~8 us faster). Note that above 500KHz the gain becomes less
53
-
while reliability of signal decreases. (500KHz is ~3x faster than 100 KHz)
67
+
while reliability of signal decreases. (500KHz is about ~3x faster than 100 KHz)
68
+
As 400 KHz is a standard I2C clock speed it is the preferred one.
69
+
54
70
55
-
| I2C speed | time (us) | delta | %% |
71
+
| I2C speed | time (us) | delta | %% |
56
72
|:---------:|:---------:|:-----:|:-----:|
57
73
| 100 KHz | 247 |||
58
74
| 200 KHz | 146 | 99 | 40% |
@@ -62,6 +78,7 @@ while reliability of signal decreases. (500KHz is ~3x faster than 100 KHz)
62
78
| 600 KHz | 79 | 5 | 6% |
63
79
| 700 KHz | 73 | 6 | 8% |
64
80
81
+
65
82
At @400KHz it can update 4 rotary encoders in ~100us.
66
83
At a 50% update percentage this implies a max of about
67
84
5000 **update()** calls per second in theory
@@ -75,3 +92,10 @@ assuming 4 pulses == 360
75
92
76
93
See examples..
77
94
95
+
96
+
## Future
97
+
98
+
- test with a high speed drill like a Dremel-tool.
99
+
- update documentation
100
+
- picture how to connect e.g 2 RE's which pins to used
0 commit comments