aboutsummaryrefslogtreecommitdiff
path: root/fsm/ramping.c
diff options
context:
space:
mode:
Diffstat (limited to 'fsm/ramping.c')
-rw-r--r--fsm/ramping.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/fsm/ramping.c b/fsm/ramping.c
index adc8acb..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,15 +50,28 @@ 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_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) {
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
// ... 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
}
}
@@ -57,6 +79,11 @@ inline void set_level_aux_rgb_leds(uint8_t level) {
void set_level(uint8_t level) {
+ #ifdef USE_RAMP_LEVEL_HARD_LIMIT
+ if (ramp_level_hard_limit && (level > ramp_level_hard_limit))
+ level = ramp_level_hard_limit;
+ #endif
+
#ifdef USE_JUMP_START
// maybe "jump start" the engine, if it's prone to slow starts
// (pulse the output high for a moment to wake up the power regulator)