MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / rotaryDecoderSwitch

Class rotaryDecoderSwitch

libraries/rotaryDecoderSwitch/rotaryDecoderSwitch.h:17–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class rotaryDecoderSwitch
18{
19public:
20 explicit rotaryDecoderSwitch(const int8_t address, TwoWire *wire = &Wire);
21
22#if defined (ESP8266) || defined(ESP32)
23 bool begin(uint8_t sda, uint8_t scl, uint8_t count = 2);
24#endif
25
26 bool begin(uint8_t count = 2);
27 bool isConnected();
28
29 void readInitialState();
30
31 // for polling version,
32 // checkChange is bit faster than a call to update
33 // so useful if there are only a few updates
34 bool checkChange();
35
36 // read and update the counters
37 bool update(); // assumes two directions => +1 and -1
38 bool updateSingle(); // assumes single direction => + ++ +++
39
40 int32_t getValue(uint8_t re) { return _encoder[re]; };
41 void setValue(uint8_t re, int32_t val = 0) { _encoder[re] = val; };
42 bool isKeyPressed(uint8_t re);
43
44 // DEBUG
45 uint8_t getLastPosition(uint8_t re) { return _lastPos[re]; };
46 uint8_t getRaw() { return _read8(); };
47
48
49private:
50 uint8_t _count = 0;
51 uint8_t _lastValue = 0;
52 uint8_t _lastPos[2] = { 0,0 };
53 int32_t _encoder[2] = { 0,0 };
54
55 uint8_t _read8();
56 uint8_t _address;
57 TwoWire * _wire;
58};
59
60
61// -- END OF FILE --

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68