From 2e4f4162a85092207729fc8b5691cbd02e5b5b64 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 31 Aug 2018 21:05:30 -0600 Subject: Added support for the BLF/Lumintop GT Mini. (same as the Emisar D1S, but with a lighted button) --- spaghetti-monster/anduril/anduril.c | 4 ++++ spaghetti-monster/anduril/build-all.sh | 1 + spaghetti-monster/anduril/cfg-blf-gt-mini.h | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 spaghetti-monster/anduril/cfg-blf-gt-mini.h (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index bf16da5..d4e541d 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -26,6 +26,7 @@ //#define FSM_BLF_Q8_DRIVER //#define FSM_FW3A_DRIVER //#define FSM_BLF_GT_DRIVER +//#define FSM_BLF_GT_MINI_DRIVER #define USE_LVP // FIXME: won't build when this option is turned off @@ -68,6 +69,9 @@ #if defined(FSM_BLF_GT_DRIVER) #include "cfg-blf-gt.h" +#elif defined(FSM_BLF_GT_MINI_DRIVER) +#include "cfg-blf-gt-mini.h" + #elif defined(FSM_BLF_Q8_DRIVER) #include "cfg-blf-q8.h" diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh index d0c0d5c..85e3cc9 100755 --- a/spaghetti-monster/anduril/build-all.sh +++ b/spaghetti-monster/anduril/build-all.sh @@ -2,6 +2,7 @@ for TARGET in \ BLF_GT \ + BLF_GT_MINI \ BLF_Q8 \ EMISAR_D1 \ EMISAR_D1S \ diff --git a/spaghetti-monster/anduril/cfg-blf-gt-mini.h b/spaghetti-monster/anduril/cfg-blf-gt-mini.h new file mode 100644 index 0000000..885024a --- /dev/null +++ b/spaghetti-monster/anduril/cfg-blf-gt-mini.h @@ -0,0 +1,11 @@ +// BLF/Lumintop GT Mini config options for Anduril +// Same as an Emisar D1S, except it has a lighted button +#include "cfg-emisar-d1s.h" + +// the button lights up +#define USE_INDICATOR_LED +// the button is visible while main LEDs are on +#define USE_INDICATOR_LED_WHILE_RAMPING +// enable blinking indicator LED while off +#define TICK_DURING_STANDBY + -- cgit v1.2.3 From 4e23fbbf8b1a155c830a2db79d412687332ce031 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 1 Sep 2018 17:29:29 -0600 Subject: Reduced moon-during-lockout code size by 10 bytes. --- spaghetti-monster/anduril/anduril.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index d4e541d..f5c2649 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -1098,16 +1098,15 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { last = pgm_read_byte(event + i); if (arg == 0) { // Only turn on/off when button state changes if ((last == A_PRESS) || (last == A_HOLD)) { - // detect moon level and activate it - uint8_t lvl = ramp_smooth_floor; #ifdef LOCKOUT_MOON_LOWEST // Use lowest moon configured + uint8_t lvl = ramp_smooth_floor; if (ramp_discrete_floor < lvl) lvl = ramp_discrete_floor; + set_level(lvl); #else // Use moon from current ramp - if (ramp_style) lvl = ramp_discrete_floor; + set_level(nearest_level(1)); #endif - set_level(lvl); } else if ((last == A_RELEASE) || (last == A_RELEASE_TIMEOUT)) { set_level(0); -- cgit v1.2.3 From 895349ffb2f15ad05de57bf0c5a08d24b5d2a42c Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 1 Sep 2018 17:34:45 -0600 Subject: Fixed bug introduced in trunk r211.1.9, where Anduril's goodnight mode didn't work sometimes. The problem was that goodnight's EV_enter was executing before battcheck's loop() finished. This meant battcheck's exit code would turn the emitter off right after goodnight's init set it to the desired level. --- spaghetti-monster/fsm-events.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c index aa5c3d6..c71e822 100644 --- a/spaghetti-monster/fsm-events.c +++ b/spaghetti-monster/fsm-events.c @@ -160,11 +160,15 @@ uint8_t nice_delay_ms(uint16_t ms) { _delay_loop_2(BOGOMIPS*98/100); #endif // ifdef USE_DYNAMIC_UNDERCLOCKING - process_emissions(); if ((nice_delay_interrupt) || (old_state != current_state)) { - //nice_delay_interrupt = 0; return 0; // state changed; abort } + // handle events only afterward, so that any collapsed delays will + // finish running the UI's loop() code before taking any further actions + // (this helps make sure code runs in the correct order) + // (otherwise, a new state's EV_enter runs before the old state's + // loop() has finished, and things can get weird) + process_emissions(); } return 1; } -- cgit v1.2.3 From d51163492931b248636cdb0aab0bb9df3c1c239c Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 1 Sep 2018 18:03:21 -0600 Subject: Reduced ROM size another 10 bytes by removing redundant call to nearest_level(). Added some comments to clarify what lowest and highest level mean. --- spaghetti-monster/anduril/anduril.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index f5c2649..bbf661d 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -375,7 +375,7 @@ uint8_t off_state(EventPtr event, uint16_t arg) { return MISCHIEF_MANAGED; } #endif - // hold (initially): go to lowest level, but allow abort for regular click + // hold (initially): go to lowest level (floor), but allow abort for regular click else if (event == EV_click1_press) { set_level(nearest_level(1)); return MISCHIEF_MANAGED; @@ -389,7 +389,7 @@ uint8_t off_state(EventPtr event, uint16_t arg) { } return MISCHIEF_MANAGED; } - // hold, release quickly: go to lowest level + // hold, release quickly: go to lowest level (floor) else if (event == EV_click1_hold_release) { set_state(steady_state, 1); return MISCHIEF_MANAGED; @@ -409,14 +409,14 @@ uint8_t off_state(EventPtr event, uint16_t arg) { set_level(0); return MISCHIEF_MANAGED; } - // click, hold: go to highest level (for ramping down) + // click, hold: go to highest level (ceiling) (for ramping down) else if (event == EV_click2_hold) { set_state(steady_state, MAX_LEVEL); return MISCHIEF_MANAGED; } - // 2 clicks: highest mode + // 2 clicks: highest mode (ceiling) else if (event == EV_2clicks) { - set_state(steady_state, nearest_level(MAX_LEVEL)); + set_state(steady_state, MAX_LEVEL); return MISCHIEF_MANAGED; } #ifdef USE_BATTCHECK -- cgit v1.2.3