From a656caf25568e137ec1c4828951132aa88a82254 Mon Sep 17 00:00:00 2001 From: SiteRelEnby <125829806+SiteRelEnby@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:24:05 -0500 Subject: [PATCH] Updating PR branch to rebase on latest changes, and also save a bit of MCU space on a few lights --- hw/hank/emisar-2ch/fet/hwdef.c | 10 ++++++++++ hw/hank/emisar-2ch/hwdef.c | 10 ++++++++++ hw/hank/noctigon-kr4/nofet/anduril.h | 2 -- hw/hank/noctigon-m44/hwdef.c | 10 ++++++++++ hw/sofirn/blf-lt1-t1616/hwdef.c | 5 ----- hw/sofirn/blf-lt1/hwdef.c | 5 ----- hw/sofirn/lt1s-pro/hwdef.c | 5 ----- hw/wurkkos/ts10/hwdef.c | 4 ++++ ui/anduril/config-default.h | 16 +++++++++++++++- ui/anduril/strobe-modes.c | 5 ++++- 10 files changed, 53 insertions(+), 19 deletions(-) diff --git a/hw/hank/emisar-2ch/fet/hwdef.c b/hw/hank/emisar-2ch/fet/hwdef.c index 8b2545e4..7bfba768 100644 --- a/hw/hank/emisar-2ch/fet/hwdef.c +++ b/hw/hank/emisar-2ch/fet/hwdef.c @@ -26,31 +26,41 @@ Channel channels[] = { .set_level = set_level_ch1, .gradual_tick = gradual_tick_ch1, .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, + #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, + #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, + #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, + #ifdef USE_CHANNEL_USES_AUX .uses_aux = 0 + #endif }, RGB_AUX_CHANNELS }; diff --git a/hw/hank/emisar-2ch/hwdef.c b/hw/hank/emisar-2ch/hwdef.c index 3171eac2..514b5585 100644 --- a/hw/hank/emisar-2ch/hwdef.c +++ b/hw/hank/emisar-2ch/hwdef.c @@ -26,31 +26,41 @@ Channel channels[] = { .set_level = set_level_ch1, .gradual_tick = gradual_tick_ch1, .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, + #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, + #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, + #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, + #ifdef USE_CHANNEL_USES_AUX .uses_aux = 0 + #endif }, RGB_AUX_CHANNELS }; diff --git a/hw/hank/noctigon-kr4/nofet/anduril.h b/hw/hank/noctigon-kr4/nofet/anduril.h index d5257a04..ad3f0125 100644 --- a/hw/hank/noctigon-kr4/nofet/anduril.h +++ b/hw/hank/noctigon-kr4/nofet/anduril.h @@ -8,8 +8,6 @@ #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 diff --git a/hw/hank/noctigon-m44/hwdef.c b/hw/hank/noctigon-m44/hwdef.c index 0593aabb..716b0575 100644 --- a/hw/hank/noctigon-m44/hwdef.c +++ b/hw/hank/noctigon-m44/hwdef.c @@ -26,31 +26,41 @@ Channel channels[] = { .set_level = set_level_ch1, .gradual_tick = gradual_tick_ch1, .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, + #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, + #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, + #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, + #ifdef USE_CHANNEL_USES_AUX .uses_aux = 0 + #endif }, RGB_AUX_CHANNELS }; diff --git a/hw/sofirn/blf-lt1-t1616/hwdef.c b/hw/sofirn/blf-lt1-t1616/hwdef.c index d290c6c7..ba6e909a 100644 --- a/hw/sofirn/blf-lt1-t1616/hwdef.c +++ b/hw/sofirn/blf-lt1-t1616/hwdef.c @@ -26,31 +26,26 @@ Channel channels[] = { .set_level = set_level_ch1, .gradual_tick = gradual_tick_ch1, .has_args = 0, - .uses_aux = 0 }, { // channel 2 only .set_level = set_level_ch2, .gradual_tick = gradual_tick_ch2, .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, - .uses_aux = 0 }, { // both channels, manual blend (max "100%" power) .set_level = set_level_blend, .gradual_tick = gradual_tick_blend, .has_args = 1, - .uses_aux = 0 }, { // both channels, auto blend .set_level = set_level_auto, .gradual_tick = gradual_tick_auto, .has_args = 1, - .uses_aux = 0 }, AUX_CHANNELS }; diff --git a/hw/sofirn/blf-lt1/hwdef.c b/hw/sofirn/blf-lt1/hwdef.c index 9aaaad37..eabc7499 100644 --- a/hw/sofirn/blf-lt1/hwdef.c +++ b/hw/sofirn/blf-lt1/hwdef.c @@ -26,31 +26,26 @@ Channel channels[] = { .set_level = set_level_ch1, //.gradual_tick = gradual_tick_ch1, .has_args = 0, - .uses_aux = 0 }, { // channel 2 only .set_level = set_level_ch2, //.gradual_tick = gradual_tick_ch2, .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, - .uses_aux = 0 }, { // both channels, manual blend (max "100%" power) .set_level = set_level_blend, //.gradual_tick = gradual_tick_blend, .has_args = 1, - .uses_aux = 0 }, { // both channels, auto blend .set_level = set_level_blend, //.gradual_tick = gradual_tick_blend, .has_args = 1, - .uses_aux = 0 }, }; diff --git a/hw/sofirn/lt1s-pro/hwdef.c b/hw/sofirn/lt1s-pro/hwdef.c index ac797589..f8cf77a6 100644 --- a/hw/sofirn/lt1s-pro/hwdef.c +++ b/hw/sofirn/lt1s-pro/hwdef.c @@ -24,31 +24,26 @@ Channel channels[] = { .set_level = set_level_white_blend, .gradual_tick = gradual_tick_white_blend, .has_args = 1, - .uses_aux = 0 }, { // auto blend from warm white to cool white .set_level = set_level_auto_2ch_blend, .gradual_tick = gradual_tick_auto_2ch_blend, .has_args = 0, - .uses_aux = 0 }, { // auto blend from red to warm white to cool white .set_level = set_level_auto_3ch_blend, .gradual_tick = gradual_tick_auto_3ch_blend, .has_args = 0, - .uses_aux = 0 }, { // red only .set_level = set_level_red, .gradual_tick = gradual_tick_red, .has_args = 0, - .uses_aux = 0 }, { // manual white blend + adjustable red .set_level = set_level_red_white_blend, .gradual_tick = gradual_tick_red_white_blend, .has_args = 1, - .uses_aux = 0 } }; diff --git a/hw/wurkkos/ts10/hwdef.c b/hw/wurkkos/ts10/hwdef.c index 84dfbf3d..8e9ad6e3 100644 --- a/hw/wurkkos/ts10/hwdef.c +++ b/hw/wurkkos/ts10/hwdef.c @@ -16,12 +16,16 @@ Channel channels[] = { { // main LEDs .set_level = set_level_main, .gradual_tick = gradual_tick_main, + #ifdef USE_CHANNEL_USES_AUX .uses_aux = 0 + #endif }, { // aux LEDs .set_level = set_level_aux, .gradual_tick = gradual_tick_null, + #ifdef USE_CHANNEL_USES_AUX .uses_aux = 1 + #endif } }; diff --git a/ui/anduril/config-default.h b/ui/anduril/config-default.h index a68a8516..00e7fcaf 100644 --- a/ui/anduril/config-default.h +++ b/ui/anduril/config-default.h @@ -220,8 +220,22 @@ // (but allow disabling this feature per build) #define USE_CHANNEL_PER_STROBE -// enable channel mode config prerequisites for channel_uses_aux() +// Use channel_uses_aux() where needed and practical to. +// See issue: https://github.com/ToyKeeper/anduril/issues/29 +// We want to avoid including this functionality for code size reasons on t85. +// By default there are no t85 builds with RGB aux (it is unlikely to be *able* +// to fit on a t85) - this does leave one known issue, that strobe modes on t85 +// lights will be able to be configured to use aux channels, including strobes +// that wouldn't work with aux (e.g. bike flasher or candle mode), but we need +// this for any t1634 or newer light with RGB aux to fix some more significant +// edge cases around RGB, but this also applies to *any* light with aux-based +// channels for the aforementioned issue. This has to be included here because +// we need this to be defined *before* the light-specific anduril.h and hwdefs +// are loaded, as ramp tables could be shared between two lghts with different +// aux configurations. +#if (MCU==0x1634) || (MCU==0x1616) || (MCU==0x32dd20) #define USE_CHANNEL_USES_AUX +#endif // We want this bugfix on everything except the original t85 LT1 (because it doesn't fit) #define USE_TINT_RAMP_DIRECTION_FIX diff --git a/ui/anduril/strobe-modes.c b/ui/anduril/strobe-modes.c index ab7e640e..82b7f5e3 100644 --- a/ui/anduril/strobe-modes.c +++ b/ui/anduril/strobe-modes.c @@ -71,7 +71,10 @@ uint8_t strobe_state(Event event, uint16_t arg) { do { count ++; //e.g. 1 next_ch = ((next_ch + 1) % NUM_CHANNEL_MODES); - if (!channel_uses_aux(next_ch)) break; + #ifdef USE_CHANNEL_USES_AUX // this bugfix is not available without this feature (probably only on t85 without RGB, where it matters less) + //TODO: do something else here to get the same effect, maybe using NUM_CHANNEL_MODES? + if (!channel_uses_aux(next_ch)) break; + #endif } while (count < NUM_CHANNEL_MODES); } else { next_ch = ((channel_mode + 1) % NUM_CHANNEL_MODES);