Skip to content

Commit 6859621

Browse files
committed
#167 better intent and zero handling in encoder classes
1 parent 5a5e8d4 commit 6859621

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/SwitchInput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void RotaryEncoder::changePrecision(uint16_t maxValue, int currentValue, bool ro
288288
this->currentReading = currentValue;
289289
this->stepSize = step;
290290
bitWrite(flags, WRAP_AROUND_MODE, rolloverOnMax);
291-
if(maxValue == 0U && currentValue == 0) intent = DIRECTION_ONLY;
291+
intent = (maxValue == 0U && currentValue == 0) ? DIRECTION_ONLY : CHANGE_VALUE;
292292
runCallback((int)currentReading);
293293
}
294294

@@ -314,7 +314,7 @@ void RotaryEncoder::setUserIntention(EncoderUserIntention intention) {
314314
#define safeAbs(x) ((x) < 0 ? -(x) : (x))
315315

316316
void RotaryEncoder::increment(int8_t incVal) {
317-
if(maximumValue == 0) {
317+
if(maximumValue == 0 && intent == DIRECTION_ONLY) {
318318
// first check if we are in direction only mode (max = 0)
319319
runCallback(incVal);
320320
return;

0 commit comments

Comments
 (0)