-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor interface + update readme.md (#13)
- changed **uint8_t readInitialState()** to return the read state. - changed **bool setValue(uint8_t re, int32_t value = 0)** to return false if parameter re is out of range, prevent possible bug. - changed **int32_t getValue(uint8_t re)** to return 0 if parameter re is out of range, prevent possible bug. - add example **rotaryDecoder_demo_RE_IO.ino** - update readme.md, interface section. - minor edits
- Loading branch information
1 parent
ca3f4e4
commit ea5c3e0
Showing
7 changed files
with
138 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
examples/rotaryDecoder_demo_RE_IO/rotaryDecoder_demo_RE_IO.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// FILE: rotaryDecoder_demo_RE_IO.ino | ||
// AUTHOR: Rob Tillaart | ||
// DATE: 2024-02-13 | ||
// PURPOSE: demo | ||
// URL: https://github.com/RobTillaart/rotaryDecoder | ||
// | ||
// example configuration | ||
// connect one rotary encoders | ||
// connect multiple switches | ||
// connect one line to the other end of the switches to enable them | ||
// connect a buzzer | ||
// | ||
// RotaryEncoder PCF8574 UNO | ||
// -------------------------------------- | ||
// pin A pin 0 | ||
// pin B pin 1 | ||
// switch pin 2 | ||
// switch pin 3 | ||
// switch pin 4 | ||
// enable line pin 5 | ||
// buzzer pin 6 | ||
// switch pin 7 | ||
// | ||
// SDA A4 | ||
// SCL A5 | ||
// | ||
|
||
|
||
#include "rotaryDecoder.h" | ||
|
||
rotaryDecoder decoder(0x39); // 0x39 = 57 | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println(__FILE__); | ||
Serial.print("ROTARY_DECODER_LIB_VERSION:\t"); | ||
Serial.println(ROTARY_DECODER_LIB_VERSION); | ||
|
||
Wire.begin(); | ||
Wire.setClock(100000); | ||
|
||
// only one rotary encoder | ||
decoder.begin(1); | ||
decoder.readInitialState(); | ||
|
||
// other lines are switches (INPUT) | ||
decoder.write1(2, LOW); | ||
decoder.write1(3, LOW); | ||
decoder.write1(4, LOW); | ||
decoder.write1(7, LOW); | ||
|
||
// enable/disable switches | ||
// HIGH == switches enabled | ||
decoder.write1(5, HIGH); | ||
|
||
// line 6 == buzzer | ||
decoder.write1(6, LOW); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
// if one of the lines is updated, print them. | ||
if (decoder.update()) | ||
{ | ||
Serial.print("\t"); | ||
Serial.print(decoder.getValue(0)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(2)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(3)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(4)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(5)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(6)); | ||
Serial.print("\t"); | ||
Serial.print(decoder.read1(7)); | ||
Serial.println(); | ||
} | ||
|
||
// other tasks... | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=rotaryDecoder | ||
version=0.3.0 | ||
version=0.3.1 | ||
author=Rob Tillaart <[email protected]> | ||
maintainer=Rob Tillaart <[email protected]> | ||
sentence=Arduino library for rotary decoder with a PCF8574. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters