diff options
| author | Selene ToyKeeper | 2017-09-28 17:03:58 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2017-09-28 17:03:58 -0600 |
| commit | 2ec533abd4592958bef3ec818870e3fb41b64b29 (patch) | |
| tree | 52a28c8e1620bfe0bfda7d5e301c39b1fa6e13bb /spaghetti-monster/fsm-wdt.c | |
| parent | Rearranged some build options and made sure the build still works if some are... (diff) | |
| download | anduril-2ec533abd4592958bef3ec818870e3fb41b64b29.tar.gz anduril-2ec533abd4592958bef3ec818870e3fb41b64b29.tar.bz2 anduril-2ec533abd4592958bef3ec818870e3fb41b64b29.zip | |
Added reversing to Anduril. Made EV_tick always send 0 while in "hold" state.
Reversing is a build-time option.
Diffstat (limited to 'spaghetti-monster/fsm-wdt.c')
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 11 |
1 files changed, 8 insertions, 3 deletions
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) { |
