aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-03-28 13:27:00 -0600
committerSelene ToyKeeper2023-03-28 13:27:00 -0600
commit9634e4a8073af20644cafef30048f47b9287abd9 (patch)
tree0a25af33c75f7c3147b9694066b645e6d4212460
parentstrobe modes: added 4C to cycle backward through strobes (diff)
downloadanduril-9634e4a8073af20644cafef30048f47b9287abd9.tar.gz
anduril-9634e4a8073af20644cafef30048f47b9287abd9.tar.bz2
anduril-9634e4a8073af20644cafef30048f47b9287abd9.zip
added a "tactical mode" on "Off -> 6C"
Tactical Mode is similar to Momentary Mode or Lockout Mode, but it has three mode slots which are independent of other config values. The default is a classic tactical setup with "high, low, strobe", each with immediate activation as soon as the button is pressed. Each slot can be a regular ramp level 1 to 150, or a strobe-group mode. To exit, press 6C or loosen/tighten the tailcap. Aux LEDs follow the same pattern as Lockout Mode. To configure, use 7H. There are 3 options, one for each slot. Enter a number 1 to 150 for a ramp mode, 0 for current strobe, or 151+ for a specific strobe mode.
-rw-r--r--spaghetti-monster/anduril/anduril.c16
-rw-r--r--spaghetti-monster/anduril/cfg-blf-gt.h2
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern.h3
-rw-r--r--spaghetti-monster/anduril/cfg-blf-q8.h1
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d18.h3
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d1s.h3
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4.h2
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4s.h3
-rw-r--r--spaghetti-monster/anduril/cfg-ff-e01.h2
-rw-r--r--spaghetti-monster/anduril/cfg-ff-pl47.h2
-rw-r--r--spaghetti-monster/anduril/cfg-ff-pl47g2.h2
-rw-r--r--spaghetti-monster/anduril/cfg-ff-rot66.h3
-rw-r--r--spaghetti-monster/anduril/cfg-fw3a.h3
-rw-r--r--spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h2
-rw-r--r--spaghetti-monster/anduril/cfg-mateminco-mf01s.h2
-rw-r--r--spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h3
-rw-r--r--spaghetti-monster/anduril/config-default.h3
-rw-r--r--spaghetti-monster/anduril/load-save-config-fsm.h5
-rw-r--r--spaghetti-monster/anduril/load-save-config.c10
-rw-r--r--spaghetti-monster/anduril/momentary-mode.c6
-rw-r--r--spaghetti-monster/anduril/off-mode.c8
-rw-r--r--spaghetti-monster/anduril/tactical-mode.c125
-rw-r--r--spaghetti-monster/anduril/tactical-mode.h34
23 files changed, 239 insertions, 4 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index de9b332..47cd00f 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -134,6 +134,10 @@
#include "momentary-mode.h"
#endif
+#ifdef USE_TACTICAL_MODE
+#include "tactical-mode.h"
+#endif
+
#ifdef USE_TINT_RAMPING
#include "tint-ramping.h"
#endif
@@ -189,6 +193,10 @@
#include "momentary-mode.c"
#endif
+#ifdef USE_TACTICAL_MODE
+#include "tactical-mode.c"
+#endif
+
#ifdef USE_TINT_RAMPING
#include "tint-ramping.c"
#endif
@@ -282,7 +290,13 @@ void loop() {
else if ((state == strobe_state)
#ifdef USE_MOMENTARY_MODE
// also handle momentary strobes
- || ((state == momentary_state) && (momentary_mode == 1) && (momentary_active))
+ || ((
+ (state == momentary_state)
+ #ifdef USE_TACTICAL_MODE
+ || (state == tactical_state)
+ #endif
+ )
+ && (momentary_mode == 1) && (momentary_active))
#endif
) {
strobe_state_iter();
diff --git a/spaghetti-monster/anduril/cfg-blf-gt.h b/spaghetti-monster/anduril/cfg-blf-gt.h
index 7f880dd..977d877 100644
--- a/spaghetti-monster/anduril/cfg-blf-gt.h
+++ b/spaghetti-monster/anduril/cfg-blf-gt.h
@@ -44,3 +44,5 @@
// stop panicking at 80% power, this light has plenty of thermal mass
#define THERM_FASTER_LEVEL POWER_80PX // throttle back faster when high
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h
index 56ed410..251c0db 100644
--- a/spaghetti-monster/anduril/cfg-blf-lantern.h
+++ b/spaghetti-monster/anduril/cfg-blf-lantern.h
@@ -82,3 +82,6 @@
#ifndef BLINK_AT_RAMP_CEIL
#define BLINK_AT_RAMP_CEIL
#endif
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-blf-q8.h b/spaghetti-monster/anduril/cfg-blf-q8.h
index f657adb..a9c48f6 100644
--- a/spaghetti-monster/anduril/cfg-blf-q8.h
+++ b/spaghetti-monster/anduril/cfg-blf-q8.h
@@ -53,3 +53,4 @@
//#undef USE_VOLTAGE_CORRECTION
//#undef USE_2C_STYLE_CONFIG
//#undef USE_TACTICAL_STROBE_MODE
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-emisar-d18.h b/spaghetti-monster/anduril/cfg-emisar-d18.h
index 2147dc5..6644513 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d18.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d18.h
@@ -37,3 +37,6 @@
// stop panicking at about ~40% power or ~5000 lm
#define THERM_FASTER_LEVEL 125
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-emisar-d1s.h b/spaghetti-monster/anduril/cfg-emisar-d1s.h
index e6ca0f1..47cecf6 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d1s.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d1s.h
@@ -14,3 +14,6 @@
#undef THERM_FASTER_LEVEL
#endif
#define THERM_FASTER_LEVEL 144 // throttle back faster when high
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4.h b/spaghetti-monster/anduril/cfg-emisar-d4.h
index b21c6a3..e77ac38 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4.h
@@ -28,3 +28,5 @@
// stop panicking at ~30% power or ~1200 lm
#define THERM_FASTER_LEVEL 105
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4s.h b/spaghetti-monster/anduril/cfg-emisar-d4s.h
index f224377..3c82460 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4s.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4s.h
@@ -43,3 +43,6 @@
#endif
#define MIN_THERM_STEPDOWN 60 // lowest value it'll step down to
#define THERM_FASTER_LEVEL (RAMP_SIZE-20) // don't throttle back faster when high
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-ff-e01.h b/spaghetti-monster/anduril/cfg-ff-e01.h
index c035180..f26bfb4 100644
--- a/spaghetti-monster/anduril/cfg-ff-e01.h
+++ b/spaghetti-monster/anduril/cfg-ff-e01.h
@@ -19,3 +19,5 @@
#define SIMPLE_UI_CEIL 130
#define SIMPLE_UI_STEPS 4
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-ff-pl47.h b/spaghetti-monster/anduril/cfg-ff-pl47.h
index 1d46801..54827cf 100644
--- a/spaghetti-monster/anduril/cfg-ff-pl47.h
+++ b/spaghetti-monster/anduril/cfg-ff-pl47.h
@@ -64,3 +64,5 @@
#undef BLINK_AT_RAMP_MIDDLE
#undef BLINK_AT_RAMP_CEIL
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-ff-pl47g2.h b/spaghetti-monster/anduril/cfg-ff-pl47g2.h
index 8d80555..c11ba28 100644
--- a/spaghetti-monster/anduril/cfg-ff-pl47g2.h
+++ b/spaghetti-monster/anduril/cfg-ff-pl47g2.h
@@ -51,3 +51,5 @@
#undef BLINK_AT_RAMP_MIDDLE
#undef BLINK_AT_RAMP_CEIL
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h
index 481808a..d386f17 100644
--- a/spaghetti-monster/anduril/cfg-ff-rot66.h
+++ b/spaghetti-monster/anduril/cfg-ff-rot66.h
@@ -53,3 +53,6 @@
#ifdef USE_LOWPASS_WHILE_ASLEEP
#undef USE_LOWPASS_WHILE_ASLEEP
#endif
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-fw3a.h b/spaghetti-monster/anduril/cfg-fw3a.h
index 0ef2e15..24a77c0 100644
--- a/spaghetti-monster/anduril/cfg-fw3a.h
+++ b/spaghetti-monster/anduril/cfg-fw3a.h
@@ -25,3 +25,6 @@
// can't reset the normal way because power is connected before the button
#define USE_SOFT_FACTORY_RESET
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
index 83b2614..894ebaf 100644
--- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
+++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
@@ -64,3 +64,5 @@
#undef USE_LOWPASS_WHILE_ASLEEP
#endif
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01s.h b/spaghetti-monster/anduril/cfg-mateminco-mf01s.h
index b1f3b6e..49dbcf0 100644
--- a/spaghetti-monster/anduril/cfg-mateminco-mf01s.h
+++ b/spaghetti-monster/anduril/cfg-mateminco-mf01s.h
@@ -45,3 +45,5 @@
#define THERM_FASTER_LEVEL 125 // throttle back faster when high (>6000 lm)
#define THERM_HARD_TURBO_DROP // this light is massively overpowered
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h
index b409c39..c5b40e2 100644
--- a/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h
+++ b/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h
@@ -49,3 +49,6 @@
// Allow 3C in Simple UI for switching between smooth and stepped ramping
#define USE_SIMPLE_UI_RAMPING_TOGGLE
+
+// too big, turn off extra features
+#undef USE_TACTICAL_MODE
diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h
index 0e70347..171c8b3 100644
--- a/spaghetti-monster/anduril/config-default.h
+++ b/spaghetti-monster/anduril/config-default.h
@@ -180,6 +180,9 @@
// enable momentary mode
#define USE_MOMENTARY_MODE
+// enable tactical mode
+#define USE_TACTICAL_MODE
+
// enable a shortcut for +10 in number entry mode
// (click for +1, hold for +10)
diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h
index ba3c69b..f0de161 100644
--- a/spaghetti-monster/anduril/load-save-config-fsm.h
+++ b/spaghetti-monster/anduril/load-save-config-fsm.h
@@ -95,6 +95,11 @@ typedef enum {
#ifdef USE_AUTOLOCK
autolock_time_e,
#endif
+ #ifdef USE_TACTICAL_MODE
+ tactical_lvl_1_e,
+ tactical_lvl_2_e,
+ tactical_lvl_3_e,
+ #endif
eeprom_indexes_e_END
} eeprom_indexes_e;
#define EEPROM_BYTES eeprom_indexes_e_END
diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c
index 4987def..4101e7a 100644
--- a/spaghetti-monster/anduril/load-save-config.c
+++ b/spaghetti-monster/anduril/load-save-config.c
@@ -95,6 +95,11 @@ void load_config() {
#ifdef USE_AUTOLOCK
autolock_time = eeprom[autolock_time_e];
#endif
+ #ifdef USE_TACTICAL_MODE
+ tactical_levels[0] = eeprom[tactical_lvl_1_e];
+ tactical_levels[1] = eeprom[tactical_lvl_2_e];
+ tactical_levels[2] = eeprom[tactical_lvl_3_e];
+ #endif
}
#ifdef START_AT_MEMORIZED_LEVEL
if (load_eeprom_wl()) {
@@ -174,6 +179,11 @@ void save_config() {
#ifdef USE_AUTOLOCK
eeprom[autolock_time_e] = autolock_time;
#endif
+ #ifdef USE_TACTICAL_MODE
+ eeprom[tactical_lvl_1_e] = tactical_levels[0];
+ eeprom[tactical_lvl_2_e] = tactical_levels[1];
+ eeprom[tactical_lvl_3_e] = tactical_levels[2];
+ #endif
save_eeprom();
}
diff --git a/spaghetti-monster/anduril/momentary-mode.c b/spaghetti-monster/anduril/momentary-mode.c
index 8d111c7..08879a1 100644
--- a/spaghetti-monster/anduril/momentary-mode.c
+++ b/spaghetti-monster/anduril/momentary-mode.c
@@ -25,7 +25,7 @@
uint8_t momentary_state(Event event, uint16_t arg) {
// init strobe mode, if relevant
#ifdef USE_STROBE_STATE
- if ((event == EV_enter_state) && (momentary_mode == 1)) {
+ if ((event == EV_enter_state) && (momentary_mode != 0)) {
strobe_state(event, arg);
}
#endif
@@ -56,8 +56,8 @@ uint8_t momentary_state(Event event, uint16_t arg) {
else if (event == EV_tick) {
#ifdef USE_STROBE_STATE
if (momentary_active) {
- // 0 = ramping, 1 = strobes
- if (momentary_mode == 1) {
+ // 0 = ramping, non-zero = strobes
+ if (momentary_mode != 0) {
return strobe_state(event, arg);
}
}
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
index c879e56..6781ade 100644
--- a/spaghetti-monster/anduril/off-mode.c
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -271,6 +271,14 @@ uint8_t off_state(Event event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
#endif
+ #ifdef USE_TACTICAL_MODE
+ // 6 clicks: tactical mode
+ else if (event == EV_6clicks) {
+ blink_once();
+ set_state(tactical_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
#ifdef USE_INDICATOR_LED
// 7 clicks: change indicator LED mode
else if (event == EV_7clicks) {
diff --git a/spaghetti-monster/anduril/tactical-mode.c b/spaghetti-monster/anduril/tactical-mode.c
new file mode 100644
index 0000000..7e9d66b
--- /dev/null
+++ b/spaghetti-monster/anduril/tactical-mode.c
@@ -0,0 +1,125 @@
+/*
+ * tactical-mode.c: Tactical (ish) mode for Anduril.
+ *
+ * Copyright (C) 2023 Selene ToyKeeper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TACTICAL_MODE_C
+#define TACTICAL_MODE_C
+
+#include "tactical-mode.h"
+
+// TODO: save these in eeprom
+uint8_t tactical_levels[] = { TACTICAL_LEVELS }; // high, low, strobe
+
+uint8_t tactical_state(Event event, uint16_t arg) {
+ // momentary(ish) tactical mode
+ uint8_t mem_lvl = memorized_level; // save this to restore it later
+ uint8_t ret = EVENT_NOT_HANDLED;
+
+ // button is being held
+ if ((event & (B_CLICK | B_PRESS)) == (B_CLICK | B_PRESS)) {
+ // 1H: 1st level
+ // 2H: 2nd level
+ // 3H: 3rd level
+ // 4+: nothing
+ momentary_active = 0;
+ ret = EVENT_HANDLED;
+ uint8_t click = event & 0x0f; // click number
+ if (click <= 3) {
+ momentary_active = 1;
+ uint8_t lvl;
+ lvl = tactical_levels[click-1];
+ if ((1 <= lvl) && (lvl <= RAMP_SIZE)) { // steady output
+ memorized_level = lvl;
+ momentary_mode = 0;
+ } else { // momentary strobe mode
+ momentary_mode = 1;
+ if (lvl > RAMP_SIZE) {
+ strobe_type = (lvl - RAMP_SIZE - 1) % strobe_mode_END;
+ }
+ }
+ }
+ }
+ // button was released
+ else if ((event & (B_CLICK | B_PRESS)) == (B_CLICK)) {
+ momentary_active = 0;
+ set_level(0);
+ }
+
+ // delegate to momentary mode while button is pressed
+ if (momentary_active) {
+ momentary_state(event, arg);
+ }
+
+ memorized_level = mem_lvl; // restore temporarily overridden mem level
+
+ // copy lockout mode's aux LED and sleep behaviors
+ if (event == EV_enter_state) {
+ lockout_state(event, arg);
+ }
+ else if (event == EV_tick) {
+ if (! momentary_active) {
+ return lockout_state(event, arg);
+ }
+ return EVENT_HANDLED;
+ }
+ else if (event == EV_sleep_tick) {
+ return lockout_state(event, arg);
+ }
+
+ // 6 clicks: exit and turn off
+ else if (event == EV_6clicks) {
+ blink_once();
+ set_state(off_state, 0);
+ return EVENT_HANDLED;
+ }
+
+ ////////// Every action below here is blocked in the simple UI //////////
+ // (unnecessary since this entire mode is blocked in simple UI)
+ /*
+ #ifdef USE_SIMPLE_UI
+ if (simple_ui_active) {
+ return EVENT_NOT_HANDLED;
+ }
+ #endif
+ */
+
+ // 7H: configure tactical mode
+ else if (event == EV_click7_hold) {
+ push_state(tactical_config_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+
+ return ret;
+}
+
+void tactical_config_save(uint8_t step, uint8_t value) {
+ // update tac mode values
+ // 3 values
+ // each value is 1 to 150, or other:
+ // - 1..150 is a ramp level
+ // - other means "strobe mode"
+ tactical_levels[step - 1] = value;
+}
+
+uint8_t tactical_config_state(Event event, uint16_t arg) {
+ return config_state_base(event, arg, 3, tactical_config_save);
+}
+
+
+#endif
+
diff --git a/spaghetti-monster/anduril/tactical-mode.h b/spaghetti-monster/anduril/tactical-mode.h
new file mode 100644
index 0000000..4403314
--- /dev/null
+++ b/spaghetti-monster/anduril/tactical-mode.h
@@ -0,0 +1,34 @@
+/*
+ * tactical-mode.h: Tactical mode for Anduril.
+ *
+ * Copyright (C) 2023 Selene ToyKeeper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TACTICAL_MODE_H
+#define TACTICAL_MODE_H
+
+// tactical(ish) mode
+uint8_t tactical_state(Event event, uint16_t arg);
+
+#ifndef TACTICAL_LEVELS
+// high, low, tactical strobe
+#define TACTICAL_LEVELS 120,30,(RAMP_SIZE+2)
+#endif
+uint8_t tactical_levels[];
+uint8_t tactical_config_state(Event event, uint16_t arg);
+
+
+#endif