aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/anduril/anduril.c16
-rw-r--r--ui/anduril/aux-leds.c13
-rw-r--r--ui/anduril/battcheck-mode.c40
-rw-r--r--ui/anduril/battcheck-mode.h12
-rw-r--r--ui/anduril/config-default.h8
-rw-r--r--ui/anduril/load-save-config-fsm.h6
-rw-r--r--ui/anduril/load-save-config.h28
7 files changed, 84 insertions, 39 deletions
diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c
index 5972eb2..a17ecf2 100644
--- a/ui/anduril/anduril.c
+++ b/ui/anduril/anduril.c
@@ -287,12 +287,16 @@ void loop() {
#ifdef 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);
+ if (state == steady_state) {
+ #ifdef USE_AUX_THRESHOLD_CONFIG
+ // only show voltage if feature is enabled and
+ // we are above the configured minimum ramp level
+ if (actual_level > cfg.button_led_low_ramp_level)
+ rgb_led_voltage_readout(actual_level > cfg.button_led_high_ramp_level);
+ #else
+ rgb_led_voltage_readout(actual_level > USE_AUX_RGB_LEDS_WHILE_ON);
+ #endif
+ }
#endif
if (0) {} // placeholder
diff --git a/ui/anduril/aux-leds.c b/ui/anduril/aux-leds.c
index 7356666..50ce5c5 100644
--- a/ui/anduril/aux-leds.c
+++ b/ui/anduril/aux-leds.c
@@ -125,7 +125,18 @@ void rgb_led_update(uint8_t mode, uint16_t arg) {
&& (ticks_since_on > 0) // don't blink red on 1st frame
) {
// use high mode if regular aux level is high or prev level was high
- pattern = 1 + ((2 == pattern) | (prev_level >= POST_OFF_VOLTAGE_BRIGHTNESS));
+ #ifdef USE_AUX_THRESHOLD_CONFIG
+ // always high if configured for high aux
+ // otherwise 0/1/2 depending on recent main LED brightness
+ // (using >= makes it off by 1, but allows POVD at boot time)
+ if (pattern != 2)
+ pattern = (prev_level >= cfg.button_led_low_ramp_level)
+ << (prev_level > cfg.button_led_high_ramp_level);
+ #else
+ pattern = 1
+ + ((2 == pattern)
+ | (prev_level >= POST_OFF_VOLTAGE_BRIGHTNESS));
+ #endif
// voltage mode
color = RGB_LED_NUM_COLORS - 1;
}
diff --git a/ui/anduril/battcheck-mode.c b/ui/anduril/battcheck-mode.c
index 997c2b0..460c58a 100644
--- a/ui/anduril/battcheck-mode.c
+++ b/ui/anduril/battcheck-mode.c
@@ -51,7 +51,7 @@ uint8_t battcheck_state(Event event, uint16_t arg) {
return EVENT_NOT_HANDLED;
}
-#ifdef USE_VOLTAGE_CORRECTION
+#if defined(USE_VOLTAGE_CORRECTION) || defined(USE_POST_OFF_VOLTAGE) || defined(USE_AUX_THRESHOLD_CONFIG)
// the user can adjust the battery measurements... on a scale of 1 to 13
// 1 = subtract 0.30V
// 2 = subtract 0.25V
@@ -61,23 +61,35 @@ 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 (post_off_voltage_config_step == step) cfg.post_off_voltage = value;
- else
- #endif
- #ifdef USE_VOLTAGE_CORRECTION
- if (value) cfg.voltage_correction = value;
- #endif
+ switch (step) {
+ #if defined(USE_AUX_THRESHOLD_CONFIG)
+ case button_led_low_ramp_level_step:
+ // 0 clicks = 255 = never turn on
+ cfg.button_led_low_ramp_level = value - 1;
+ break;
+ case button_led_high_ramp_level_step:
+ // 0 clicks = 255 = never turn on
+ cfg.button_led_high_ramp_level = value - 1;
+ break;
+ #endif
+
+ #ifdef USE_POST_OFF_VOLTAGE
+ case post_off_voltage_config_step:
+ cfg.post_off_voltage = value;
+ break;
+ #endif
+
+ #ifdef USE_VOLTAGE_CORRECTION
+ default:
+ if (value) cfg.voltage_correction = value;
+ break;
+ #endif
+ }
}
uint8_t voltage_config_state(Event event, uint16_t arg) {
return config_state_base(event, arg,
- (voltage_config_num_steps - 1),
+ 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 4acdb74..2ff7c81 100644
--- a/ui/anduril/battcheck-mode.h
+++ b/ui/anduril/battcheck-mode.h
@@ -5,7 +5,7 @@
uint8_t battcheck_state(Event event, uint16_t arg);
-#ifdef USE_VOLTAGE_CORRECTION
+#if defined(USE_VOLTAGE_CORRECTION) || defined(USE_POST_OFF_VOLTAGE) || defined(USE_AUX_THRESHOLD_CONFIG)
void voltage_config_save(uint8_t step, uint8_t value);
uint8_t voltage_config_state(Event event, uint16_t arg);
#endif
@@ -13,14 +13,14 @@ uint8_t voltage_config_state(Event event, uint16_t arg);
typedef enum {
voltage_cfg_zero = 0,
#ifdef USE_VOLTAGE_CORRECTION
- voltage_correction_config_step,
+ voltage_correction_config_step,
#endif
#ifdef USE_POST_OFF_VOLTAGE
- post_off_voltage_config_step,
+ 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,
+ #if defined(USE_AUX_THRESHOLD_CONFIG)
+ button_led_low_ramp_level_step,
+ button_led_high_ramp_level_step,
#endif
voltage_config_num_steps
} voltage_config_steps_e;
diff --git a/ui/anduril/config-default.h b/ui/anduril/config-default.h
index 1b34e8c..51249f6 100644
--- a/ui/anduril/config-default.h
+++ b/ui/anduril/config-default.h
@@ -199,6 +199,14 @@
#define USE_LOWPASS_WHILE_ASLEEP
#endif
+// if the light has aux LEDs and enough ROM, let the user choose whether
+// the aux LEDs should be on while the main LEDs are on
+#if (ROM_SIZE > 10000)
+// can be enabled even if no aux LEDs exist,
+// will simply do nothing in that case
+#define USE_AUX_THRESHOLD_CONFIG
+#endif
+
// if there's tint ramping, allow user to set it smooth or stepped
#define USE_STEPPED_TINT_RAMPING
#define DEFAULT_TINT_RAMP_STYLE 0 // smooth
diff --git a/ui/anduril/load-save-config-fsm.h b/ui/anduril/load-save-config-fsm.h
index 61947ce..a69d1b1 100644
--- a/ui/anduril/load-save-config-fsm.h
+++ b/ui/anduril/load-save-config-fsm.h
@@ -97,9 +97,9 @@ 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;
+ #ifdef USE_AUX_THRESHOLD_CONFIG
+ uint8_t button_led_low_ramp_level;
+ uint8_t button_led_high_ramp_level;
#endif
///// aux LEDs
diff --git a/ui/anduril/load-save-config.h b/ui/anduril/load-save-config.h
index 6a52171..f5afb29 100644
--- a/ui/anduril/load-save-config.h
+++ b/ui/anduril/load-save-config.h
@@ -169,18 +169,28 @@ 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,
+ #if defined(USE_AUX_THRESHOLD_CONFIG)
+ // 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`).
+ #ifdef USE_AUX_LEDS_WHILE_ON_INITIAL_MINIMUM_LEVEL
+ .button_led_low_ramp_level = USE_AUX_LEDS_WHILE_ON_INITIAL_MINIMUM_LEVEL,
#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,
+ .button_led_low_ramp_level = 0, // default
#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,
+ #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.
+ .button_led_high_ramp_level = USE_AUX_RGB_LEDS_WHILE_ON,
#else
- .use_aux_rgb_leds_while_on_min_level = 15, // default
+ #ifdef USE_AUX_RGB_LEDS
+ //#warning "USE_AUX_RGB_LEDS_WHILE_ON defined but has no value. Setting to default value."
+ .button_led_high_ramp_level = 25 - 1, // default
+ #else
+ .button_led_high_ramp_level = DEFAULT_LEVEL - 1, // default
+ #endif
#endif
#endif
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.