From 36fc1e22964795922370008adda1b9a1732905a8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 24 Sep 2017 21:08:51 -0600 Subject: Added idle to goodnight mode, for 2mA less power at all levels. Reduced ROM size slightly by avoiding repeated access to the volatile current_state var. --- spaghetti-monster/anduril/anduril.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index b7c4421..8784bc5 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -945,13 +945,18 @@ void setup() { void loop() { + StatePtr state = current_state; + + if (0) {} + #ifdef USE_IDLE_MODE - if (current_state == steady_state) { + else if ((state == steady_state) + || (state == goodnight_state)) { idle_mode(); - } else + } #endif - if (current_state == strobe_state) { + else if (state == strobe_state) { // party / tactical strobe if (strobe_type < 2) { set_level(MAX_LEVEL); @@ -1025,17 +1030,17 @@ void loop() { } #ifdef USE_BATTCHECK - else if (current_state == battcheck_state) { + else if (state == battcheck_state) { battcheck(); } - else if (current_state == tempcheck_state) { + else if (state == tempcheck_state) { blink_num(temperature>>2); nice_delay_ms(1000); } // TODO: blink out therm_ceil during thermal_config_state #endif - else if (current_state == beacon_state) { + else if (state == beacon_state) { set_level(memorized_level); if (! nice_delay_ms(500)) return; set_level(0); -- cgit v1.2.3