diff options
| author | Selene ToyKeeper | 2018-08-06 21:27:45 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-08-06 21:27:45 -0600 |
| commit | ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4 (patch) | |
| tree | ab5b14203adad80505368f31f8dfa6a87a1cb356 /spaghetti-monster/fsm-wdt.c | |
| parent | Made it easier to change ramp shape in bin/level_calc.py . (diff) | |
| parent | Added more driver types to Anduril. (diff) | |
| download | anduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.tar.gz anduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.tar.bz2 anduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.zip | |
merged updates from fsm branch, including RampingIOS V3 and Werner UIs...
... plus a bunch of other updates, fixes, improvements, etc.
Diffstat (limited to 'spaghetti-monster/fsm-wdt.c')
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index ff96ffb..e8419bc 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -33,6 +33,18 @@ void WDT_on() //sei(); // Enable interrupts } +#ifdef TICK_DURING_STANDBY +inline void WDT_slow() +{ + // interrupt slower + //cli(); // Disable interrupts + wdt_reset(); // Reset the WDT + WDTCR |= (1<<WDCE) | (1<<WDE); // Start timed sequence + WDTCR = (1<<WDIE) | STANDBY_TICK_SPEED; // Enable interrupt every so often + //sei(); // Enable interrupts +} +#endif + inline void WDT_off() { //cli(); // Disable interrupts @@ -45,6 +57,20 @@ inline void WDT_off() // clock tick -- this runs every 16ms (62.5 fps) ISR(WDT_vect) { + #ifdef TICK_DURING_STANDBY + f_wdt = 1; // WDT event happened + + static uint16_t sleep_counter = 0; + // handle standby mode specially + if (go_to_standby) { + // emit a halfsleep tick, and process it + emit(EV_sleep_tick, sleep_counter++); + process_emissions(); + return; + } + sleep_counter = 0; + #endif + // detect and emit button change events uint8_t was_pressed = button_last_state; uint8_t pressed = button_is_pressed(); |
