aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hwdef-BLF_GT_Mini.h4
-rw-r--r--spaghetti-monster/anduril/anduril.c21
-rwxr-xr-xspaghetti-monster/anduril/build-all.sh1
-rw-r--r--spaghetti-monster/anduril/cfg-blf-gt-mini.h11
-rw-r--r--spaghetti-monster/fsm-events.c8
-rw-r--r--tk-attiny.h3
6 files changed, 37 insertions, 11 deletions
diff --git a/hwdef-BLF_GT_Mini.h b/hwdef-BLF_GT_Mini.h
new file mode 100644
index 0000000..504c561
--- /dev/null
+++ b/hwdef-BLF_GT_Mini.h
@@ -0,0 +1,4 @@
+/* BLF/Lumintop GT Mini driver layout
+ */
+// exactly the same as a D1S, but with a lighted button
+#include "hwdef-Emisar_D1S.h"
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;
}
diff --git a/tk-attiny.h b/tk-attiny.h
index eb971dd..d121709 100644
--- a/tk-attiny.h
+++ b/tk-attiny.h
@@ -78,6 +78,9 @@
#elif defined(FSM_BLF_GT_DRIVER)
#include "hwdef-BLF_GT.h"
+#elif defined(FSM_BLF_GT_MINI_DRIVER)
+#include "hwdef-BLF_GT_Mini.h"
+
#elif defined(FSM_BLF_Q8_DRIVER)
#include "hwdef-BLF_Q8.h"