From c55a40481df39e9a8c634c05771748acc6d0b5b2 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Fri, 20 Oct 2023 17:23:45 +0200 Subject: [PATCH] Spectrum refactoring --- app/spectrum.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/spectrum.c b/app/spectrum.c index e8a722d..b5a414d 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -627,19 +627,12 @@ static void DrawStatus() { gBatteryVoltages[3]) / 4; - if (gBatteryCalibration[5] < Voltage) { - v = 5; - } else if (gBatteryCalibration[4] < Voltage) { - v = 5; - } else if (gBatteryCalibration[3] < Voltage) { - v = 4; - } else if (gBatteryCalibration[2] < Voltage) { - v = 3; - } else if (gBatteryCalibration[1] < Voltage) { - v = 2; - } else if (gBatteryCalibration[0] < Voltage) { - v = 1; +for(uint8_t i = 5; i > 0; i--) { + if(Voltage > gBatteryCalibration[i - 1]) { + v = i; + break; } +} gStatusLine[127] = 0b01111110; for (int i = 126; i >= 116; i--) {