diff options
| author | Selene ToyKeeper | 2019-05-22 16:01:07 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-05-22 16:01:07 -0600 |
| commit | 7078f9c66d36deb1f1c8eeeb631bdc2f5465de01 (patch) | |
| tree | 014436933faffa8c0472150845b45527d7a72761 /spaghetti-monster | |
| parent | Rewrote thermal regulation. Seems to be much more stable now... doesn't boun... (diff) | |
| download | anduril-7078f9c66d36deb1f1c8eeeb631bdc2f5465de01.tar.gz anduril-7078f9c66d36deb1f1c8eeeb631bdc2f5465de01.tar.bz2 anduril-7078f9c66d36deb1f1c8eeeb631bdc2f5465de01.zip | |
made momentary mode also do strobes
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/anduril-manual.txt | 20 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 36 |
2 files changed, 46 insertions, 10 deletions
diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 96640f6..3684b50 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -223,11 +223,23 @@ Momentary Mode Click 5 times from Off to enter Momentary mode. This locks the flashlight into a single-mode interface where the LEDs are only on when -the button is held down. It is intended for Morse code and other -signalling tasks. +the button is held down. It is intended for Morse code, light painting, +and other tasks where the light should be on only for a short time and +probably in a pattern. -Brightness is the last-ramped level, so adjust that before entering -momentary mode. +Momentary mode does either a steady brightness level or a strobe. To +select which one, go to the mode you want to use, adjust the brightness +and speed and other settings, then turn the light off. Then click 5 +times to enter momentary mode. + +Supported momentary modes are steady (normal ramping mode) and strobes +(everything in the "strobe" mode group). + +In steady mode, brightness is the last-ramped level, so adjust that +before entering momentary mode. + +In momentary strobe mode, the settings are copied from the last-used +strobe mode, such as party strobe, tactical strobe, or lightning. To exit this mode, physically disconnect power by unscrewing the tailcap or battery tube. diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index fadf51e..0fb9386 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -244,6 +244,8 @@ uint8_t beacon_config_state(Event event, uint16_t arg); uint8_t lockout_state(Event event, uint16_t arg); // momentary / signalling mode uint8_t momentary_state(Event event, uint16_t arg); +uint8_t momentary_mode = 0; // 0 = ramping, 1 = strobe +uint8_t momentary_active = 0; // boolean, true if active *right now* #ifdef USE_MUGGLE_MODE // muggle mode, super-simple, hard to exit uint8_t muggle_state(Event event, uint16_t arg); @@ -568,6 +570,7 @@ uint8_t steady_state(Event event, uint16_t arg) { // turn LED on when we first enter the mode if ((event == EV_enter_state) || (event == EV_reenter_state)) { + momentary_mode = 0; // 0 = ramping, 1 = strobes // if we just got back from config mode, go back to memorized level if (event == EV_reenter_state) { arg = memorized_level; @@ -935,6 +938,8 @@ uint8_t strobe_state(Event event, uint16_t arg) { // (maybe I should just make it nonvolatile?) strobe_mode_te st = strobe_type; + momentary_mode = 1; // 0 = ramping, 1 = strobes + #ifdef USE_CANDLE_MODE // pass all events to candle mode, when it's active // (the code is in its own pseudo-state to keep things cleaner) @@ -1542,14 +1547,24 @@ uint8_t lockout_state(Event event, uint16_t arg) { uint8_t momentary_state(Event event, uint16_t arg) { // TODO: momentary strobe here? (for light painting) + // init strobe mode, if relevant + if ((event == EV_enter_state) && (momentary_mode == 1)) { + strobe_state(event, arg); + } + // light up when the button is pressed; go dark otherwise // button is being held if ((event & (B_CLICK | B_PRESS)) == (B_CLICK | B_PRESS)) { - set_level(memorized_level); + momentary_active = 1; + // 0 = ramping, 1 = strobes + if (momentary_mode == 0) { + set_level(memorized_level); + } return MISCHIEF_MANAGED; } // button was released else if ((event & (B_CLICK | B_PRESS)) == (B_CLICK)) { + momentary_active = 0; set_level(0); //go_to_standby = 1; // sleep while light is off return MISCHIEF_MANAGED; @@ -1560,10 +1575,18 @@ uint8_t momentary_state(Event event, uint16_t arg) { // with exiting via tailcap loosen+tighten unless you leave power // disconnected for several seconds, so we want to be awake when that // happens to speed up the process) - else if ((event == EV_tick) && (actual_level == 0)) { - if (arg > TICKS_PER_SECOND*15) { // sleep after 15 seconds - go_to_standby = 1; // sleep while light is off - // TODO: lighted button should use lockout config? + else if (event == EV_tick) { + if (momentary_active) { + // 0 = ramping, 1 = strobes + if (momentary_mode == 1) { + return strobe_state(event, arg); + } + } + else { + if (arg > TICKS_PER_SECOND*15) { // sleep after 15 seconds + go_to_standby = 1; // sleep while light is off + // TODO: lighted button should use lockout config? + } } return MISCHIEF_MANAGED; } @@ -2181,7 +2204,8 @@ void loop() { if (0) {} #ifdef USE_STROBE_STATE - else if (state == strobe_state) { + else if ((state == strobe_state) + || ((state == momentary_state) && (momentary_mode == 1) && (momentary_active)) ) { // also handle momentary strobes uint8_t st = strobe_type; switch(st) { |
