Created
June 16, 2023 10:00
-
-
Save DurvalMenezes/5eeb434404ea215ef4a88edef414e9a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################################################################### | |
# 721-8C_quick_aux_switch.diff: implements @Light_Veteran feature request[1], to wit: | |
# 8C will turn the aux LED off if it’s on (on whatever mode), and the same 8C will turn it back to the mode it was before. | |
# | |
# [1] per https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/147 and following comments | |
# | |
# Apply it with `patch -p1 < 721-8C_quick_aux_switch.diff` at the same directory you expanded 721.tgz, | |
# or `patch -p2 <721-8C_quick_aux_switch.diff` into the same (or other release, but then no guarantees) | |
# | |
# 2023-06-12 Written [Durval Menezes, @dmenezes at budgetlightforum.com and lemmy.world, u/dmenezes at reddit.com] | |
# 2023-06-15 Saves the previous mode in EEPROM and switches back to it on a 2nd 8C [Durval Menezes] | |
###################################################################################################################################### | |
diff -ruN -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h | |
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h 2023-04-19 04:21:19.000000000 -0400 | |
+++ 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h 2023-06-15 05:26:20.033951435 -0400 | |
@@ -185,3 +185,6 @@ | |
#define USE_STEPPED_TINT_RAMPING | |
#define DEFAULT_TINT_RAMP_STYLE 0 // smooth | |
+// enable quick switch to/from current aux mode to off | |
+#define USE_QUICK_AUX_SWITCH | |
+ | |
diff -ruN -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h | |
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 2023-05-30 08:10:39.000000000 -0400 | |
+++ 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 2023-06-16 05:51:17.629052864 -0400 | |
@@ -115,11 +115,25 @@ | |
uint8_t jump_start_level; | |
#endif | |
+ ///// quick aux switch saved previous modes | |
+ #ifdef USE_QUICK_AUX_SWITCH | |
+ uint8_t previous_indicator_led_mode; | |
+ uint8_t previous_rgb_led_off_mode; | |
+ uint8_t previous_rgb_led_lockout_mode; | |
+ #endif | |
+ | |
} Config; | |
// auto-detect how many eeprom bytes | |
#define EEPROM_BYTES sizeof(Config) | |
+// Abort compilation if eeprom size exceeded | |
+// Good explanation on how this works: https://scaryreasoner.wordpress.com/2009/02/28/checking-sizeof-at-compile-time/ | |
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | |
+__attribute__((unused)) static void build_bug_on() { // this is never called and doesn't generate any code, serves only to expand the macro | |
+ BUILD_BUG_ON(EEPROM_BYTES > EEPROM_SIZE); // EEPROM_SIZE comes from avr-gcc and so should adjust automatically for each MCU | |
+} | |
+ | |
// declare this so FSM can see it, | |
// but define its values in a file which loads later | |
Config cfg; | |
diff -ruN -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h | |
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h 2023-05-02 10:39:28.000000000 -0400 | |
+++ 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h 2023-06-15 19:41:38.664542188 -0400 | |
@@ -156,5 +156,16 @@ | |
.jump_start_level = DEFAULT_JUMP_START_LEVEL, | |
#endif | |
+ ///// quick aux switch saved previous modes | |
+ #ifdef USE_QUICK_AUX_SWITCH | |
+ #ifdef USE_INDICATOR_LED | |
+ .previous_indicator_led_mode = ~INDICATOR_LED_DEFAULT_MODE, | |
+ #endif | |
+ #ifdef USE_AUX_RGB_LEDS | |
+ .previous_rgb_led_off_mode = ~RGB_LED_OFF_DEFAULT, | |
+ .previous_rgb_led_lockout_mode = ~RGB_LED_LOCKOUT_DEFAULT, | |
+ #endif | |
+ #endif | |
+ | |
}; | |
diff -ruN -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c 721-8C_quick_aux_switch/~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_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c 2023-06-15 07:08:36.464099048 -0400 | |
@@ -188,6 +188,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 = cfg.indicator_led_mode >> 2; | |
+ uint8_t previous_mode = cfg.previous_indicator_led_mode >> 2; | |
+ if (mode) { | |
+ previous_mode = mode; | |
+ mode = 0; | |
+ } else { | |
+ mode = previous_mode; | |
+ previous_mode = 0; | |
+ } | |
+ cfg.indicator_led_mode = (mode << 2) + (cfg.indicator_led_mode & 0x03); | |
+ cfg.previous_indicator_led_mode = (previous_mode << 2) + (cfg.previous_indicator_led_mode & 0x03); | |
+ // redundant, sleep tick does the same thing | |
+ //indicator_led_update(cfg.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 = (cfg.rgb_led_lockout_mode >> 4); | |
+ uint8_t previous_mode = (cfg.previous_rgb_led_lockout_mode >> 4); | |
+ if (mode) { | |
+ previous_mode = mode; | |
+ mode = 0; | |
+ } else { | |
+ mode = previous_mode; | |
+ previous_mode = 0; | |
+ } | |
+ cfg.rgb_led_lockout_mode = (mode << 4) | (cfg.rgb_led_lockout_mode & 0x0f); | |
+ cfg.previous_rgb_led_lockout_mode = (previous_mode << 4) | (cfg.previous_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 | |
+ #endif | |
+ | |
#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 -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 721-8C_quick_aux_switch/~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_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 2023-06-15 06:00:37.693681984 -0400 | |
@@ -303,6 +303,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 = (cfg.indicator_led_mode & 3); | |
+ uint8_t previous_mode = (cfg.previous_indicator_led_mode & 3); | |
+ if (mode) { | |
+ previous_mode = mode; | |
+ mode = 0; | |
+ } else { | |
+ mode = previous_mode; | |
+ previous_mode = 0; | |
+ } | |
+ cfg.indicator_led_mode = (cfg.indicator_led_mode & 0b11111100) | mode; | |
+ cfg.previous_indicator_led_mode = (cfg.previous_indicator_led_mode & 0b11111100) | previous_mode; | |
+ // redundant, sleep tick does the same thing | |
+ //indicator_led_update(cfg.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 = (cfg.rgb_led_off_mode >> 4); | |
+ uint8_t previous_mode = (cfg.previous_rgb_led_off_mode >> 4); | |
+ if (mode) { | |
+ previous_mode = mode; | |
+ mode = 0; | |
+ } else { | |
+ mode = previous_mode; | |
+ previous_mode = 0; | |
+ } | |
+ cfg.rgb_led_off_mode = (mode << 4) | (cfg.rgb_led_off_mode & 0x0f); | |
+ cfg.previous_rgb_led_off_mode = (previous_mode << 4) | (cfg.previous_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 | |
+ #endif | |
+ | |
////////// Every action below here is blocked in the Extended Simple UI ////////// | |
#ifdef USE_SIMPLE_UI | |
diff -ruN -x '*.cpp' -x '*.hex' -x '*.orig-*' -x '*.new-*' -x '*.elf' -x '*.o' 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/version.h 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/version.h | |
--- 721/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/version.h 2023-06-16 05:24:01.001330408 -0400 | |
+++ 721-8C_quick_aux_switch/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/version.h 2023-06-15 18:31:05.293227361 -0400 | |
@@ -1,4 +1,4 @@ | |
// this file is replaced automatically by the build script | |
// set your own date here if you're not using the build script | |
// otherwise, default to first human contact with the moon | |
-#define VERSION_NUMBER "1969-07-20" | |
+#define VERSION_NUMBER "2023-06-15" //date of most recent file in this source tree as per `ls -lt` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment