diff options
Diffstat (limited to 'spaghetti-monster/fsm-pcint.c')
| -rw-r--r-- | spaghetti-monster/fsm-pcint.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c index d362633..24cc82c 100644 --- a/spaghetti-monster/fsm-pcint.c +++ b/spaghetti-monster/fsm-pcint.c @@ -93,18 +93,19 @@ ISR(PCINT0_vect) { // should only be called from PCINT and/or WDT // (is a separate function to reduce code duplication) void PCINT_inner(uint8_t pressed) { - uint8_t pushed; + button_last_state = pressed; - if (pressed) { - pushed = push_event(B_PRESS); - } else { - pushed = push_event(B_RELEASE); - } - - // send event to the current state callback - if (pushed) { - button_last_state = pressed; + // register the change, and send event to the current state callback + if (pressed) { // user pressed button + push_event(B_PRESS); emit_current_event(0); + } else { // user released button + // how long was the button held? + push_event(B_RELEASE); + emit_current_event(ticks_since_last_event); } + ticks_since_last_event = 0; } + + #endif |
