From f6dc0ce516fb8ac1921df77593a32b1a2a3b9a28 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Thu, 24 Jan 2019 18:47:42 -0500 Subject: [PATCH] Fix color range for ledstrip battery and rssi layers The range was underflowing the calculated hue value causing it to loop back to other colors. For example when battery ranged from below 20% the color would shift from red (the correct color for minimum battery) to shades of magenta. RSSI had the same problem. Now the logic reserves the base color (red in these cases) for the minimum 20% of the range. From 20-100% the color will scale from red through to green. --- src/main/io/ledstrip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index 910a328c5..784f3de95 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -492,12 +492,12 @@ static void applyLedFixedLayers(void) case LED_FUNCTION_BATTERY: color = HSV(RED); - hOffset += scaleRange(calculateBatteryPercentageRemaining(), 0, 100, -30, 120); + hOffset += MAX(scaleRange(calculateBatteryPercentageRemaining(), 0, 100, -30, 120), 0); break; case LED_FUNCTION_RSSI: color = HSV(RED); - hOffset += scaleRange(getRssiPercent(), 0, 100, -30, 120); + hOffset += MAX(scaleRange(getRssiPercent(), 0, 100, -30, 120), 0); break; default: