From d4b1824b1c66606310c07d70707e15c937c3aef4 Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Sun, 15 Feb 2026 19:33:19 +1100 Subject: [PATCH] using different HAS_BQ27220 for renderbatteryindicator --- examples/companion_radio/ui-new/UITask.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 69d4e4cd..2f4cdde4 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -118,8 +118,12 @@ class HomeScreen : public UIScreen { void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts, int* outIconX = nullptr) { - // Use voltage-based estimation to match BLE app readings uint8_t batteryPercentage = 0; +#if HAS_BQ27220 + // Use fuel gauge SOC directly — accurate across the full discharge curve + batteryPercentage = board.getBatteryPercent(); +#else + // Fallback: voltage-based linear estimation for boards without fuel gauge if (batteryMilliVolts > 0) { const int minMilliVolts = 3000; const int maxMilliVolts = 4200; @@ -128,6 +132,7 @@ void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts, if (pct > 100) pct = 100; batteryPercentage = (uint8_t)pct; } +#endif display.setColor(DisplayDriver::GREEN);