Added battery status icon.

This commit is contained in:
Vojtěch Pour 2022-12-13 11:21:49 +01:00
parent 18afb7c559
commit 15c940b836
14 changed files with 1287 additions and 5 deletions

View file

@ -1,6 +1,8 @@
#include <M5Core2.h>
#include "icons.cpp" // icons
float batPercentage;
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
Button restartButton(200, 191, 45, 50, false, "", noDraw);
@ -43,14 +45,15 @@ void drawGui(screenMode COLOR_MODE) {
if (COLOR_MODE == DARK) {
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_dark);
} else {
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_light);
M5.lcd.drawBitmap(240, 5, 30, 50, (uint16_t *) bluetooth_light);
}
// NOT CONNECTED BLUETOOTH
for (int i = 0; i < 4; i++) { // thicker line
M5.lcd.drawLine(280 + i, 55, 310 + i, 5, RED);
M5.lcd.drawLine(240 + i, 55, 270 + i, 5, RED);
}
drawBattery();
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
@ -73,10 +76,44 @@ void drawGui(screenMode COLOR_MODE) {
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
}
}
void drawBattery() {
batPercentage = 5;
Serial.print(M5.Axp.isCharging());
if (COLOR_MODE == DARK) {
if (M5.Axp.isCharging()) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryCharging_white);
} else {
if (batPercentage > 90) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus4_white);
} else if ((90 > batPercentage) && (batPercentage > 60)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus3_white);
} else if ((60 > batPercentage) && (batPercentage > 20)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus2_white);
} else if ((20 > batPercentage) && (batPercentage > 10)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus1_white);
} else {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus0_white);
}
}
} else {
if (M5.Axp.isCharging()) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryCharging);
} else {
if (batPercentage > 90) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus4);
} else if ((90 > batPercentage) && (batPercentage > 60)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus3);
} else if ((60 > batPercentage) && (batPercentage > 20)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus2);
} else if ((20 > batPercentage) && (batPercentage > 10)) {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus1);
} else {
M5.lcd.drawBitmap(280, 5, 32, 50, (uint16_t *) batteryStatus0);
}
}
}
}
void screenModeHandler(Event& e) {

File diff suppressed because it is too large Load diff

BIN
GUI/img/batteryCharging.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

BIN
GUI/img/batteryStatus0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
GUI/img/batteryStatus1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
GUI/img/batteryStatus2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
GUI/img/batteryStatus3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
GUI/img/batteryStatus4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB