From a277316f98aee49d00e51778a71760a531f1f94e Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Mon, 29 Dec 2025 22:25:53 +0100 Subject: WatchFaceTerminal : Apply better curve in BatteryIcon::ColorFromPercentage() so the color doesn't start going yellow until the battery is low. --- src/displayapp/screens/BatteryIcon.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/displayapp/screens/BatteryIcon.cpp') diff --git a/src/displayapp/screens/BatteryIcon.cpp b/src/displayapp/screens/BatteryIcon.cpp index ec740e93..8ebb1f54 100644 --- a/src/displayapp/screens/BatteryIcon.cpp +++ b/src/displayapp/screens/BatteryIcon.cpp @@ -1,5 +1,6 @@ -#include "displayapp/screens/BatteryIcon.h" #include +#include +#include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/Symbols.h" #include "displayapp/icons/battery/batteryicon.c" #include "displayapp/InfiniTimeTheme.h" @@ -58,6 +59,8 @@ lv_color_t BatteryIcon::ColorFromPercentage(int batteryPercent) { // 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; + const float normalizedPercent = batteryPercent / 100.0f; + // Follow -e^{-4x} + 1 curve: begins going yellow around 25%, yellow around 15%, red around 5% + const uint8_t hue = (-std::exp(-4.0f * normalizedPercent) + 1.0f) * 120.0f; return lv_color_hsv_to_rgb(hue, 100, 100); } -- cgit v1.2.3-70-g09d2