Created
October 3, 2023 20:19
-
-
Save DurvalMenezes/1d43869541274ddbb6082155d8886776 to your computer and use it in GitHub Desktop.
anduril_-_multi-channel: 767-8C_quick_aux_switch + undef_USE_MANUAL_MEMORY_fix + undef_USE_SIMPLE_UI_fix
This file contains 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
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h.orig 2023-08-26 21:42:04.000000000 -0400 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/config-default.h 2023-10-02 16:04:54.415794640 -0300 | |
@@ -195,3 +195,6 @@ | |
// 0 = none, 1 = smooth, 2+ = undefined | |
#define DEFAULT_SMOOTH_STEPS_STYLE 1 | |
+// enable quick switch to/from current aux mode to off | |
+#define USE_QUICK_AUX_SWITCH | |
+ | |
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h.orig 2023-08-26 21:42:04.000000000 -0400 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 2023-10-02 16:04:54.427794999 -0300 | |
@@ -123,11 +123,27 @@ | |
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) | |
+#ifdef EEPROM_SIZE // avr-gcc doesn't define EEPROM_SIZE for some MCUs (eg 1634) so we can only check this when it's defined | |
+ // 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 | |
+ } | |
+#endif | |
+ | |
// declare this so FSM can see it, | |
// but define its values in a file which loads later | |
Config cfg; | |
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c.orig 2023-08-26 21:42:04.000000000 -0400 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/off-mode.c 2023-10-02 16:04:54.455795834 -0300 | |
@@ -327,6 +327,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 | |
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h.orig 2023-08-26 21:42:04.000000000 -0400 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/load-save-config.h 2023-10-02 16:04:54.443795475 -0300 | |
@@ -167,5 +167,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 | |
+ | |
}; | |
This file contains 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
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/ramp-mode.c.orig 2023-09-08 21:28:52.000000000 -0300 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/ramp-mode.c 2023-10-02 13:48:22.000000000 -0300 | |
@@ -557,10 +557,14 @@ | |
#ifdef USE_RAMP_EXTRAS_CONFIG | |
void ramp_extras_config_save(uint8_t step, uint8_t value) { | |
+ if (0) { } //syntactic trick so USE_MANUAL_MEMORY can be #undef | |
+ | |
+ #ifdef USE_MANUAL_MEMORY | |
// item 1: disable manual memory, go back to automatic | |
- if (manual_memory_config_step == step) { | |
+ else if (manual_memory_config_step == step) { | |
cfg.manual_memory = 0; | |
} | |
+ #endif | |
#ifdef USE_MANUAL_MEMORY_TIMER | |
// item 2: set manual memory timer duration | |
@@ -691,6 +695,7 @@ | |
#define set_level_and_therm_target(level) set_level(level) | |
#endif | |
+#ifdef USE_MANUAL_MEMORY | |
void manual_memory_restore() { | |
memorized_level = cfg.manual_memory; | |
#if NUM_CHANNEL_MODES > 1 | |
@@ -712,6 +717,7 @@ | |
cfg.manual_memory_channel_args[i] = cfg.channel_mode_args[i]; | |
#endif | |
} | |
+#endif | |
#ifdef USE_SUNSET_TIMER | |
void reset_sunset_timer() { |
This file contains 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
--- 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/channel-modes.c.orig-20231002 2023-08-25 18:21:04.000000000 -0400 | |
+++ 767/~toykeeper/flashlight-firmware/multi-channel/ToyKeeper/spaghetti-monster/anduril/channel-modes.c 2023-10-02 15:36:46.185174209 -0300 | |
@@ -119,7 +119,6 @@ | |
return EVENT_HANDLED; | |
} | |
#endif // ifndef DONT_USE_DEFAULT_CHANNEL_ARG_MODE | |
- #endif // ifdef USE_CHANNEL_MODE_ARGS | |
#if defined(USE_SIMPLE_UI) | |
// remaining mappings aren't "simple", so stop here | |
@@ -135,6 +134,7 @@ | |
return EVENT_HANDLED; | |
} | |
#endif | |
+ #endif // ifdef USE_CHANNEL_MODE_ARGS | |
return EVENT_NOT_HANDLED; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment