aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-08-25 17:27:43 -0600
committerSelene ToyKeeper2023-08-25 17:27:43 -0600
commit9e5f2dacebf880f61671974ddd8f604cf1782f37 (patch)
tree49e3624babda4a9d646e1dd2026efedab658bab0 /spaghetti-monster
parentmade custom 3H handler system work, added circular HSV ramping, (diff)
downloadanduril-9e5f2dacebf880f61671974ddd8f604cf1782f37.tar.gz
anduril-9e5f2dacebf880f61671974ddd8f604cf1782f37.tar.bz2
anduril-9e5f2dacebf880f61671974ddd8f604cf1782f37.zip
started splitting set_level(0) into its own set_level_zero(), and
made USE_AUX_RGB_LEDS_WHILE_ON work more like the old indicator LEDs, where it gets set automatically with set_level() Using set_level_zero() reduces space used by channel modes, and simplifies code for each mode's set_level_*() functions. I measured about 220 bytes less in the emisar-d4k-3ch build this way, while also reducing the chance of bugs.
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c2
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4k-3ch.h2
-rw-r--r--spaghetti-monster/fsm-ramping.c33
-rw-r--r--spaghetti-monster/fsm-ramping.h1
4 files changed, 33 insertions, 5 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index ab43df6..6399ef6 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -267,7 +267,7 @@ void loop() {
#ifdef USE_AUX_RGB_LEDS_WHILE_ON
// display battery charge on RGB button during use
- if (! setting_rgb_mode_now)
+ if (state == steady_state)
rgb_led_voltage_readout(actual_level > USE_AUX_RGB_LEDS_WHILE_ON);
#endif
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4k-3ch.h b/spaghetti-monster/anduril/cfg-emisar-d4k-3ch.h
index 46d5796..c015295 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4k-3ch.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4k-3ch.h
@@ -13,7 +13,7 @@
// turn on the aux LEDs while main LEDs are on
// (in case there's a RGB button)
-#define USE_AUX_RGB_LEDS_WHILE_ON 20
+#define USE_AUX_RGB_LEDS_WHILE_ON 25
#define USE_INDICATOR_LED_WHILE_RAMPING
// channel modes...
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index a970f0e..89f540b 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -36,6 +36,25 @@ inline void set_level_aux_leds(uint8_t level) {
}
#endif // ifdef HAS_AUX_LEDS
+#ifdef USE_AUX_RGB_LEDS_WHILE_ON
+// TODO: maybe move this stuff into FSM
+#include "anduril/aux-leds.h" // for rgb_led_voltage_readout()
+inline void set_level_aux_rgb_leds(uint8_t level) {
+ if (! go_to_standby) {
+ if (level > 0) {
+ rgb_led_voltage_readout(level > USE_AUX_RGB_LEDS_WHILE_ON);
+ } 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
+ button_led_set((level > 0) + (level > DEFAULT_LEVEL));
+ #endif
+ }
+}
+#endif // ifdef USE_AUX_RGB_LEDS_WHILE_ON
+
void set_level(uint8_t level) {
#ifdef USE_JUMP_START
@@ -58,9 +77,17 @@ void set_level(uint8_t level) {
set_level_aux_leds(level);
#endif
- // call the relevant hardware-specific set_level_*()
- SetLevelFuncPtr set_level_func = channels[channel_mode].set_level;
- set_level_func(level);
+ #ifdef USE_AUX_RGB_LEDS_WHILE_ON
+ set_level_aux_rgb_leds(level);
+ #endif
+
+ if (0 == level) {
+ set_level_zero();
+ } else {
+ // call the relevant hardware-specific set_level_*()
+ SetLevelFuncPtr set_level_func = channels[channel_mode].set_level;
+ set_level_func(level - 1);
+ }
if (actual_level != level) prev_level = actual_level;
actual_level = level;
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index cae9a4d..bfcc5fb 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -13,6 +13,7 @@ uint8_t prev_level = 0;
void set_level(uint8_t level);
//void set_level_smooth(uint8_t level);
+void set_level_zero(); // implement this in a hwdef
#ifdef USE_SET_LEVEL_GRADUALLY
// adjust brightness very smoothly
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.