Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement channel_uses_aux() (Fixes issue #29) #33

Open
wants to merge 34 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cbef5e7
Implement channel_uses_aux() (Fixes issue #29)
SiteRelEnby Dec 17, 2023
a6fd5cf
Merge branch 'main' into issue29-channel-uses-aux
SiteRelEnby Jan 22, 2024
d12a278
Prevent selecting aux channels in strobes needing brightness control
SiteRelEnby Jan 23, 2024
8703b53
fix two separate bugs around RGB aux channels
SiteRelEnby Jan 23, 2024
532cf4a
Fix another aux channel bug
SiteRelEnby Jan 23, 2024
4949daf
added initial code for emisar-d3aa torch
ToyKeeper Nov 30, 2023
90cf97f
emisar-d3aa: new model number, since this is a new product line
ToyKeeper Nov 30, 2023
23eab2d
d3aa: made it easy to switch between vddio2 and external voltage divider
ToyKeeper Dec 5, 2023
340ba9f
avr32dd20-devkit: use unimplemented "CH" pin as a boost bypass control
ToyKeeper Jan 30, 2024
20cf1ea
thefreeman-avr32dd20-devkit: enable boost bypass at boot, so AA/NiMH …
ToyKeeper Feb 3, 2024
98e71f0
enabled eeprom read/write stabilization by default on recent MCUs,
ToyKeeper Feb 3, 2024
d3cd2f8
d3aa: fixed voltage measurement
ToyKeeper Mar 4, 2024
8f9dc1d
d3aa fine-tuning:
ToyKeeper Mar 11, 2024
92d9ded
dammit, got alkaline detection half working and then my flashing adap…
ToyKeeper Mar 25, 2024
877b158
d3aa: got weak battery detection actually working,
ToyKeeper Mar 26, 2024
da91bfd
weak battery detection: use different thresholds for AA and Li-Ion
ToyKeeper Mar 26, 2024
293ceed
d3aa weak battery test: blink 3x instead of 2x, and omit number readout
ToyKeeper Mar 29, 2024
d6be44a
fixed inaccurate comment (thanks to xikteny for spotting it)
ToyKeeper Mar 24, 2024
2580629
increased voltage precision from 0.025V to 0.02V
ToyKeeper Mar 27, 2024
b1e6ee3
Bugfix: Prevent switching channel modes when in tactical mode
SiteRelEnby Feb 14, 2024
e6747c3
Bugfix: Tactical mode has a dependency on momentary mode
SiteRelEnby Feb 3, 2024
ef7a45d
fixed Tactical Mode's strobes when Momentary Mode not enabled
ToyKeeper Mar 28, 2024
0fb1078
Allow manually running GitHub actions workflows
SiteRelEnby Mar 1, 2024
57764c1
use smooth steps in lockout mode, if enabled
ToyKeeper Mar 29, 2024
fb71361
d3aa: fixed voltage calculation to use 0.02V units instead of 0.025V
ToyKeeper Mar 29, 2024
5582498
make-release.sh should use version-string.sh instead of duplicating code
ToyKeeper Mar 31, 2024
b4fb058
MODELS: added emisar-d3aa
ToyKeeper Apr 1, 2024
cf80d17
use low aux for chan-aux level 0
aslotnick Feb 5, 2024
202310b
Add Fireflies PL47G2-219 variant.
jim-p Jan 22, 2024
480335c
Forgot to update model count after the last couple additions
ToyKeeper Apr 19, 2024
0538ca1
added change log for 2024-04-20 release
ToyKeeper Apr 20, 2024
394c196
include hardware-specific readme files in the release .zip
ToyKeeper Apr 20, 2024
be0361a
Updating PR branch to rebase on latest changes, and also save a bit of
SiteRelEnby Apr 29, 2024
43e5c57
Merge branch 'main' into issue29-channel-uses-aux
SiteRelEnby Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions fsm/chan-rgbaux.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,55 @@
#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, \
.gradual_tick = gradual_tick_null \
AUX_RGB_HAS_ARGS \
AUX_RGB_USES_AUX \
}, \
{ \
.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
26 changes: 22 additions & 4 deletions fsm/ramping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ 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 {
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 @@ -83,14 +87,28 @@ 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();
#if(defined(USE_CHANNEL_USES_AUX) && defined(USE_AUX_RGB_LEDS))
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;
//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
26 changes: 20 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,46 @@ 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,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
RGB_AUX_CHANNELS
};
Expand Down
25 changes: 20 additions & 5 deletions hw/hank/emisar-2ch/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,42 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
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 @@ -31,42 +31,50 @@ 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, manual blend (max "100%" power) (8/16/16)
.set_level = set_level_led34a_blend,
.gradual_tick = gradual_tick_led34a_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // 3rd + 4th LEDs, manual blend (max "100%" power) (16/16/8)
.set_level = set_level_led34b_blend,
.gradual_tick = gradual_tick_led34b_blend,
.has_args = 1
.has_args = 1,
.uses_aux = 0
},
{ // 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
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
25 changes: 20 additions & 5 deletions hw/hank/noctigon-m44/hwdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,42 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
#ifdef USE_CHANNEL_USES_AUX
.uses_aux = 0
#endif
},
RGB_AUX_CHANNELS
};
Expand Down
10 changes: 5 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,27 @@ Channel channels[] = {
{ // channel 1 only
.set_level = set_level_ch1,
.gradual_tick = gradual_tick_ch1,
.has_args = 0
.has_args = 0,
},
{ // channel 2 only
.set_level = set_level_ch2,
.gradual_tick = gradual_tick_ch2,
.has_args = 0
.has_args = 0,
},
{ // both channels, tied together (max "200%" power)
.set_level = set_level_both,
.gradual_tick = gradual_tick_both,
.has_args = 0
.has_args = 0,
},
{ // both channels, manual blend (max "100%" power)
.set_level = set_level_blend,
.gradual_tick = gradual_tick_blend,
.has_args = 1
.has_args = 1,
},
{ // both channels, auto blend
.set_level = set_level_auto,
.gradual_tick = gradual_tick_auto,
.has_args = 1
.has_args = 1,
},
AUX_CHANNELS
};
Expand Down
Loading
Loading