Skip to content

Commit

Permalink
Fix another aux channel bug
Browse files Browse the repository at this point in the history
set_level_zero was causing aux-based channels to be set to off at level
0 (i.e. level 1). Also added a clarifying comment.
  • Loading branch information
SiteRelEnby committed Jan 23, 2024
1 parent 8703b53 commit e97e9a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
16 changes: 9 additions & 7 deletions fsm/chan-rgbaux.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@
#pragma once

void set_level_auxred(uint8_t level) {
rgb_led_set(!(!(level)) * 0b000010); // red, high (or off)
// +1 is needed because set_level subfunctions normally go from 0-149 instead of 1-150 but in this case we want 1-150
// TODO: have 0 be low?
rgb_led_set(!(!(level + 1)) * 0b000010); // red, high (or off)
}

void set_level_auxyel(uint8_t level) {
rgb_led_set(!(!(level)) * 0b001010); // red+green, high (or off)
rgb_led_set(!(!(level + 1)) * 0b001010); // red+green, high (or off)
}

void set_level_auxgrn(uint8_t level) {
rgb_led_set(!(!(level)) * 0b001000); // green, high (or off)
rgb_led_set(!(!(level + 1)) * 0b001000); // green, high (or off)
}

void set_level_auxcyn(uint8_t level) {
rgb_led_set(!(!(level)) * 0b101000); // green+blue, high (or off)
rgb_led_set(!(!(level + 1)) * 0b101000); // green+blue, high (or off)
}

void set_level_auxblu(uint8_t level) {
rgb_led_set(!(!(level)) * 0b100000); // blue, high (or off)
rgb_led_set(!(!(level + 1)) * 0b100000); // blue, high (or off)
}

void set_level_auxprp(uint8_t level) {
rgb_led_set(!(!(level)) * 0b100010); // red+blue, high (or off)
rgb_led_set(!(!(level + 1)) * 0b100010); // red+blue, high (or off)
}

void set_level_auxwht(uint8_t level) {
rgb_led_set(!(!(level)) * 0b101010); // red+green+blue, high (or off)
rgb_led_set(!(!(level + 1)) * 0b101010); // red+green+blue, high (or off)
}

bool gradual_tick_null(uint8_t gt) { return true; } // do nothing
Expand Down
9 changes: 3 additions & 6 deletions fsm/ramping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ 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 (
if ((! go_to_standby)
#ifdef USE_CHANNEL_USES_AUX
// && (!channel_uses_aux(channel_mode))
(!channel_uses_aux(channel_mode))
#else
(! go_to_standby)
&& (!channel_uses_aux(channel_mode))
#endif
){
if (level > 0) {
Expand Down Expand Up @@ -107,6 +103,7 @@ void set_level(uint8_t level) {
} else {
// call the relevant hardware-specific set_level_*()
SetLevelFuncPtr set_level_func = channels[channel_mode].set_level;
//when using set_level_func(), ramp levels start at 0 and go up to 149 instead of 1-150:
set_level_func(level - 1);
}

Expand Down

0 comments on commit e97e9a0

Please sign in to comment.