From 7223395740685cb57c2dae0b155ca50964ab826c Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Fri, 13 Feb 2026 18:36:17 +1100 Subject: [PATCH] Improved device ui battery rendering for more accurate battery indicator --- examples/companion_radio/ui-new/UITask.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 6ccf07b5..8d28c8a0 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -111,9 +111,10 @@ class HomeScreen : public UIScreen { void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) { - // Use voltage-based estimation to match BLE app readings - uint8_t batteryPercentage = 0; - if (batteryMilliVolts > 0) { + // Use the BQ27220 fuel gauge SOC register for accurate percentage. + // Falls back to voltage estimation if the fuel gauge returns 0. + uint8_t batteryPercentage = board.getBatteryPercent(); + if (batteryPercentage == 0 && batteryMilliVolts > 0) { const int minMilliVolts = 3000; const int maxMilliVolts = 4200; int pct = ((batteryMilliVolts - minMilliVolts) * 100) / (maxMilliVolts - minMilliVolts);