Anduril 2 feature change suggestions

Finally finished it, here’s the tested and working hex: http://www.durval.com/xfer-only/anduril.emisar-d4sv2-tintramp_-_DONT_USE_BUTTON_LED_WHILE_ON_+_DONT_BLINK_AT_RAMP_CEIL_+_8C_QUICK_AUX_SWITCH_-_2023090904.zip

And the patch source:
#3: 642-8C_QUICK_AUX_SWITCH.diff

--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/off-mode.c.orig-2023090904  2021-09-01 00:07:45.000000000 -0400
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/off-mode.c  2023-09-10 14:06:07.362758269 -0300
@@ -318,6 +318,49 @@
     }
     #endif  // end 7 clicks
 
+    #ifdef USE_QUICK_AUX_SWITCH
+        #ifdef USE_INDICATOR_LED
+        // 8 clicks: if indicator LEDs (aka "aux LEDs") are not off, change them to off; if they're already off, change them to low
+        //  See: https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/145
+        else if (event == EV_8clicks) {
+            uint8_t mode = (indicator_led_mode & 3);
+            uint8_t previous_mode = (previous_indicator_led_mode & 3);
+            if (mode) {
+                previous_mode = mode;
+                mode = 0;
+           } else {
+                mode = previous_mode;
+                previous_mode = 0;
+            }
+            indicator_led_mode = (indicator_led_mode & 0b11111100) | mode;
+            previous_indicator_led_mode = (previous_indicator_led_mode & 0b11111100) | previous_mode;
+            // redundant, sleep tick does the same thing
+            //indicator_led_update(indicator_led_mode & 0x03, arg);
+            save_config();
+            return MISCHIEF_MANAGED;
+        }
+        #elif defined(USE_AUX_RGB_LEDS)
+        // 8 clicks: if RGB aux LED pattern is not off, change it to off; if it's already off, change it to low
+        else if (event == EV_8clicks) {
+            uint8_t mode = (rgb_led_off_mode >> 4);
+            uint8_t previous_mode = (previous_rgb_led_off_mode >> 4);
+            if (mode) {
+                previous_mode = mode;
+                mode = 0;
+            } else {
+                mode = previous_mode;
+                previous_mode = 0;
+            }
+            rgb_led_off_mode = (mode << 4) | (rgb_led_off_mode & 0x0f);
+            previous_rgb_led_off_mode = (previous_mode << 4) | (previous_rgb_led_off_mode & 0x0f);
+            rgb_led_update(rgb_led_off_mode, 0);
+            save_config();
+            blink_once();
+            return MISCHIEF_MANAGED;
+        }
+        #endif  // end 8 clicks
+    #endif
+
     #ifdef USE_GLOBALS_CONFIG
     // 9 clicks, but hold last click: configure misc global settings
     else if ((event == EV_click9_hold) && (!arg)) {
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config.c.orig-2023090904  2021-11-03 07:16:05.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config.c  2023-09-10 14:07:11.145032045 -0300
@@ -95,6 +95,15 @@
         #ifdef USE_AUTOLOCK
         autolock_time = eeprom[autolock_time_e];
         #endif
+        #ifdef USE_QUICK_AUX_SWITCH
+            #ifdef USE_INDICATOR_LED
+                previous_indicator_led_off_mode = eeprom[previous_indicator_led_off_mode_e];
+            #endif
+            #ifdef USE_AUX_RGB_LEDS
+                previous_rgb_led_off_mode = eeprom[previous_rgb_led_off_mode_e];
+                previous_rgb_led_lockout_mode = eeprom[previous_rgb_led_lockout_mode_e];
+            #endif
+        #endif
     }
     #ifdef START_AT_MEMORIZED_LEVEL
     if (load_eeprom_wl()) {
@@ -174,6 +183,15 @@
     #ifdef USE_AUTOLOCK
     eeprom[autolock_time_e] = autolock_time;
     #endif
+    #ifdef USE_QUICK_AUX_SWITCH
+        #ifdef USE_INDICATOR_LED
+            eeprom[previous_indicator_led_off_mode_e] = previous_indicator_led_off_mode;
+        #endif
+        #ifdef USE_AUX_RGB_LEDS
+            eeprom[previous_rgb_led_off_mode_e] = previous_rgb_led_off_mode;
+            eeprom[previous_rgb_led_lockout_mode_e] = previous_rgb_led_lockout_mode;
+        #endif
+    #endif
 
     save_eeprom();
 }
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c.orig-2023090904      2021-12-13 19:19:19.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c      2023-09-10 14:02:23.150724506 -0300
@@ -187,6 +187,49 @@
     }
     #endif
 
+    #ifdef USE_QUICK_AUX_SWITCH
+         #if defined(USE_INDICATOR_LED)
+         // 8 clicks: if indicator LEDs (aka "aux LEDs") mode is not off, save it and change it to off; if it's already off, change it back to saved
+         //  See: https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/145
+         else if (event == EV_8clicks) {
+             uint8_t mode = indicator_led_mode >> 2;
+                uint8_t previous_mode = previous_indicator_led_mode >> 2;
+             if (mode) {
+                 previous_mode = mode;
+                 mode = 0;
+             } else {
+                 mode = previous_mode;
+                 previous_mode = 0;
+             }
+             indicator_led_mode = (mode << 2) + (indicator_led_mode & 0x03);
+             previous_indicator_led_mode = (previous_mode << 2) + (previous_indicator_led_mode & 0x03);
+             // redundant, sleep tick does the same thing
+             //indicator_led_update(indicator_led_mode >> 2, arg);
+             save_config();
+             return MISCHIEF_MANAGED;
+         }
+         #elif defined(USE_AUX_RGB_LEDS)
+         // 8 clicks: if RGB aux LED pattern mode is not off, save it and change it to off; if it's already off, change it back to saved
+         else if (event == EV_8clicks) {
+             uint8_t mode = (rgb_led_lockout_mode >> 4);
+             uint8_t previous_mode = (previous_rgb_led_lockout_mode >> 4);
+             if (mode) {
+                 previous_mode = mode;
+                 mode = 0;
+             } else {
+                 mode = previous_mode;
+                 previous_mode = 0;
+             }
+             rgb_led_lockout_mode = (mode << 4) | (rgb_led_lockout_mode & 0x0f);
+             previous_rgb_led_lockout_mode = (previous_mode << 4) | (previous_rgb_led_lockout_mode & 0x0f);
+             rgb_led_update(rgb_led_lockout_mode, 0);
+             save_config();
+             blink_once();
+             return MISCHIEF_MANAGED;
+         }
+         #endif // end 8 clicks
+     #endif
+
     return EVENT_NOT_HANDLED;
 }
 
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/aux-leds.h.orig-2023090904  2021-04-14 02:09:23.000000000 -0400
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/aux-leds.h  2023-09-10 13:57:28.340059657 -0300
@@ -83,5 +83,14 @@
     #endif
 #endif
 
+#ifdef USE_QUICK_AUX_SWITCH
+  #ifdef USE_INDICATOR_LED
+          uint8_t previous_indicator_led_mode = ~INDICATOR_LED_DEFAULT_MODE;
+  #endif
+#endif
 
 #endif
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h.orig-2023090904      2021-11-03 07:16:05.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h      2023-09-09 18:00:25.047904773 -0300
@@ -95,6 +95,11 @@
     #ifdef USE_AUTOLOCK
     autolock_time_e,
     #endif
+    #ifdef USE_QUICK_AUX_SWITCH
+    previous_indicator_led_mode_e,
+    previous_rgb_led_off_mode_e,
+    previous_rgb_led_lockout_mode_e,
+    #endif
     eeprom_indexes_e_END
 } eeprom_indexes_e;
 #define EEPROM_BYTES eeprom_indexes_e_END
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/config-default.h.orig-2023090904    2021-12-08 19:36:58.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/config-default.h    2023-09-09 17:49:37.215866774 -0300
@@ -194,4 +194,7 @@
 // those oscillations
 //#define USE_LOWPASS_WHILE_ASLEEP
 
+// enable quick switch to/from current aux mode to off
+#define USE_QUICK_AUX_SWITCH
+
 #endif

Thanks to @jon_slider for coming up with the idea, and for helping me with the testing.

I would just like to add that, to my great surprise, this last mod also worked first try despite its relative complexity.

This goes on to show what a great programmer @Toykeeper is, her code is so well-written that even being a relatively ignorant person (meaning, I know C well, and embedded programming relatively well, but very little flashlight electronics and even less Anduril internals) I was able to ‘parachute’ into her code and easily make these changes. Kudos to her! :+1: :+1: :+1:

2 Thanks