From 81888a7aca5c5b0d3e1e60144d659ecaf0d56ef1 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Wed, 30 Oct 2024 00:49:53 -0700 Subject: [PATCH] fix night mode issue and nicer fading on pi2 --- src/python/leds.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/python/leds.py b/src/python/leds.py index 49cadec..d30ee88 100644 --- a/src/python/leds.py +++ b/src/python/leds.py @@ -118,8 +118,14 @@ def updateLeds(cls): for c in range(3): if abs(led['current'][c] - currentTarget[c]) <= Config.FADE_SPEED: led['current'][c] = currentTarget[c] - elif led['current'][c] < currentTarget[c]: led['current'][c] = min(currentTarget[c], int((led['current'][c] + 1) * 1.25)) - elif led['current'][c] > currentTarget[c]: led['current'][c] = max(currentTarget[c], int((led['current'][c] + 1) * 0.75)) + elif led['current'][c] < currentTarget[c]: led['current'][c] = min(currentTarget[c], int((led['current'][c] + 1) * 1.15)) + elif led['current'][c] > currentTarget[c]: + led['current'][c] = max(currentTarget[c], int((led['current'][c] + 1) * 0.85)) + + # Handle edge case with multiplication of 3 + 1 * 0.75 = 3, never actually fades + if led['current'][c] == led['previous'][c] and led['current'][c] > currentTarget[c]: + led['current'][c] -= 1 + # elif led['current'][c] < currentTarget[c]: led['current'][c] += Config.FADE_SPEED # elif led['current'][c] > currentTarget[c]: led['current'][c] -= Config.FADE_SPEED