Battery indicator optimised
This commit is contained in:
+14
-21
@@ -163,6 +163,7 @@ char buff[16];
|
|||||||
char programTypePrevious[18];
|
char programTypePrevious[18];
|
||||||
char radioIdPrevious[6];
|
char radioIdPrevious[6];
|
||||||
const uint8_t* currentFont = nullptr;
|
const uint8_t* currentFont = nullptr;
|
||||||
|
float vPerold;
|
||||||
int ActiveColor;
|
int ActiveColor;
|
||||||
int ActiveColorSmooth;
|
int ActiveColorSmooth;
|
||||||
int AGC;
|
int AGC;
|
||||||
@@ -226,10 +227,7 @@ int16_t SStatus;
|
|||||||
int8_t LevelOffset;
|
int8_t LevelOffset;
|
||||||
int8_t LowLevelSet;
|
int8_t LowLevelSet;
|
||||||
int8_t VolSet;
|
int8_t VolSet;
|
||||||
int vref = 1056;
|
|
||||||
float batteryV;
|
|
||||||
float batteryVold;
|
float batteryVold;
|
||||||
float batteryPold;
|
|
||||||
IPAddress remoteip;
|
IPAddress remoteip;
|
||||||
String afstringold;
|
String afstringold;
|
||||||
String cryptedpassword;
|
String cryptedpassword;
|
||||||
@@ -3543,6 +3541,7 @@ 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 {
|
||||||
@@ -3573,28 +3572,22 @@ void ShowBattery() {
|
|||||||
batteryold = battery;
|
batteryold = battery;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!advancedRDS && !afscreen) {
|
if (!advancedRDS && !afscreen && batterydetect) {
|
||||||
if (batteryoptions > BATTERY_NONE) {
|
float batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (1056 / 1000.0);
|
||||||
batteryV = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
|
batteryV = constrain(batteryV, 0.0, 5.0);
|
||||||
if (batteryoptions == BATTERY_VALUE) {
|
if (round(batteryV * 100.0) != round(batteryVold * 100.0)) {
|
||||||
if (batteryV < BATTERY_LOW_VALUE) return;
|
|
||||||
|
|
||||||
tftPrint(-1, String(batteryVold, 1), 213, 163, BackgroundColor, BackgroundColor, FONT16);
|
|
||||||
|
|
||||||
tftPrint(-1, String(batteryV, 1), 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
|
||||||
tftPrint(-1, "V", 232, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
|
||||||
batteryVold = batteryV;
|
batteryVold = batteryV;
|
||||||
|
if (batteryoptions == BATTERY_VALUE) {
|
||||||
|
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 = (batteryPold - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
|
||||||
if (vPer >= 1) vPer = 1;
|
|
||||||
tftPrint(-1, String(vPer * 100, 0), 213, 163, BackgroundColor, BackgroundColor, FONT16);
|
|
||||||
|
|
||||||
vPer = (batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
vPer = (batteryV - BATTERY_LOW_VALUE) / (BATTERY_FULL_VALUE - BATTERY_LOW_VALUE);
|
||||||
if (vPer >= 1) vPer = 1;
|
vPer = constrain(vPer, 0.0, 1.0);
|
||||||
tftPrint(-1, String(vPer * 100, 0), 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
vPer *= 100.0;
|
||||||
tftPrint(-1, "%", 230, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
Serial.println(vPer);
|
||||||
batteryPold = batteryV;
|
tftReplace(-1, String(vPerold, 0) + "%", String(vPer, 0) + "%", 213, 163, BatteryValueColor, BatteryValueColorSmooth, FONT16);
|
||||||
|
vPerold = vPer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -458,6 +458,7 @@ void BuildDisplay() {
|
|||||||
SNRold = 254;
|
SNRold = 254;
|
||||||
af_counterold = 254;
|
af_counterold = 254;
|
||||||
batteryold = 6;
|
batteryold = 6;
|
||||||
|
batteryVold = 0;
|
||||||
strcpy(programTypePrevious, "0");
|
strcpy(programTypePrevious, "0");
|
||||||
strcpy(radioIdPrevious, "0");
|
strcpy(radioIdPrevious, "0");
|
||||||
programServicePrevious = "0";
|
programServicePrevious = "0";
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ extern byte touchrotating;
|
|||||||
extern byte unit;
|
extern byte unit;
|
||||||
extern char programTypePrevious[18];
|
extern char programTypePrevious[18];
|
||||||
extern char radioIdPrevious[6];
|
extern char radioIdPrevious[6];
|
||||||
|
extern float batteryVold;
|
||||||
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