From c132c50a98c984fb6daee0a96370f466b1ee8b6a Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 2 May 2023 08:39:28 -0600 Subject: made "post-off voltage display" user-configurable in battcheck 7H menu item 2 (1 click per second the display should last) --- spaghetti-monster/anduril/aux-leds.c | 4 +++- spaghetti-monster/anduril/battcheck-mode-fsm.h | 7 +++++++ spaghetti-monster/anduril/battcheck-mode.c | 13 ++++++++++++- spaghetti-monster/anduril/load-save-config-fsm.h | 3 +++ spaghetti-monster/anduril/load-save-config.h | 4 ++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c index 237390c..d833d82 100644 --- a/spaghetti-monster/anduril/aux-leds.c +++ b/spaghetti-monster/anduril/aux-leds.c @@ -104,11 +104,13 @@ void rgb_led_update(uint8_t mode, uint16_t arg) { // always preview in high mode if (! go_to_standby) { pattern = 2; } + #ifdef USE_POST_OFF_VOLTAGE // use voltage high mode for a few seconds after initial poweroff - else if (arg < (SLEEP_TICKS_PER_SECOND*3)) { + else if (arg < (cfg.post_off_voltage * SLEEP_TICKS_PER_SECOND)) { pattern = 2; color = RGB_LED_NUM_COLORS - 1; } + #endif const uint8_t *colors = rgb_led_colors; uint8_t actual_color = 0; diff --git a/spaghetti-monster/anduril/battcheck-mode-fsm.h b/spaghetti-monster/anduril/battcheck-mode-fsm.h index 4ab8f06..580080c 100644 --- a/spaghetti-monster/anduril/battcheck-mode-fsm.h +++ b/spaghetti-monster/anduril/battcheck-mode-fsm.h @@ -5,3 +5,10 @@ #define USE_BATTCHECK +#ifdef USE_AUX_RGB_LEDS + // show voltage colors for a few seconds after going to standby + #define USE_POST_OFF_VOLTAGE + #ifndef DEFAULT_POST_OFF_VOLTAGE_SECONDS + #define DEFAULT_POST_OFF_VOLTAGE_SECONDS 5 + #endif +#endif diff --git a/spaghetti-monster/anduril/battcheck-mode.c b/spaghetti-monster/anduril/battcheck-mode.c index 7e25f79..0ef6b0a 100644 --- a/spaghetti-monster/anduril/battcheck-mode.c +++ b/spaghetti-monster/anduril/battcheck-mode.c @@ -61,11 +61,22 @@ uint8_t battcheck_state(Event event, uint16_t arg) { // ... // 13 = add 0.30V void voltage_config_save(uint8_t step, uint8_t value) { + #ifdef USE_POST_OFF_VOLTAGE + if (2 == step) cfg.post_off_voltage = value; + else + #endif if (value) cfg.voltage_correction = value; } uint8_t voltage_config_state(Event event, uint16_t arg) { - return config_state_base(event, arg, 1, voltage_config_save); + #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_save); } #endif // #ifdef USE_VOLTAGE_CORRECTION diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index df46fc5..862cf26 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -97,6 +97,9 @@ typedef struct Config { #ifdef USE_AUX_RGB_LEDS uint8_t rgb_led_off_mode; uint8_t rgb_led_lockout_mode; + #ifdef USE_POST_OFF_VOLTAGE + uint8_t post_off_voltage; + #endif #endif ///// misc other mode settings diff --git a/spaghetti-monster/anduril/load-save-config.h b/spaghetti-monster/anduril/load-save-config.h index 278d286..8ae9d96 100644 --- a/spaghetti-monster/anduril/load-save-config.h +++ b/spaghetti-monster/anduril/load-save-config.h @@ -135,6 +135,10 @@ Config cfg = { #ifdef USE_AUX_RGB_LEDS .rgb_led_off_mode = RGB_LED_OFF_DEFAULT, .rgb_led_lockout_mode = RGB_LED_LOCKOUT_DEFAULT, + #ifdef USE_POST_OFF_VOLTAGE + // display voltage readout for a while after turning off? + .post_off_voltage = DEFAULT_POST_OFF_VOLTAGE_SECONDS, + #endif #endif ///// misc other mode settings -- cgit v1.2.3