diff options
| author | SiteRelEnby | 2023-11-06 14:50:06 -0600 |
|---|---|---|
| committer | SiteRelEnby | 2024-04-02 21:34:36 -0500 |
| commit | d7c7ff8e921456b1f1a27ad16f6d3466157c91c4 (patch) | |
| tree | 65c1bf7a48f4f29eb99af94ce687c03ff90cb2c5 /ui | |
| parent | use smooth steps in lockout mode, if enabled (diff) | |
| download | anduril-d7c7ff8e921456b1f1a27ad16f6d3466157c91c4.tar.gz anduril-d7c7ff8e921456b1f1a27ad16f6d3466157c91c4.tar.bz2 anduril-d7c7ff8e921456b1f1a27ad16f6d3466157c91c4.zip | |
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.
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/anduril/anduril.c | 10 | ||||
| -rw-r--r-- | ui/anduril/battcheck-mode.c | 20 | ||||
| -rw-r--r-- | ui/anduril/battcheck-mode.h | 15 | ||||
| -rw-r--r-- | ui/anduril/load-save-config-fsm.h | 4 | ||||
| -rw-r--r-- | ui/anduril/load-save-config.h | 15 |
5 files changed, 52 insertions, 12 deletions
diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c index 4378816..fdc9527 100644 --- a/ui/anduril/anduril.c +++ b/ui/anduril/anduril.c @@ -278,9 +278,13 @@ void loop() { StatePtr state = current_state; #ifdef USE_AUX_RGB_LEDS_WHILE_ON - // display battery charge on RGB button during use - if (state == steady_state) - rgb_led_voltage_readout(actual_level > USE_AUX_RGB_LEDS_WHILE_ON); + // display battery charge on RGB button during use + #ifdef USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS + if ((state == steady_state) && (actual_level > cfg.use_aux_rgb_leds_while_on_min_level)) // only show voltage if we are above the configured minimum ramp level + #else + if (state == steady_state) + #endif + rgb_led_voltage_readout(actual_level > USE_AUX_RGB_LEDS_WHILE_ON); #endif if (0) {} // placeholder diff --git a/ui/anduril/battcheck-mode.c b/ui/anduril/battcheck-mode.c index c7c80dd..997c2b0 100644 --- a/ui/anduril/battcheck-mode.c +++ b/ui/anduril/battcheck-mode.c @@ -61,21 +61,23 @@ uint8_t battcheck_state(Event event, uint16_t arg) { // ... // 13 = add 0.30V void voltage_config_save(uint8_t step, uint8_t value) { + #if defined(USE_AUX_RGB_LEDS_WHILE_ON) && defined(USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS) + if (use_aux_rgb_leds_while_on_config_step == step) cfg.use_aux_rgb_leds_while_on = value; + else if (use_aux_rgb_leds_while_on_min_level_step == step) cfg.use_aux_rgb_leds_while_on_min_level = value; + else + #endif #ifdef USE_POST_OFF_VOLTAGE - if (2 == step) cfg.post_off_voltage = value; - else + if (post_off_voltage_config_step == step) cfg.post_off_voltage = value; + else + #endif + #ifdef USE_VOLTAGE_CORRECTION + if (value) cfg.voltage_correction = value; #endif - if (value) cfg.voltage_correction = value; } uint8_t voltage_config_state(Event event, uint16_t arg) { - #ifdef USE_POST_OFF_VOLTAGE - #define VOLTAGE_CONFIG_STEPS 2 - #else - #define VOLTAGE_CONFIG_STEPS 1 - #endif return config_state_base(event, arg, - VOLTAGE_CONFIG_STEPS, + (voltage_config_num_steps - 1), voltage_config_save); } #endif // #ifdef USE_VOLTAGE_CORRECTION diff --git a/ui/anduril/battcheck-mode.h b/ui/anduril/battcheck-mode.h index b505b68..4acdb74 100644 --- a/ui/anduril/battcheck-mode.h +++ b/ui/anduril/battcheck-mode.h @@ -10,3 +10,18 @@ void voltage_config_save(uint8_t step, uint8_t value); uint8_t voltage_config_state(Event event, uint16_t arg); #endif +typedef enum { + voltage_cfg_zero = 0, + #ifdef USE_VOLTAGE_CORRECTION + voltage_correction_config_step, + #endif + #ifdef USE_POST_OFF_VOLTAGE + post_off_voltage_config_step, + #endif + #if defined(USE_AUX_RGB_LEDS_WHILE_ON) && defined(USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS) + use_aux_rgb_leds_while_on_config_step, + use_aux_rgb_leds_while_on_min_level_step, + #endif + voltage_config_num_steps +} voltage_config_steps_e; + diff --git a/ui/anduril/load-save-config-fsm.h b/ui/anduril/load-save-config-fsm.h index d189d3a..61947ce 100644 --- a/ui/anduril/load-save-config-fsm.h +++ b/ui/anduril/load-save-config-fsm.h @@ -97,6 +97,10 @@ typedef struct Config { uint8_t therm_ceil; int8_t therm_cal_offset; #endif + #if defined(USE_AUX_RGB_LEDS_WHILE_ON) && defined(USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS) + uint8_t use_aux_rgb_leds_while_on; + uint8_t use_aux_rgb_leds_while_on_min_level; + #endif ///// aux LEDs #ifdef USE_INDICATOR_LED diff --git a/ui/anduril/load-save-config.h b/ui/anduril/load-save-config.h index 3ad477c..6a52171 100644 --- a/ui/anduril/load-save-config.h +++ b/ui/anduril/load-save-config.h @@ -169,5 +169,20 @@ Config cfg = { .jump_start_level = DEFAULT_JUMP_START_LEVEL, #endif + #if defined(USE_AUX_RGB_LEDS_WHILE_ON) && defined(USE_CONFIGURABLE_RGB_VOLTAGE_LEVELS) + // config for RGB voltage. We need to check these here rather than setting defaults in `config-default.h` as we only know *after* defaults are loaded if `USE_AUX_RGB_LEDS_WHILE_ON` is set or unset (in `CFG_H`). + #if (USE_AUX_RGB_LEDS_WHILE_ON + 0) // if USE_AUX_RGB_LEDS_WHILE_ON is an int, passes. If blank (undefined or defined with no value), evaluates to `(+0)` which evaluates to false. + .use_aux_rgb_leds_while_on = USE_AUX_RGB_LEDS_WHILE_ON, + #else + #warning "USE_AUX_RGB_LEDS_WHILE_ON defined but has no value. Setting minimum threshold to default of 25" + .use_aux_rgb_leds_while_on = 25, + #endif + #ifdef USE_AUX_RGB_LEDS_WHILE_ON_INITIAL_MINIMUM_LEVEL + .use_aux_rgb_leds_while_on_min_level = USE_AUX_RGB_LEDS_WHILE_ON_INITIAL_MINIMUM_LEVEL, + #else + .use_aux_rgb_leds_while_on_min_level = 15, // default + #endif + #endif + }; |
