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 Isilmerie committed Oct 14, 2024
1 parent 6e00233 commit aff9cfc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 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
27 changes: 22 additions & 5 deletions fsm/ramping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ 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 ((! go_to_standby)
if (
#ifdef USE_CHANNEL_USES_AUX
&& (!channel_uses_aux(channel_mode))
// && (!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);
}
}// 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
Expand Down Expand Up @@ -136,6 +140,14 @@ 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

Expand All @@ -148,6 +160,11 @@ void set_level(uint8_t level) {

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 aff9cfc

Please sign in to comment.