Skip to content

Commit

Permalink
vkareh:battery-icon-colors (#5)
Browse files Browse the repository at this point in the history
* Remove unused pointer to DisplayApp member variables (InfiniTimeOrg#2125)

In the screens that use `DisplayApp *app` and pass it to a child item,
or use the reference just in the constructor. Afterwards the `app`
member is not used. So remove it from the private member variables.

Completely remove `app` parameter from `SettingDisplay` constructor as
it is unused.

* MusicService: add missing includes for TickType_t and xTaskGetTickCount (InfiniTimeOrg#2130)

Add `FreeRTOS.h` include for the directly used data type `TickType_t` in the header
and the function `xTaskGetTickCount` from FreeRTOS's `task.h`

* BatteryIcon: Change color with charge percentage

---------

Co-authored-by: NeroBurner <[email protected]>
Co-authored-by: Victor Kareh <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2024
1 parent 49079a6 commit e84de3d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/displayapp/screens/BatteryIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ void BatteryIcon::SetBatteryPercentage(uint8_t percentage) {
lv_obj_set_height(batteryJuice, percentage * 14 / 100);
lv_obj_realign(batteryJuice);
if (colorOnLowBattery) {
static constexpr int lowBatteryThreshold = 15;
static constexpr int criticalBatteryThreshold = 5;
if (percentage > lowBatteryThreshold) {
SetColor(LV_COLOR_WHITE);
} else if (percentage > criticalBatteryThreshold) {
SetColor(LV_COLOR_ORANGE);
} else {
SetColor(Colors::deepOrange);
}
// HSV color model has red at 0° and green at 120°.
// We lock satuation and brightness at 100% and traverse the cilinder
// between red and green, thus avoiding the darker RGB on medium battery
// charges and giving us a much nicer color range.
uint8_t hue = percentage * 120 / 100;
SetColor(lv_color_hsv_to_rgb(hue, 100, 100));
}
}

Expand Down

0 comments on commit e84de3d

Please sign in to comment.