Migration from V2 to V3: tick() returns unreliable status
ShaggyDog18 opened this issue · 5 comments
Unsuccessfully tried to migrate from V2 to v3 with troubles. Platform: STM32F401
I use the following to handle events/actions:
if( inputEnc.tick() ){
// event handler
bool fastRotate = inputEnc.fast();
if( inputEnc.right() ) {
// do something for encoder turning right
}
....
if( inputEnc.left() ) {
// do something for encoder turning left
}
}
So, it seems that tick() is skipping events (returns true for some events, does not return true for some events even though an event is happening); as a result, the handler does not process events, behaves as event did not happen... It skips events unregularly, so, I did not notice any pattern. Should be mentioned, I also call tickISR()
in the interrupt for any pin state CHANGE.
Please, check up if tick() is always returning true
for any event.
Thank you.
Do you have only one tick
function in loop?
yes, I do: just one tick()
is in the loop() for encoder with button. I also have a separate button with a dedicated button.tick()
in the loop()...
should mention, V2 works like a charm :-)
no, v3 is more stable than v2, I'm sure that you do something wrong. Try examples from library. And give me a minimal example with this bug. Because tick always returns true
on events, there can't be event without true result
ok, please, test two options:
void loop() {
static uint32_t cycleCounter = 0;
static uint32_t holdingBthCycleCounter = 0;
bool buttonHolding = false;
cycleCounter++;
if( button.tick() ) buttonHolding = button.holding();
if( buttonHolding ) {
holdingBthCycleCounter++;
Serial.print( "cycle# " ); Serial.println( cycleCounter );
Serial.print( "holding button cycle# "); Serial.println( holdingBthCycleCounter );
Serial.flush();
}
}
and:
void loop() {
static uint32_t cycleCounter = 0;
static uint32_t holdingBthCycleCounter = 0;
bool buttonHolding = false;
cycleCounter++;
button.tick();
buttonHolding = button.holding();
if( buttonHolding ) {
holdingBthCycleCounter++;
Serial.print( "cycle# " ); Serial.println( cycleCounter );
Serial.print( "holding button cycle# "); Serial.println( holdingBthCycleCounter );
Serial.flush();
}
}
the difference is only in handling holding()
event... and when the button is pressed & held, there should be a print out for holding counter for each loop() cycle… which is not happening for the 1st option…
Of course, holding()
is a status, not an event. tick will return true on hold
event, once