aboutsummaryrefslogtreecommitdiff
path: root/fsm
diff options
context:
space:
mode:
Diffstat (limited to 'fsm')
-rw-r--r--fsm/misc.c58
-rw-r--r--fsm/misc.h3
-rw-r--r--fsm/ramping.c30
3 files changed, 86 insertions, 5 deletions
diff --git a/fsm/misc.c b/fsm/misc.c
index fa8ddd7..915dbd4 100644
--- a/fsm/misc.c
+++ b/fsm/misc.c
@@ -65,6 +65,16 @@ uint8_t blink_digit(uint8_t num) {
return nice_delay_ms(BLINK_SPEED * 8 / 12);
}
+#ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN
+void blink_negative() {
+ // "negative" symbol gets a single long blink
+ uint8_t ontime = BLINK_SPEED * 2 / 12;
+ set_level(BLINK_BRIGHTNESS);
+ nice_delay_ms(ontime * 3);
+ set_level(0);
+ nice_delay_ms(ontime * 5);
+}
+#endif
#endif
#ifdef USE_BLINK_BIG_NUM
@@ -245,6 +255,50 @@ void rgb_led_set(uint8_t value) {
// FIXME: move this logic to arch/*
#if (MCU==0x1616) || (MCU==0x32dd20) // ATTINY816, 817, etc
+ // FIXME: this *really* needs to be moved to somewhere hardware-specific
+ #ifdef AUXLED_RGB_DIFFERENT_PORTS
+
+ case 0: // LED off
+ if (i == 0) {
+ AUXLED_R_PORT.DIRSET = (1 << pin);
+ AUXLED_R_PORT.OUTCLR = (1 << pin);
+ } else if (i == 1) {
+ AUXLED_G_PORT.DIRSET = (1 << pin);
+ AUXLED_G_PORT.OUTCLR = (1 << pin);
+ } else if (i == 2) {
+ AUXLED_B_PORT.DIRSET = (1 << pin);
+ AUXLED_B_PORT.OUTCLR = (1 << pin);
+ }
+ break;
+
+ case 1: // LED low
+ if (i == 0) {
+ AUXLED_R_PORT.DIRCLR = (1 << pin);
+ *((uint8_t *)&AUXLED_R_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;
+ } else if (i == 1) {
+ AUXLED_G_PORT.DIRCLR = (1 << pin);
+ *((uint8_t *)&AUXLED_G_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;
+ } else if (i == 2) {
+ AUXLED_B_PORT.DIRCLR = (1 << pin);
+ *((uint8_t *)&AUXLED_B_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;
+ }
+ break;
+
+ default: // LED high
+ if (i==0) {
+ AUXLED_R_PORT.DIRSET = (1 << pin);
+ AUXLED_R_PORT.OUTSET = (1 << pin);
+ } else if (i==1) {
+ AUXLED_G_PORT.DIRSET = (1 << pin);
+ AUXLED_G_PORT.OUTSET = (1 << pin);
+ } else if (i==2) {
+ AUXLED_B_PORT.DIRSET = (1 << pin);
+ AUXLED_B_PORT.OUTSET = (1 << pin);
+ }
+ break;
+
+ #else // not ifdef AUXLED_RGB_DIFFERENT_PORTS
+
case 0: // LED off
AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output
AUXLED_RGB_PORT.OUTCLR = (1 << pin); // set output low
@@ -258,8 +312,10 @@ void rgb_led_set(uint8_t value) {
AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output
AUXLED_RGB_PORT.OUTSET = (1 << pin); // set as high
break;
+
+ #endif
- #else
+ #else // not #if (MCU==0x1616) || (MCU==0x32dd20)
case 0: // LED off
AUXLED_RGB_DDR &= 0xff ^ (1 << pin);
diff --git a/fsm/misc.h b/fsm/misc.h
index ba1f8d9..0b13496 100644
--- a/fsm/misc.h
+++ b/fsm/misc.h
@@ -28,6 +28,9 @@ void auto_clock_speed();
#ifdef USE_BLINK_NUM
//#define USE_BLINK
uint8_t blink_num(uint8_t num);
+#ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN
+void blink_negative();
+#endif
#endif
/*
diff --git a/fsm/ramping.c b/fsm/ramping.c
index 743e619..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
}
}