Greyed out battery icon was missing when WiFi was active
This commit is contained in:
+39
-41
@@ -3547,53 +3547,51 @@ void ShowRSSI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShowBattery() {
|
void ShowBattery() {
|
||||||
if (!wifi) {
|
if (millis() >= batupdatetimer + TIMER_BAT_TIMER) {
|
||||||
if (millis() >= batupdatetimer + TIMER_BAT_TIMER) {
|
batupdatetimer = millis();
|
||||||
batupdatetimer = millis();
|
} else {
|
||||||
} else {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t v = analogRead(BATTERY_PIN);
|
uint16_t v = analogRead(BATTERY_PIN);
|
||||||
|
|
||||||
battery = map(constrain(v, BAT_LEVEL_EMPTY, BAT_LEVEL_FULL), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL, 0, BAT_LEVEL_STAGE);
|
battery = map(constrain(v, BAT_LEVEL_EMPTY, BAT_LEVEL_FULL), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL, 0, BAT_LEVEL_STAGE);
|
||||||
if (batteryold != battery) {
|
if (batteryold != battery) {
|
||||||
if (batterydetect) {
|
if (batterydetect) {
|
||||||
if (battery == 0) {
|
if (battery == 0) {
|
||||||
tft.drawRect(300, 8, 12, 20, BarSignificantColor);
|
tft.drawRect(300, 8, 12, 20, BarSignificantColor);
|
||||||
tft.fillRect(303, 4, 6, 4, BarSignificantColor);
|
tft.fillRect(303, 4, 6, 4, BarSignificantColor);
|
||||||
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
|
||||||
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, BarInsignificantColor);
|
|
||||||
} else {
|
|
||||||
tft.drawRect(300, 8, 12, 20, ActiveColor);
|
|
||||||
tft.fillRect(303, 4, 6, 4, ActiveColor);
|
|
||||||
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
|
||||||
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, BarInsignificantColor);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tft.drawRect(300, 8, 12, 20, GreyoutColor);
|
|
||||||
tft.fillRect(303, 4, 6, 4, GreyoutColor);
|
|
||||||
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
||||||
|
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, BarInsignificantColor);
|
||||||
|
} else {
|
||||||
|
tft.drawRect(300, 8, 12, 20, ActiveColor);
|
||||||
|
tft.fillRect(303, 4, 6, 4, ActiveColor);
|
||||||
|
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
||||||
|
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, BarInsignificantColor);
|
||||||
}
|
}
|
||||||
batteryold = battery;
|
} else {
|
||||||
|
tft.drawRect(300, 8, 12, 20, GreyoutColor);
|
||||||
|
tft.fillRect(303, 4, 6, 4, GreyoutColor);
|
||||||
|
tft.fillRect(302, 10, 8, 16, BackgroundColor);
|
||||||
}
|
}
|
||||||
|
batteryold = battery;
|
||||||
|
}
|
||||||
|
|
||||||
if (!advancedRDS && !afscreen && batterydetect) {
|
if (!wifi && !advancedRDS && !afscreen && batterydetect) {
|
||||||
float batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (1056 / 1000.0);
|
float batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (1056 / 1000.0);
|
||||||
batteryV = constrain(batteryV, 0.0, 5.0);
|
batteryV = constrain(batteryV, 0.0, 5.0);
|
||||||
if (round(batteryV * 100.0) != round(batteryVold * 100.0)) {
|
if (round(batteryV * 100.0) != round(batteryVold * 100.0)) {
|
||||||
batteryVold = batteryV;
|
batteryVold = batteryV;
|
||||||
if (batteryoptions == BATTERY_VALUE) {
|
if (batteryoptions == BATTERY_VALUE) {
|
||||||
tftReplace(-1, String(batteryVold, 1) + "V", String(batteryV, 1) + "V", 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
tftReplace(-1, String(batteryVold, 1) + "V", String(batteryV, 1) + "V", 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
||||||
} else if (batteryoptions == BATTERY_PERCENT) {
|
} else if (batteryoptions == BATTERY_PERCENT) {
|
||||||
float vPer = 0.0;
|
float vPer = 0.0;
|
||||||
vPer = (batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
vPer = (batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
||||||
vPer = constrain(vPer, 0.0, 1.0);
|
vPer = constrain(vPer, 0.0, 1.0);
|
||||||
vPer *= 100.0;
|
vPer *= 100.0;
|
||||||
Serial.println(vPer);
|
Serial.println(vPer);
|
||||||
tftReplace(-1, String(vPerold, 0) + "%", String(vPer, 0) + "%", 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
tftReplace(-1, String(vPerold, 0) + "%", String(vPer, 0) + "%", 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
||||||
vPerold = vPer;
|
vPerold = vPer;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user