diff options
| author | Selene ToyKeeper | 2018-09-01 18:06:39 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-09-01 18:06:39 -0600 |
| commit | a572e004ae2439f89237eae5223c21e5cd9b282d (patch) | |
| tree | 6eeac51cb55bd0faf6e6215f24e0dabbc43a2531 /spaghetti-monster | |
| parent | First Anduril build for Fireflies ROT66. (diff) | |
| parent | Reduced ROM size another 10 bytes by removing redundant call to nearest_level(). (diff) | |
| download | anduril-a572e004ae2439f89237eae5223c21e5cd9b282d.tar.gz anduril-a572e004ae2439f89237eae5223c21e5cd9b282d.tar.bz2 anduril-a572e004ae2439f89237eae5223c21e5cd9b282d.zip | |
merged updates/fixes from fsm branch
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 21 | ||||
| -rwxr-xr-x | spaghetti-monster/anduril/build-all.sh | 1 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-gt-mini.h | 11 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-events.c | 8 |
4 files changed, 30 insertions, 11 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 533ace4..c8c1c67 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -21,6 +21,7 @@ /********* User-configurable options *********/ // Physical driver type (uncomment one of the following or define it at the gcc command line) //#define FSM_BLF_GT_DRIVER +//#define FSM_BLF_GT_MINI_DRIVER //#define FSM_BLF_Q8_DRIVER //#define FSM_EMISAR_D1_DRIVER //#define FSM_EMISAR_D1S_DRIVER @@ -71,6 +72,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" @@ -377,7 +381,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; @@ -391,7 +395,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; @@ -411,14 +415,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 @@ -1100,16 +1104,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); diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh index 306dabc..9b5983d 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 + 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; } |
