diff options
Diffstat (limited to 'src/displayapp/screens/BatteryIcon.cpp')
| -rw-r--r-- | src/displayapp/screens/BatteryIcon.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp index 6194807d..ec740e93 100644 --- a/src/displayapp/screens/BatteryIcon.cpp +++ b/src/displayapp/screens/BatteryIcon.cpp @@ -3,6 +3,7 @@ #include "displayapp/screens/Symbols.h" #include "displayapp/icons/battery/batteryicon.c" #include "displayapp/InfiniTimeTheme.h" +#include <lvgl/src/lv_misc/lv_color.h> using namespace Pinetime::Applications::Screens; @@ -51,3 +52,12 @@ const char* BatteryIcon::GetPlugIcon(bool isCharging) { else return ""; } + +lv_color_t BatteryIcon::ColorFromPercentage(int batteryPercent) { + // HSV color model has red at 0° and green at 120°. + // We lock saturation and brightness at 100% and traverse the cylinder + // between red and green, thus avoiding the darker RGB on medium battery + // charges and giving us a much nicer color range. + const uint8_t hue = batteryPercent * 120 / 100; + return lv_color_hsv_to_rgb(hue, 100, 100); +} |
