From c451d2ce9fae0c491a5e516a85f2faf1cf25273e Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Fri, 26 Dec 2025 14:50:01 +0100 Subject: Refactor battery color calculation logic into `BatteryIcon::ColorFromPercentage()`. --- src/displayapp/screens/WatchFaceTerminal.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/displayapp/screens/WatchFaceTerminal.cpp') diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 4442b29c..69fbc3ce 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -123,12 +123,10 @@ void WatchFaceTerminal::Refresh() { powerPresent = batteryController.IsPowerPresent(); batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { - // 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 = batteryPercentRemaining.Get() * 120 / 100; - lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(hue, 100, 100)); + lv_obj_set_style_local_text_color(batteryValue, + LV_LABEL_PART_MAIN, + LV_STATE_DEFAULT, + BatteryIcon::ColorFromPercentage(batteryPercentRemaining.Get())); lv_label_set_text_fmt(batteryValue, "#ffffff [BATT]# %d%%", batteryPercentRemaining.Get()); if (batteryController.IsCharging()) { lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); -- cgit v1.2.3-70-g09d2