Skip to content

Commit bfaaffd

Browse files
committed
BatteryIcon: Change color with charge percentage
1 parent 0503248 commit bfaaffd

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/displayapp/screens/BatteryIcon.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@ void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
2727
lv_obj_set_height(batteryJuice, percentage * 14 / 100);
2828
lv_obj_realign(batteryJuice);
2929
if (colorOnLowBattery) {
30-
static constexpr int lowBatteryThreshold = 15;
31-
static constexpr int criticalBatteryThreshold = 5;
32-
if (percentage > lowBatteryThreshold) {
33-
SetColor(LV_COLOR_WHITE);
34-
} else if (percentage > criticalBatteryThreshold) {
35-
SetColor(LV_COLOR_ORANGE);
36-
} else {
37-
SetColor(Colors::deepOrange);
38-
}
30+
uint8_t green = percentage * 255 / 100;
31+
uint8_t red = 255 - green;
32+
SetColor(LV_COLOR_MAKE(red, green, 0x0));
3933
}
4034
}
4135

0 commit comments

Comments
 (0)