aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-wdt.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-06-17 18:18:38 -0600
committerSelene ToyKeeper2018-06-17 18:18:38 -0600
commitcfedb2eaf4a0d62969ff05307ac40d4f1cdab2d9 (patch)
tree0d4ecd59e65b3152c44e50c9a93e679a260fac5c /spaghetti-monster/fsm-wdt.c
parentAdded dual-switch support (tail clicky + e-switch) to muggle mode. (diff)
downloadanduril-cfedb2eaf4a0d62969ff05307ac40d4f1cdab2d9.tar.gz
anduril-cfedb2eaf4a0d62969ff05307ac40d4f1cdab2d9.tar.bz2
anduril-cfedb2eaf4a0d62969ff05307ac40d4f1cdab2d9.zip
Implemented halfsleep mode.
Will probably change it quite a bit though, so I'm checking in changes first. Needs to be "tick during standby" instead of "half sleep".
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();