Skip to content

Instantly share code, notes, and snippets.

@DurvalMenezes
Last active June 12, 2023 14:36
Show Gist options
  • Save DurvalMenezes/e75474b05b35d0118f54c27e22d4cd14 to your computer and use it in GitHub Desktop.
Save DurvalMenezes/e75474b05b35d0118f54c27e22d4cd14 to your computer and use it in GitHub Desktop.
Anduril: implement quick aux LED on/low switching, see description at the top
######################################################################################################################################
# 721-8C_turn_aux_off_low.diff: implements @Light_Veteran feature request[1], to wit:
# 8C will turn the aux LED on (on low) if it’s off, and the same 8C will turn it off if it’s on (whether in low, high or blink).
# [1] per https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/147
#
# Apply it with `patch -p1 <721-8C_turn_aux_off_low.diff` at the same directory you expanded 721.tgz,
# or `patch -p2 <721-8C_turn_aux_off_low.diff` into the same (or other release, but then no guarantees)
#
# 2023-06-12 Written [Durval Menezes, @dmenezes at budgetlightforum.com, u/dmenezes at reddit.com]
######################################################################################################################################
diff -ruN 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c 721-8C_turn_aux_off_low/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c 2023-05-03 01:44:22.000000000 -0400
+++ 721-8C_turn_aux_off_low/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c 2023-06-12 06:13:39.349989117 -0400
@@ -188,6 +188,34 @@
}
#endif
+ #if defined(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) {
+ #if defined(USE_INDICATOR_LED)
+ uint8_t mode = cfg.indicator_led_mode >> 2;
+ if (mode) mode=0; else mode=1;
+ cfg.indicator_led_mode = (mode << 2) + (cfg.indicator_led_mode & 0x03);
+ // redundant, sleep tick does the same thing
+ //indicator_led_update(cfg.indicator_led_mode >> 2, arg);
+ #elif defined(USE_AUX_RGB_LEDS)
+ #endif
+ 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 = (cfg.rgb_led_lockout_mode >> 4);
+ if (mode) mode=0; else mode=1;
+ cfg.rgb_led_lockout_mode = (mode << 4) | (cfg.rgb_led_lockout_mode & 0x0f);
+ rgb_led_update(cfg.rgb_led_lockout_mode, 0);
+ save_config();
+ blink_once();
+ return MISCHIEF_MANAGED;
+ }
+ #endif // end 8 clicks
+
#if defined(USE_EXTENDED_SIMPLE_UI) && defined(USE_SIMPLE_UI)
////////// Every action below here is blocked in the Extended Simple UI //////////
if (cfg.simple_ui_active) {
diff -ruN 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 721-8C_turn_aux_off_low/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 2023-05-03 01:44:22.000000000 -0400
+++ 721-8C_turn_aux_off_low/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 2023-06-12 05:55:37.413551381 -0400
@@ -303,6 +303,30 @@
}
#endif // end 7 clicks
+
+ #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 = (cfg.indicator_led_mode & 3);
+ if (mode) mode=0; else mode=1;
+ cfg.indicator_led_mode = (cfg.indicator_led_mode & 0b11111100) | mode;
+ 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 = (cfg.rgb_led_off_mode >> 4);
+ if (mode) mode=0; else mode=1;
+ cfg.rgb_led_off_mode = (mode << 4) | (cfg.rgb_led_off_mode & 0x0f);
+ rgb_led_update(cfg.rgb_led_off_mode, 0);
+ save_config();
+ blink_once();
+ return MISCHIEF_MANAGED;
+ }
+ #endif // end 8 clicks
+
////////// Every action below here is blocked in the Extended Simple UI //////////
#ifdef USE_SIMPLE_UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment