Bat icon adjust
1.Add slow down timer 2.if bat adc value < BAT_LEVEL_WARN, bat icon will turn red.
This commit is contained in:
+20
-5
@@ -84,6 +84,7 @@ byte audiomode;
|
|||||||
byte band;
|
byte band;
|
||||||
byte battery;
|
byte battery;
|
||||||
byte batteryold;
|
byte batteryold;
|
||||||
|
int batupdatetimer;
|
||||||
byte BWset;
|
byte BWset;
|
||||||
byte colorinvert;
|
byte colorinvert;
|
||||||
byte ContrastSet;
|
byte ContrastSet;
|
||||||
@@ -3972,13 +3973,27 @@ void ShowRSSI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShowBattery() {
|
void ShowBattery() {
|
||||||
battery = map(constrain(analogRead(BATTERY_PIN), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL), BAT_LEVEL_EMPTY, BAT_LEVEL_FULL, 0, BAT_LEVEL_STAGE);
|
if (millis() >= batupdatetimer + TIMER_BAT_TIMER) {
|
||||||
|
batupdatetimer = millis();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t batteryadc = analogRead(BATTERY_PIN);
|
||||||
|
battery = map(constrain(batteryadc, 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) {
|
||||||
tft.drawRect(300, 8, 12, 20, TFT_WHITE);
|
if (batteryadc < BAT_LEVEL_WARN) {
|
||||||
tft.fillRect(303, 4, 6, 4, TFT_WHITE);
|
tft.drawRect(300, 8, 12, 20, TFT_RED);
|
||||||
tft.fillRect(302, 10, 8, 16, TFT_BLACK);
|
tft.fillRect(303, 4, 6, 4, TFT_RED);
|
||||||
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, TFT_GREEN);
|
tft.fillRect(302, 10, 8, 16, TFT_BLACK);
|
||||||
|
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, TFT_GREEN);
|
||||||
|
} else {
|
||||||
|
tft.drawRect(300, 8, 12, 20, TFT_WHITE);
|
||||||
|
tft.fillRect(303, 4, 6, 4, TFT_WHITE);
|
||||||
|
tft.fillRect(302, 10, 8, 16, TFT_BLACK);
|
||||||
|
tft.fillRect(302, 26 - (battery * 4), 8, battery * 4, TFT_GREEN);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tft.drawRect(300, 8, 12, 20, TFT_GREYOUT);
|
tft.drawRect(300, 8, 12, 20, TFT_GREYOUT);
|
||||||
tft.fillRect(303, 4, 6, 4, TFT_GREYOUT);
|
tft.fillRect(303, 4, 6, 4, TFT_GREYOUT);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#define TIMER_OFFSET_TIMER (TIMER_500_TICK)
|
#define TIMER_OFFSET_TIMER (TIMER_500_TICK)
|
||||||
#define TIMER_BW_TIMER (TIMER_500_TICK)
|
#define TIMER_BW_TIMER (TIMER_500_TICK)
|
||||||
#define TIMER_SNR_TIMER (TIMER_500_TICK)
|
#define TIMER_SNR_TIMER (TIMER_500_TICK)
|
||||||
|
#define TIMER_BAT_TIMER (TIMER_500_TICK)
|
||||||
#define TIMER_500_TICK 500
|
#define TIMER_500_TICK 500
|
||||||
|
|
||||||
#define BAT_LEVEL_EMPTY 1600
|
#define BAT_LEVEL_EMPTY 1600
|
||||||
|
|||||||
Reference in New Issue
Block a user