Skip to content

Commit ee7330f

Browse files
authored
refactor begin() (#8)
- simplify begin() interface - breaking change - update readme.md
1 parent 5a63607 commit ee7330f

File tree

7 files changed

+22
-32
lines changed

7 files changed

+22
-32
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.2.0] - 2023-11-21
10+
- simplify begin() interface - breaking change
11+
- update readme.md
12+
13+
----
14+
915
## [0.1.4] - 2023-09-22
1016
- add Wire1 support for ESP32
1117
- moved code from .h to .cpp
1218
- update readme.md
1319
- minor edits
1420

15-
1621
## [0.1.3] - 2022-11-23
1722
- add changelog.md
1823
- add RP2040 to build-CI

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ library assumes these are used. Furthermore it is advised to connect the free PC
2525
pins to GND so you will not get unintended interrupts.
2626

2727

28+
#### Related
29+
30+
- https://github.com/RobTillaart/rotaryDecoderSwitch
31+
- https://github.com/RobTillaart/PCF8574
32+
33+
2834
## Interface
2935

3036
```cpp
@@ -34,10 +40,6 @@ pins to GND so you will not get unintended interrupts.
3440
#### Constructor
3541

3642
- **rotaryDecoder(const int8_t address, TwoWire \*wire = Wire);**
37-
- **bool begin(uint8_t sda, uint8_t scl, uint8_t count = 4)** ESP32 ea initializes the class
38-
by setting the I2C sda and scl pins.
39-
count is the number of rotary encoders connected. (Max 4 per PCF8574)
40-
Returns true if the PCF8574 is on the I2C bus.
4143
- **bool begin(uint8_t count = 4)** UNO ea. initializes the class.
4244
count is the number of rotary encoders connected. (Max 4 per PCF8574)
4345
Returns true if the PCF8574 is on the I2C bus.
@@ -114,23 +116,19 @@ See examples..
114116
- update documentation
115117
- picture how to connect e.g two rotary encoders which pins to used
116118

117-
118119
#### Should
119120

120121
- test with a high speed drill like a Dremel-tool.
121122

122-
123123
#### Could
124124

125125
- invert flag to adjust to RE that give their pulse just the other way around?
126126
- setInvert(bool); getInvert();
127127
- per channel / all?
128128

129-
130129
#### Wont
131130

132131

133-
134132
## Support
135133

136134
If you appreciate my libraries, you can support the development and maintenance.

library.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/rotaryDecoder.git"
1717
},
18-
"version": "0.1.4",
18+
"version": "0.2.0",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",
2222
"headers": "rotaryDecoder.h"
2323
}
24+

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=rotaryDecoder
2-
version=0.1.4
2+
version=0.2.0
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library to rotary decoder with a PCF8574

rotaryDecoder.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: rotaryDecoder.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.4
4+
// VERSION: 0.2.0
55
// DATE: 2021-05-08
66
// PURPOSE: rotary decoder library for Arduino
77
// URL: https://github.com/RobTillaart/rotaryDecoder
@@ -21,23 +21,11 @@ rotaryDecoder::rotaryDecoder(const int8_t address, TwoWire *wire)
2121
}
2222

2323

24-
#if defined (ESP8266) || defined(ESP32)
25-
bool rotaryDecoder::begin(uint8_t sda, uint8_t scl, uint8_t count)
26-
{
27-
_count = count;
28-
if (_count > 4) _count = 4;
29-
_wire->begin(sda, scl);
30-
if (! isConnected()) return false;
31-
return true;
32-
}
33-
#endif
34-
35-
3624
bool rotaryDecoder::begin(uint8_t count)
3725
{
3826
_count = count;
3927
if (_count > 4) _count = 4;
40-
_wire->begin();
28+
4129
if (! isConnected()) return false;
4230
return true;
4331
}

rotaryDecoder.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: rotaryDecoder.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.4
5+
// VERSION: 0.2.0
66
// DATE: 2021-05-08
77
// PURPOSE: rotary decoder library for Arduino
88
// URL: https://github.com/RobTillaart/rotaryDecoder
@@ -11,18 +11,14 @@
1111
#include "Arduino.h"
1212
#include "Wire.h"
1313

14-
#define ROTARY_DECODER_LIB_VERSION (F("0.1.4"))
14+
#define ROTARY_DECODER_LIB_VERSION (F("0.2.0"))
1515

1616

1717
class rotaryDecoder
1818
{
1919
public:
2020
explicit rotaryDecoder(const int8_t address, TwoWire *wire = &Wire);
2121

22-
#if defined (ESP8266) || defined(ESP32)
23-
bool begin(uint8_t sda, uint8_t scl, uint8_t count = 4);
24-
#endif
25-
2622
bool begin(uint8_t count = 4);
2723
bool isConnected();
2824

test/unit_test_001.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ unittest(test_constructor)
5656

5757
unittest_main()
5858

59-
// --------
59+
60+
// -- END OF FILE --
61+

0 commit comments

Comments
 (0)