From dc7d6b3724ca8e153a035eacddb95541986e39d5 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 6 May 2018 17:51:39 -0600 Subject: Added "votive candle mode", a.k.a. candle mode timer. Off by default, but click three times to add 30m to the timer. Maximum timer length about 4.5 hours. --- spaghetti-monster/anduril/anduril-ui.png | Bin 238915 -> 244079 bytes spaghetti-monster/anduril/anduril.c | 48 +++++++++- spaghetti-monster/anduril/anduril.svg | 157 ++++++++++++++++++++++++++++++- spaghetti-monster/anduril/anduril.txt | 126 ++++++++++++++----------- 4 files changed, 275 insertions(+), 56 deletions(-) diff --git a/spaghetti-monster/anduril/anduril-ui.png b/spaghetti-monster/anduril/anduril-ui.png index 191dbd1..b778a30 100644 Binary files a/spaghetti-monster/anduril/anduril-ui.png and b/spaghetti-monster/anduril/anduril-ui.png differ diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 36d29ac..26db6d8 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -653,9 +653,15 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) { static uint8_t candle_wave2_depth = 7; static uint8_t candle_wave3_depth = 4; static uint8_t candle_mode_brightness = 24; + static uint8_t candle_mode_timer = 0; + #define TICKS_PER_CANDLE_MINUTE 4096 // about 65 seconds + #define MINUTES_PER_CANDLE_HALFHOUR 27 // ish #endif if (event == EV_enter_state) { + #ifdef USE_CANDLE_MODE + candle_mode_timer = 0; // in case any time was left over from earlier + #endif return MISCHIEF_MANAGED; } // 1 click: off @@ -666,6 +672,9 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) { // 2 clicks: rotate through strobe/flasher modes else if (event == EV_2clicks) { strobe_type = (st + 1) % NUM_STROBES; + #ifdef USE_CANDLE_MODE + candle_mode_timer = 0; // in case any time was left over from earlier + #endif interrupt_nice_delays(); save_config(); return MISCHIEF_MANAGED; @@ -728,6 +737,22 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) { save_config(); return MISCHIEF_MANAGED; } + #if defined(USE_CANDLE_MODE) + // 3 clicks: add 30m to candle timer + else if (event == EV_3clicks) { + // candle mode only + if (st == 4) { + if (candle_mode_timer < (255 - MINUTES_PER_CANDLE_HALFHOUR)) { + // add 30m to the timer + candle_mode_timer += MINUTES_PER_CANDLE_HALFHOUR; + // blink to confirm + set_level(actual_level + 32); + delay_4ms(2); + } + } + return MISCHIEF_MANAGED; + } + #endif #if defined(USE_LIGHTNING_MODE) || defined(USE_CANDLE_MODE) // clock tick: bump the random seed else if (event == EV_tick) { @@ -736,12 +761,33 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) { #endif #ifdef USE_CANDLE_MODE if (st == 4) { + // self-timer dims the light during the final minute + uint8_t subtract = 0; + if (candle_mode_timer == 1) { + subtract = ((candle_mode_brightness+20) + * ((arg & (TICKS_PER_CANDLE_MINUTE-1)) >> 4)) + >> 8; + } + // we passed a minute mark, decrease timer if it's running + if ((arg & (TICKS_PER_CANDLE_MINUTE-1)) == (TICKS_PER_CANDLE_MINUTE - 1)) { + if (candle_mode_timer > 0) { + candle_mode_timer --; + //set_level(0); delay_4ms(2); + // if the timer ran out, shut off + if (! candle_mode_timer) { + set_state(off_state, 0); + } + } + } // 3-oscillator synth for a relatively organic pattern uint8_t add; add = ((triangle_wave(candle_wave1) * 8) >> 8) + ((triangle_wave(candle_wave2) * candle_wave2_depth) >> 8) + ((triangle_wave(candle_wave3) * candle_wave3_depth) >> 8); - set_level(candle_mode_brightness + add); + int8_t brightness = candle_mode_brightness + add - subtract; + if (brightness < 0) { brightness = 0; } + set_level(brightness); + // wave1: slow random LFO if ((arg & 1) == 0) candle_wave1 += pseudo_rand()&1; // wave2: medium-speed erratic LFO diff --git a/spaghetti-monster/anduril/anduril.svg b/spaghetti-monster/anduril/anduril.svg index ff9878a..9fbb7d1 100644 --- a/spaghetti-monster/anduril/anduril.svg +++ b/spaghetti-monster/anduril/anduril.svg @@ -22,6 +22,30 @@ inkscape:export-ydpi="114.26005"> + + + + + + + + + + + + + + + + +30 min + + + + + + + + + + + + + diff --git a/spaghetti-monster/anduril/anduril.txt b/spaghetti-monster/anduril/anduril.txt index 7efbf04..531609d 100644 --- a/spaghetti-monster/anduril/anduril.txt +++ b/spaghetti-monster/anduril/anduril.txt @@ -16,6 +16,7 @@ From off: Other: * 4 clicks: lock-out * 5 clicks: momentary mode (disconnect power to exit) + * 6 clicks: muggle mode In steady mode: * 1 click: off @@ -42,57 +43,69 @@ Discrete ramp config mode: (click N times to make discrete mode have N stair-steps) (minimum 2, maximum 150) -Bike flasher: - * 1 click: off - * 2 clicks: party strobe - * Hold: brighter - * Click, hold: dimmer - -Party / Tactical strobe modes: - * 1 click: off - * Hold: change speed (faster) - * Click, hold: change speed (slower) - * 2 clicks: next strobe mode - (bike flasher, party strobe, tactical strobe, lightning storm mode) - (TODO: random/police strobe?) - -Lightning storm mode: - * 1 click: off - * 2 clicks: bike flasher - -Battcheck mode: - * 1 click: off - * 2 clicks: goodnight mode - -Goodnight mode: - * 1 click: off - * 2 clicks: beacon mode - -Beacon mode: - * 1 click: off - * 2 clicks: tempcheck mode - * 3 clicks: configure time between pulses - -Beacon config mode: - * At buzz, click N times to set beacon frequency to N seconds. - -Tempcheck mode: - * 1 click: off - * 2 clicks: battcheck mode - * 3 clicks: thermal config mode - - Hold: thermal calibration mode - -Thermal config mode: - * Setting 1: calibrate sensor: - At buzz, click N times for N degrees C. For example, if the light - is current at "room temperature" of 22 C, click 22 times. Is - intended to only be done once upon initial setup, or not at all. - * Setting 2: temperature limit: - At buzz, click N times to set thermal limit to roughly 30 C + N. - -Thermal calibration mode: - - Hold until hot: set new ceiling value - - ... don't hold: blink out current ceiling value and exit +"Strobe" group modes: + + Candle mode: + * 1 click: off + * 2 clicks: next "strobe" group mode + * 3 clicks: add 30 minutes to the timer + (light will shut off when timer expires) + (default is no timer) + * Hold: brighter + * Click, hold: dimmer + + Bike flasher: + * 1 click: off + * 2 clicks: next "strobe" group mode + * Hold: brighter + * Click, hold: dimmer + + Party / Tactical strobe modes: + * 1 click: off + * Hold: change speed (faster) + * Click, hold: change speed (slower) + * 2 clicks: next "strobe" group mode + (TODO: random/police strobe?) + + Lightning storm mode: + * 1 click: off + * 2 clicks: next "strobe" group mode + +"Blinky" group modes: + + Battcheck mode: + * 1 click: off + * 2 clicks: goodnight mode + + Goodnight mode: + * 1 click: off + * 2 clicks: beacon mode + + Beacon mode: + * 1 click: off + * 2 clicks: tempcheck mode + * 3 clicks: configure time between pulses + + Beacon config mode: + * At buzz, click N times to set beacon frequency to N seconds. + + Tempcheck mode: + * 1 click: off + * 2 clicks: battcheck mode + * 3 clicks: thermal config mode + - Hold: thermal calibration mode + + Thermal config mode: + * Setting 1: calibrate sensor: + At buzz, click N times for N degrees C. For example, if the light + is current at "room temperature" of 22 C, click 22 times. Is + intended to only be done once upon initial setup, or not at all. + * Setting 2: temperature limit: + At buzz, click N times to set thermal limit to roughly 30 C + N. + + Thermal calibration mode: + - Hold until hot: set new ceiling value + - ... don't hold: blink out current ceiling value and exit Lockout mode: * Hold: momentary moon @@ -103,6 +116,11 @@ Momentary mode: * Release button: Light off. * To exit, disconnect power. (loosen/tighten the tailcap) +Muggle mode: + * 1 click: On / off. + * Hold: Ramp up / down. + * 6 clicks: Exit muggle mode. + TODO: * save settings in eeprom * decide on "hold until hot" or "click N times" for thermal config mode @@ -115,8 +133,8 @@ TODO: * add lightning mode? * muggle mode: smooth ramp * refactor to make config modes smaller - - candle mode timer, with three clicks to add 30 minutes - - candle mode: smoother adjustments? - - make sunset mode timer and brightness configurable? * move all config menus to four clicks + * candle mode timer, with three clicks to add 30 minutes - diagram updates for 3-click special actions + - candle mode: smoother adjustments? + - make sunset mode timer and brightness configurable? -- cgit v1.2.3