22[ ![ Arduino CI] ( https://github.com/RobTillaart/rotaryDecoder/workflows/Arduino%20CI/badge.svg )] ( https://github.com/marketplace/actions/arduino_ci )
33[ ![ Arduino-lint] ( https://github.com/RobTillaart/rotaryDecoder/actions/workflows/arduino-lint.yml/badge.svg )] ( https://github.com/RobTillaart/rotaryDecoder/actions/workflows/arduino-lint.yml )
44[ ![ JSON check] ( https://github.com/RobTillaart/rotaryDecoder/actions/workflows/jsoncheck.yml/badge.svg )] ( https://github.com/RobTillaart/rotaryDecoder/actions/workflows/jsoncheck.yml )
5+ [ ![ GitHub issues] ( https://img.shields.io/github/issues/RobTillaart/rotaryDecoder.svg )] ( https://github.com/RobTillaart/rotaryDecoder/issues )
6+
57[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/RobTillaart/rotaryDecoder/blob/master/LICENSE )
68[ ![ GitHub release] ( https://img.shields.io/github/release/RobTillaart/rotaryDecoder.svg?maxAge=3600 )] ( https://github.com/RobTillaart/rotaryDecoder/releases )
9+ [ ![ PlatformIO Registry] ( https://badges.registry.platformio.org/packages/robtillaart/library/rotaryDecoder.svg )] ( https://registry.platformio.org/libraries/robtillaart/rotaryDecoder )
710
811
912# rotaryDecoder
@@ -24,6 +27,12 @@ pins to GND so you will not get unintended interrupts.
2427
2528## Interface
2629
30+ ``` cpp
31+ #include " rotaryEncoder.h"
32+ ```
33+
34+ #### Constructor
35+
2736- ** rotaryDecoder(const int8_t address, TwoWire \* wire = Wire);**
2837- ** bool begin(uint8_t sda, uint8_t scl, uint8_t count = 4)** ESP32 ea initializes the class
2938by setting the I2C sda and scl pins.
@@ -35,23 +44,27 @@ Returns true if the PCF8574 is on the I2C bus.
3544- ** bool isConnected()** returns true if the PCF8574 is on the I2C bus.
3645
3746
38- ## Core functions
47+ #### Core functions
3948
4049- ** void readInitialState()** read the initial state of the 4 rotary encoders.
4150Typically called in setup only, or after a sleep e.g. in combination with ** setValue()**
42- - ** bool checkChange()** polling to see if one or more RE have changed, without updating the counters.
43- - ** void update()** update the internal counters of the RE. These will add +1 or -1 depending on 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.
51+ - ** bool checkChange()** polling to see if one or more RE have changed,
52+ without updating the counters.
53+ - ** void update()** update the internal counters of the RE.
54+ These will add +1 or -1 depending on direction.
55+ - ** void updateSingle()** update the internal counters of the RE.
56+ This will add +1 +2 or +3 as it assumes that the rotary encoder
57+ only goes into a single direction.
4658
4759
48- ## Counters
60+ #### Counters
4961
5062- ** uint32_t getValue(uint8_r re)** returns the RE counter.
51- - ** void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value, default 0
63+ - ** void setValue(uint8_r re, uint32_t value = 0)** (re)set the internal counter to value,
64+ default 0
5265
5366
54- ## Debugging
67+ #### Debugging
5568
5669- ** int8_t getLastPosition(uint8_r re)** returns last position.
5770
@@ -63,20 +76,21 @@ clock speed of the I2C bus. All four core functions have one call to **\_read8()
6376is the most expensive part.
6477
6578Early tests gave the following indicative times (Arduino UNO) for the ** update()**
66- function (with no updates it is ~ 8 us faster). Note that above 500KHz the gain becomes less
67- while reliability of signal decreases. (500KHz is about ~ 3x faster than 100 KHz)
79+ function (with no updates it is ~ 8 us faster).
80+ Note that above 500 KHz the gain becomes less while reliability of signal decreases.
81+ (500 KHz is about ~ 3x faster than 100 KHz in practice.)
6882As 400 KHz is a standard I2C clock speed it is the preferred one.
6983
7084
71- | I2C speed | time (us) | delta | %% |
72- | :---------:| :---------:| :-----:| :-----:|
73- | 100 KHz | 247 | | |
74- | 200 KHz | 146 | 99 | 40% |
75- | 300 KHz | 110 | 36 | 24% |
76- | 400 KHz | 95 | 15 | 14% | preferred max
77- | 500 KHz | 84 | 11 | 12% |
78- | 600 KHz | 79 | 5 | 6% |
79- | 700 KHz | 73 | 6 | 8% |
85+ | I2C speed | time (us) | delta | %% | Notes |
86+ | :----------- :| :----------- :| :------- :| :-----:| :-------- |
87+ | 100 KHz | 247 | | |
88+ | 200 KHz | 146 | 99 | 40% |
89+ | 300 KHz | 110 | 36 | 24% |
90+ | 400 KHz | 95 | 15 | 14% | preferred max
91+ | 500 KHz | 84 | 11 | 12% |
92+ | 600 KHz | 79 | 5 | 6% |
93+ | 700 KHz | 73 | 6 | 8% |
8094
8195
8296At @400KHz it can update 4 rotary encoders in ~ 100us.
@@ -95,14 +109,33 @@ See examples..
95109
96110## Future
97111
98- #### must
112+ #### Must
113+
99114- update documentation
100- - picture how to connect e.g 2 RE's which pins to used
115+ - picture how to connect e.g two rotary encoders which pins to used
116+
117+
118+ #### Should
101119
102- #### should
103120- test with a high speed drill like a Dremel-tool.
104121
105- #### could
122+
123+ #### Could
124+
106125- invert flag to adjust to RE that give their pulse just the other way around?
107126 - setInvert(bool); getInvert();
108- - per channel / all?
127+ - per channel / all?
128+
129+
130+ #### Wont
131+
132+
133+
134+ ## Support
135+
136+ If you appreciate my libraries, you can support the development and maintenance.
137+ Improve the quality of the libraries by providing issues and Pull Requests, or
138+ donate through PayPal or GitHub sponsors.
139+
140+ Thank you,
141+
0 commit comments