aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-wdt.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-11-11 16:01:12 -0700
committerSelene ToyKeeper2018-11-11 16:01:12 -0700
commit69d0d92c7902aa27510ab52a533bf91c37363910 (patch)
treee2387e102758e573eb0ff311f8cc168b2640a96c /spaghetti-monster/fsm-wdt.c
parentFixed the corner case of a button release when the previous state was already... (diff)
downloadanduril-69d0d92c7902aa27510ab52a533bf91c37363910.tar.gz
anduril-69d0d92c7902aa27510ab52a533bf91c37363910.tar.bz2
anduril-69d0d92c7902aa27510ab52a533bf91c37363910.zip
Fixed the sleep tick counter wrapping around to 0 instead of 32768.
Diffstat (limited to 'spaghetti-monster/fsm-wdt.c')
-rw-r--r--spaghetti-monster/fsm-wdt.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index 3606c67..d5bbdb9 100644
--- a/spaghetti-monster/fsm-wdt.c
+++ b/spaghetti-monster/fsm-wdt.c
@@ -64,7 +64,9 @@ ISR(WDT_vect) {
// handle standby mode specially
if (go_to_standby) {
// emit a halfsleep tick, and process it
- emit(EV_sleep_tick, sleep_counter++);
+ emit(EV_sleep_tick, sleep_counter);
+ // wrap around from 65535 to 32768, not 0
+ sleep_counter = (sleep_counter + 1) | (sleep_counter & 0x8000);
process_emissions();
return;
}