Skip to content

Commit

Permalink
Implement channel_uses_aux() (Fixes issue ToyKeeper#29)
Browse files Browse the repository at this point in the history
Define when a channel needs to use aux LEDs as part of its operation,
allowing that channel to block RGB voltage when on if configured.
  • Loading branch information
SiteRelEnby authored and Isilmerie committed Oct 14, 2024
1 parent c547e62 commit be91a28
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 43 deletions.
7 changes: 7 additions & 0 deletions fsm/chan-aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
#define AUX_HAS_ARGS
#endif

#ifdef USE_CHANNEL_USES_AUX
#define AUX_USES_AUX , .uses_aux = 0
#else
#define AUX_USES_AUX
#endif

#define AUX_CHANNELS \
{ \
.set_level = set_level_aux, \
.gradual_tick = gradual_tick_null \
AUX_HAS_ARGS \
AUX_USES_AUX \
}

void set_level_aux(uint8_t level);
Expand Down
12 changes: 12 additions & 0 deletions fsm/chan-rgbaux.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@
#else
#define AUX_RGB_HAS_ARGS
#endif
#ifdef USE_CHANNEL_USES_AUX
//USE_CHANNEL_USES_AUX
#define AUX_RGB_USES_AUX , .uses_aux = 1
#else
#define AUX_RGB_USES_AUX
#endif

#define RGB_AUX_CHANNELS \
{ \
.set_level = set_level_auxred, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxyel, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxgrn, \
Expand All @@ -43,21 +51,25 @@
.set_level = set_level_auxcyn, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxblu, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxprp, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.set_level = set_level_auxwht, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}

void set_level_auxred(uint8_t level);
Expand Down
6 changes: 6 additions & 0 deletions fsm/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ typedef struct Channel {
bool has_args;
//uint8_t arg; // is in the config struct, not here
#endif
#ifdef USE_CHANNEL_USES_AUX
bool uses_aux;
#endif
} Channel;

Channel channels[]; // values are defined in the hwdef-*.c
Expand Down Expand Up @@ -80,6 +83,9 @@ StatePtr channel_3H_modes[NUM_CHANNEL_MODES];
// struct member
#define channel_has_args(n) (channels[n].has_args)
#endif
#ifdef USE_CHANNEL_USES_AUX
#define channel_uses_aux(n) (channels[n].uses_aux)
#endif

#if NUM_CHANNEL_MODES > 1
void set_channel_mode(uint8_t mode);
Expand Down
6 changes: 5 additions & 1 deletion fsm/ramping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ 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)
#ifdef USE_CHANNEL_USES_AUX
&& (!channel_uses_aux(channel_mode))
#endif
){
if (level > 0) {
rgb_led_voltage_readout(level > USE_AUX_RGB_LEDS_WHILE_ON);
} else {
Expand Down
16 changes: 10 additions & 6 deletions hw/hank/emisar-2ch/fet/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,36 @@ bool gradual_tick_both(uint8_t gt);
bool gradual_tick_blend(uint8_t gt);
bool gradual_tick_auto(uint8_t gt);


Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
RGB_AUX_CHANNELS
};
Expand Down
15 changes: 10 additions & 5 deletions hw/hank/emisar-2ch/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
RGB_AUX_CHANNELS
};
Expand Down
24 changes: 16 additions & 8 deletions hw/hank/emisar-d4k-3ch/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,38 @@ Channel channels[] = {
{ // main 2 LEDs only
.set_level = set_level_main2,
.gradual_tick = gradual_tick_main2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // 3rd LED only
.set_level = set_level_led3,
.gradual_tick = gradual_tick_led3,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // 4th LED only
.set_level = set_level_led4,
.gradual_tick = gradual_tick_led4,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // all channels, tied together (equal amounts, max power)
.set_level = set_level_all,
.gradual_tick = gradual_tick_all,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // 3rd + 4th LEDs (8/16/16) or 3rd + main LEDs (16/16/8), manual blend (max "100%" power)
.set_level = set_level_led34a_blend,
.gradual_tick = gradual_tick_led34a_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // main + 3rd LEDs (8/16/16) or 4th + 3rd LEDs (16/16/8), manual blend (max "100%" power)
.set_level = set_level_led34b_blend,
.gradual_tick = gradual_tick_led34b_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // main + 4th LEDs (8/16/16) or 4th + main LEDs (16/16/8), manual blend (max "100%" power)
.set_level = set_level_led14_blend,
Expand All @@ -69,12 +75,14 @@ Channel channels[] = {
{ // 3ch blend (HSV style)
.set_level = set_level_hsv,
.gradual_tick = gradual_tick_hsv,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // 3ch auto blend (red-warm-cool style, led4-led3-main2)
.set_level = set_level_auto3,
.gradual_tick = gradual_tick_auto3,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
RGB_AUX_CHANNELS
};
Expand Down
2 changes: 2 additions & 0 deletions hw/hank/noctigon-kr4/nofet/anduril.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define HWDEF_C hank/noctigon-kr4/nofet/hwdef.c
#include "hank/noctigon-kr4/anduril.h"

#define USE_AUX_RGB_LEDS_WHILE_ON 1

// brightness w/ SST-20 4000K LEDs:
// 0/1023: 0.35 lm
// 1/1023: 2.56 lm
Expand Down
4 changes: 2 additions & 2 deletions hw/hank/noctigon-kr4/nofet/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ void set_level_zero();
void set_level_main(uint8_t level);
bool gradual_tick_main(uint8_t gt);


Channel channels[] = {
{ // channel 1 only
.set_level = set_level_main,
.gradual_tick = gradual_tick_main
.gradual_tick = gradual_tick_main,
.uses_aux = 0
},
RGB_AUX_CHANNELS
};
Expand Down
15 changes: 10 additions & 5 deletions hw/hank/noctigon-m44/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
RGB_AUX_CHANNELS
};
Expand Down
15 changes: 10 additions & 5 deletions hw/sofirn/blf-lt1-t1616/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
AUX_CHANNELS
};
Expand Down
15 changes: 10 additions & 5 deletions hw/sofirn/blf-lt1/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
//.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // channel 2 only
.set_level = set_level_ch2,
//.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
//.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
.uses_aux = 0
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
//.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // both channels, auto blend
.set_level = set_level_blend,
//.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
};

Expand Down
Loading

0 comments on commit be91a28

Please sign in to comment.