aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-wdt.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--spaghetti-monster/fsm-wdt.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index ff96ffb..06b0b6d 100644
--- a/spaghetti-monster/fsm-wdt.c
+++ b/spaghetti-monster/fsm-wdt.c
@@ -45,6 +45,23 @@ inline void WDT_off()
// clock tick -- this runs every 16ms (62.5 fps)
ISR(WDT_vect) {
+ #ifdef USE_HALFSLEEP_MODE
+ f_wdt = 1; // WDT event happened
+
+ static uint16_t sleep_counter = 0;
+ // handle halfsleep mode specially
+ if (halfsleep_mode) {
+ // emit a halfsleep tick, and process it
+ emit(EV_halfsleep_tick, sleep_counter);
+ sleep_counter ++;
+ process_emissions();
+ //if (! halfsleep_mode)
+ // sleep_counter = 0;
+ return;
+ }
+ sleep_counter = 0;
+ #endif
+
// detect and emit button change events
uint8_t was_pressed = button_last_state;
uint8_t pressed = button_is_pressed();