File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1- #include " displayapp/screens/BatteryIcon.h"
21#include < cstdint>
2+ #include < cmath>
3+ #include " displayapp/screens/BatteryIcon.h"
34#include " displayapp/screens/Symbols.h"
45#include " displayapp/icons/battery/batteryicon.c"
56#include " displayapp/InfiniTimeTheme.h"
@@ -58,6 +59,8 @@ lv_color_t BatteryIcon::ColorFromPercentage(int batteryPercent) {
5859 // We lock saturation and brightness at 100% and traverse the cylinder
5960 // between red and green, thus avoiding the darker RGB on medium battery
6061 // charges and giving us a much nicer color range.
61- const uint8_t hue = batteryPercent * 120 / 100 ;
62+ const float normalizedPercent = batteryPercent / 100 .0f ;
63+ // Follow -e^{-4x} + 1 curve: begins going yellow around 25%, yellow around 15%, red around 5%
64+ const uint8_t hue = (-std::exp (-4 .0f * normalizedPercent) + 1 .0f ) * 120 .0f ;
6265 return lv_color_hsv_to_rgb (hue, 100 , 100 );
6366}
You can’t perform that action at this time.
0 commit comments