From d7c7ff8e921456b1f1a27ad16f6d3466157c91c4 Mon Sep 17 00:00:00 2001 From: SiteRelEnby Date: Mon, 6 Nov 2023 14:50:06 -0600 Subject: Add a feature to make RGB voltage configurable Adds two entries to the battery voltage settings menu, the first isathreshold for switching aux to high, and the second sets a minimum level for it to be displayed, also effectively allowing the feature to be entirely disabled if not wanted. --- fsm/ramping.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'fsm') diff --git a/fsm/ramping.c b/fsm/ramping.c index adc8acb..b3b3b23 100644 --- a/fsm/ramping.c +++ b/fsm/ramping.c @@ -41,9 +41,16 @@ inline void set_level_aux_leds(uint8_t level) { #include "anduril/aux-leds.h" // for rgb_led_voltage_readout() inline void set_level_aux_rgb_leds(uint8_t level) { if (! go_to_standby) { + #ifdef USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS + if ((level > 0) && (actual_level > cfg.use_aux_rgb_leds_while_on_min_level)){ + rgb_led_voltage_readout(level > cfg.use_aux_rgb_leds_while_on); + } + #else if (level > 0) { rgb_led_voltage_readout(level > USE_AUX_RGB_LEDS_WHILE_ON); - } else { + } + #endif + else { rgb_led_set(0); } // some drivers can be wired with RGB or single color to button -- cgit v1.2.3 From 2b19de99a2c4acd8041a50593ff3a7586fe06a27 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 4 Jul 2025 04:57:34 -0600 Subject: made new settings apply to all button LEDs on lights bigger than 8K ROM This replaces "USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS" with "USE_AUX_THRESHOLD_CONFIG", which controls the brightness of button LEDs while the main LEDs are on, and during post-off voltage display. Same basic concept, but works on single-color LEDs too, and lets the user finally configure POVD thresholds. The code for this is a bit messy, but the aux LED code as a whole is pretty messy since it wasn't designed for the things it does now. The entire thing needs a refactor or rewrite someday. But not today. For now, this is just enough to make the pull request cover more use cases before merging into trunk. I've tested it on a variety of lights, but am not yet entirely comfortable with it. However, it worked on at least these: - 1-color button LED, no RGB - front RGB, 1-color button LED - front RGB, hardwired also to RGB button - RGB button, no other aux These may need extra changes, and may have extra config options which do nothing... - front RGB, no button LED - 1-color front aux, no button LED - no aux at all - attiny85 lights (some could theoretically support the new options, but none even try) --- fsm/ramping.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'fsm') diff --git a/fsm/ramping.c b/fsm/ramping.c index e0c391a..f8ca4ec 100644 --- a/fsm/ramping.c +++ b/fsm/ramping.c @@ -8,14 +8,20 @@ #ifdef HAS_AUX_LEDS inline void set_level_aux_leds(uint8_t level) { + #ifdef USE_AUX_THRESHOLD_CONFIG + #define AUX_BRIGHTNESS ((level > cfg.button_led_low_ramp_level) \ + << (level > cfg.button_led_high_ramp_level)) + #else + #define AUX_BRIGHTNESS ((level > 0) + (level > DEFAULT_LEVEL)) + #endif #ifdef USE_INDICATOR_LED_WHILE_RAMPING // use side-facing aux LEDs while main LEDs are on if (! go_to_standby) { #ifdef USE_INDICATOR_LED - indicator_led((level > 0) + (level > DEFAULT_LEVEL)); + indicator_led(AUX_BRIGHTNESS); #endif #ifdef USE_BUTTON_LED - button_led_set((level > 0) + (level > DEFAULT_LEVEL)); + button_led_set(AUX_BRIGHTNESS); #endif } #else // turn off front-facing aux LEDs while main LEDs are on @@ -27,12 +33,15 @@ inline void set_level_aux_leds(uint8_t level) { #ifdef USE_AUX_RGB_LEDS rgb_led_set(0); #ifdef USE_BUTTON_LED - button_led_set((level > 0) + (level > DEFAULT_LEVEL)); + button_led_set(AUX_BRIGHTNESS); #endif #endif } #endif #endif + #ifdef AUX_BRIGHTNESS + #undef AUX_BRIGHTNESS + #endif } #endif // ifdef HAS_AUX_LEDS @@ -41,9 +50,9 @@ inline void set_level_aux_leds(uint8_t level) { #include "anduril/aux-leds.h" // for rgb_led_voltage_readout() inline void set_level_aux_rgb_leds(uint8_t level) { if (! go_to_standby) { - #ifdef USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS - if ((level > 0) && (actual_level > cfg.use_aux_rgb_leds_while_on_min_level)){ - rgb_led_voltage_readout(level > cfg.use_aux_rgb_leds_while_on); + #ifdef USE_AUX_THRESHOLD_CONFIG + if (level > cfg.button_led_low_ramp_level) { + rgb_led_voltage_readout(level > cfg.button_led_high_ramp_level); } #else if (level > 0) { @@ -56,7 +65,13 @@ inline void set_level_aux_rgb_leds(uint8_t level) { // some drivers can be wired with RGB or single color to button // ... so support both even though only one is connected #ifdef USE_BUTTON_LED + #ifdef USE_AUX_THRESHOLD_CONFIG + button_led_set( + (level > cfg.button_led_low_ramp_level) + << (level > cfg.button_led_high_ramp_level)); + #else button_led_set((level > 0) + (level > DEFAULT_LEVEL)); + #endif #endif } } -- cgit v1.2.3