From 2ec533abd4592958bef3ec818870e3fb41b64b29 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 28 Sep 2017 17:03:58 -0600 Subject: Added reversing to Anduril. Made EV_tick always send 0 while in "hold" state. Reversing is a build-time option. --- spaghetti-monster/fsm-wdt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'spaghetti-monster/fsm-wdt.c') diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index afcf467..7cbe0d2 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -50,9 +50,6 @@ ISR(WDT_vect) { ticks_since_last_event = (ticks_since_last_event + 1) \ | (ticks_since_last_event & 0x8000); - // callback on each timer tick - emit(EV_tick, ticks_since_last_event); - // if time since last event exceeds timeout, // append timeout to current event sequence, then // send event to current state callback @@ -64,6 +61,14 @@ ISR(WDT_vect) { if (le_num >= 1) last_event = current_event[le_num-1]; if (le_num >= 2) prev_event = current_event[le_num-2]; + // callback on each timer tick + if (last_event == A_HOLD) { + emit(EV_tick, 0); // override tick counter while holding button + } + else { + emit(EV_tick, ticks_since_last_event); + } + // user held button long enough to count as a long click? if (last_event == A_PRESS) { if (ticks_since_last_event >= HOLD_TIMEOUT) { -- cgit v1.2.3