Skip to content

Commit f40edc6

Browse files
committed
Correct Changed-Variable
1 parent ded4112 commit f40edc6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

RotaryEncoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void EncoderClass::PushButtonHandler() { //
8383
if (millis()-lastPushed>150) { // if time > 250ms then allow set //
8484
_ButtonPresses++; // Increment the counter //
8585
_LEDChanged = true; // We are changing target values //
86+
changed = true; // Something has changed //
8687
lastPushed = millis(); // Store new push button time //
8788
_RedTarget = _ColorPushButtonR; // Set target color //
8889
_GreenTarget = _ColorPushButtonG; // Set target color //
@@ -107,12 +108,14 @@ void EncoderClass::PushButtonHandler() { //
107108
uint8_t sum = (lastEncoded << 2) | encoded; // add to previously encoded value //
108109
if(sum==0b1101||sum==0b0100||sum==0b0010||sum==0b1011) { // if clockwise turn direction //
109110
_EncoderValue++; // add value and brighten the //
111+
changed = true; // Something has changed //
110112
_LEDChanged = true; // We are changing target values //
111113
_RedTarget = _ColorCWR; // Set target color //
112114
_GreenTarget = _ColorCWG; // Set target color //
113115
_BlueTarget = _ColorCWB; // Set target color //
114116
} else if(sum==0b1110||sum==0b0111||sum==0b0001||sum==0b1000) { // if a counterclockwise turn //
115117
_EncoderValue--; // subtract the value and brighten //
118+
changed = true; // Something has changed //
116119
_LEDChanged = true; // We are changing target values //
117120
_RedTarget = _ColorCCWR; // Set target color //
118121
_GreenTarget = _ColorCCWG; // Set target color //

RotaryEncoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
const uint8_t PushbuttonPin, const uint8_t RedPin=255, // //
6666
const uint8_t GreenPin=255,const uint8_t BluePin=255, // //
6767
const bool HWDebounce=false); // //
68+
volatile bool changed = false; // Set to true on push or rotate //
6869
uint8_t GetButton(); // Returns number of button pushes //
6970
int16_t GetEncoderValue(); // Return the encoder value //
7071
static void TimerISR(); // Interim ISR calls real handler //

0 commit comments

Comments
 (0)