Optmisize battery readout
- Percentage/voltage was not visible when switching to advanced RDS/AF - Percentage value was blinking - Corrected voltage calculation - Optimised battery routine.
This commit is contained in:
+11
-16
@@ -661,7 +661,8 @@ void loop() {
|
|||||||
|
|
||||||
if (!menu && !afscreen) {
|
if (!menu && !afscreen) {
|
||||||
|
|
||||||
if (af && dropout) {
|
if (af && dropout && millis() >= aftimer + 1000) {
|
||||||
|
aftimer = millis();
|
||||||
frequency = radio.TestAF();
|
frequency = radio.TestAF();
|
||||||
if (freqold != frequency) {
|
if (freqold != frequency) {
|
||||||
ShowFreq(0);
|
ShowFreq(0);
|
||||||
@@ -2973,21 +2974,15 @@ void ShowBattery() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wifi && batterydetect) {
|
if (!wifi && batterydetect) {
|
||||||
float batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (1056 / 1000.0);
|
float batteryV = constrain((((float)v / 4095.0) * 3.3 * (1100 / 1000.0) * 2.0), 0.0, 5.0);
|
||||||
batteryV = constrain(batteryV, 0.0, 5.0);
|
float vPer = constrain((batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE), 0.0, 1.0) * 100;
|
||||||
if (round(batteryV * 100.0) != round(batteryVold * 100.0)) {
|
|
||||||
if (batteryoptions == BATTERY_VALUE) {
|
if (abs(batteryV - batteryVold) > 0.05 && batteryoptions == BATTERY_VALUE) {
|
||||||
tftReplace(-1, String(batteryVold, 1) + "V", String(batteryV, 1) + "V", 279, 9, BatteryValueColor, BatteryValueColorSmooth, 16);
|
tftReplace(-1, String(batteryVold, 1) + "V", String(batteryV, 1) + "V", 279, 9, BatteryValueColor, BatteryValueColorSmooth, 16);
|
||||||
batteryVold = batteryV;
|
batteryVold = batteryV;
|
||||||
} else if (batteryoptions == BATTERY_PERCENT) {
|
} else if (int(vPer) != int(vPerold) && batteryoptions == BATTERY_PERCENT && abs(vPer - vPerold) > 0.5) {
|
||||||
float vPer = 0.0;
|
tftReplace(-1, String(vPerold, 0) + "%", String(vPer, 0) + "%", 279, 9, BatteryValueColor, BatteryValueColorSmooth, 16);
|
||||||
vPer = (batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
vPerold = vPer;
|
||||||
vPer = constrain(vPer, 0.0, 1.0);
|
|
||||||
vPer *= 100.0;
|
|
||||||
Serial.println(vPer);
|
|
||||||
tftReplace(-1, String(vPerold, 0) + "%", String(vPer, 0) + "%", 279, 9, BatteryValueColor, BatteryValueColorSmooth, 16);
|
|
||||||
vPerold = vPer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,6 +341,8 @@ void BuildAFScreen() {
|
|||||||
SStatusold = 2000;
|
SStatusold = 2000;
|
||||||
rssiold = 2000;
|
rssiold = 2000;
|
||||||
batteryold = 6;
|
batteryold = 6;
|
||||||
|
batteryVold = 0;
|
||||||
|
vPerold = 0;
|
||||||
af_counterold = 254;
|
af_counterold = 254;
|
||||||
strcpy(radioIdPrevious, "0");
|
strcpy(radioIdPrevious, "0");
|
||||||
programServicePrevious = "0";
|
programServicePrevious = "0";
|
||||||
@@ -602,6 +604,8 @@ void BuildAdvancedRDS() {
|
|||||||
rssiold = 2000;
|
rssiold = 2000;
|
||||||
rdsblockold = 33;
|
rdsblockold = 33;
|
||||||
batteryold = 6;
|
batteryold = 6;
|
||||||
|
batteryVold = 0;
|
||||||
|
vPerold = 0;
|
||||||
|
|
||||||
strcpy(programTypePrevious, "0");
|
strcpy(programTypePrevious, "0");
|
||||||
strcpy(radioIdPrevious, "0");
|
strcpy(radioIdPrevious, "0");
|
||||||
@@ -743,6 +747,7 @@ void BuildDisplay() {
|
|||||||
af_counterold = 254;
|
af_counterold = 254;
|
||||||
batteryold = 6;
|
batteryold = 6;
|
||||||
batteryVold = 0;
|
batteryVold = 0;
|
||||||
|
vPerold = 0;
|
||||||
strcpy(programTypePrevious, "0");
|
strcpy(programTypePrevious, "0");
|
||||||
strcpy(radioIdPrevious, "0");
|
strcpy(radioIdPrevious, "0");
|
||||||
programServicePrevious = "0";
|
programServicePrevious = "0";
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ extern byte unit;
|
|||||||
extern char programTypePrevious[18];
|
extern char programTypePrevious[18];
|
||||||
extern char radioIdPrevious[6];
|
extern char radioIdPrevious[6];
|
||||||
extern float batteryVold;
|
extern float batteryVold;
|
||||||
|
extern float vPerold;
|
||||||
extern int ActiveColor;
|
extern int ActiveColor;
|
||||||
extern int ActiveColorSmooth;
|
extern int ActiveColorSmooth;
|
||||||
extern int AMLevelOffset;
|
extern int AMLevelOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user