From 902e278d0cd886d4717ae0dc7d0c39a502358dc6 Mon Sep 17 00:00:00 2001 From: SiteRelEnby <125829806+SiteRelEnby@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:31:35 -0500 Subject: [PATCH] Issue #69: tint_ramp_direction does not get reset when channel mode arg is changed by manual memory https://github.com/ToyKeeper/anduril/issues/69 --- hw/sofirn/blf-lt1/anduril.h | 4 ++++ ui/anduril/channel-modes.c | 13 +++++++++++++ ui/anduril/config-default.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/hw/sofirn/blf-lt1/anduril.h b/hw/sofirn/blf-lt1/anduril.h index ad0befd8..e7dab444 100644 --- a/hw/sofirn/blf-lt1/anduril.h +++ b/hw/sofirn/blf-lt1/anduril.h @@ -98,6 +98,10 @@ // party strobe, tac strobe, lightning, candle, bike #define DEFAULT_STROBE_CHANNELS CM_BOTH,CM_BOTH,CM_AUTO,CM_AUTO,CM_AUTO +// FIXME: This light has a known issue (https://github.com/ToyKeeper/anduril/issues/69) +// but the fix doesn't fit on the t85, so disable it +#undef USE_TINT_RAMP_DIRECTION_FIX + // for consistency with other models #define USE_SOFT_FACTORY_RESET diff --git a/ui/anduril/channel-modes.c b/ui/anduril/channel-modes.c index 74e7ea41..49aa7838 100644 --- a/ui/anduril/channel-modes.c +++ b/ui/anduril/channel-modes.c @@ -71,6 +71,19 @@ uint8_t channel_mode_state(Event event, uint16_t arg) { if (! arg) { active = 1; // first frame means this is for us past_edge_counter = 0; // doesn't start until user hits the edge + + #ifdef USE_TINT_RAMP_DIRECTION_FIX // doesn't fit on the original LT1 + // Issue 69: if manual memory was set to an arg of 0 or 255, this could result in an incorrect + // ramp direction with the arg resetting, so make sure tint_ramp_direction is set correctly + if (channel_has_args(channel_mode)) { + if (cfg.channel_mode_args[channel_mode] == 0){ + tint_ramp_direction = 1; + } + else if (cfg.channel_mode_args[channel_mode] == 255){ + tint_ramp_direction = -1; + } + } + #endif } // ignore event if we weren't the ones who handled the first frame if (! active) return EVENT_NOT_HANDLED; diff --git a/ui/anduril/config-default.h b/ui/anduril/config-default.h index 1b34e8c0..83a62603 100644 --- a/ui/anduril/config-default.h +++ b/ui/anduril/config-default.h @@ -215,3 +215,6 @@ // (but allow disabling this feature per build) #define USE_CHANNEL_PER_STROBE +// We want this bugfix on everything except the original t85 LT1 (because it doesn't fit) +#define USE_TINT_RAMP_DIRECTION_FIX +