Skip to content

Commit

Permalink
fix two separate bugs around RGB aux channels
Browse files Browse the repository at this point in the history
First off, green was not defined properly and was instead defined the
same as a main channel (leading to the behaviour described in the issue
at ToyKeeper#33 (comment)

Second, fix the actual bug causing aux to not work for blinky modes.
Specifically, set_level needs to be patched so that instead of (or as
well as, doesn't really matter) calling set_level_zero(), it will also
check for if the active channel is an RGB channel and if so them clear
RGB state.
  • Loading branch information
SiteRelEnby authored and stcarlso committed Apr 24, 2024
1 parent 95f0f20 commit 3b67ac1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions fsm/chan-rgbaux.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
.set_level = set_level_auxgrn, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxcyn, \
Expand Down
21 changes: 17 additions & 4 deletions fsm/ramping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ inline void set_level_aux_leds(uint8_t level) {
// 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 (
#ifdef USE_CHANNEL_USES_AUX
&& (!channel_uses_aux(channel_mode))
(!channel_uses_aux(channel_mode))
#else
(! go_to_standby)
#endif
){
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
Expand Down Expand Up @@ -87,11 +87,24 @@ void set_level(uint8_t level) {
#endif

#ifdef USE_AUX_RGB_LEDS_WHILE_ON
#ifdef USE_CHANNEL_USES_AUX
if (!channel_uses_aux(channel_mode)) {
set_level_aux_rgb_leds(level);
}
#else
set_level_aux_rgb_leds(level);
#endif

set_level_aux_rgb_leds(level);
#endif

if (0 == level) {
set_level_zero();
#ifdef USE_CHANNEL_USES_AUX
if (channel_uses_aux(channel_mode)){
rgb_led_set(0);
}
#endif
} else {
// call the relevant hardware-specific set_level_*()
SetLevelFuncPtr set_level_func = channels[channel_mode].set_level;
Expand Down

0 comments on commit 3b67ac1

Please sign in to comment.