From e056ea3c2c844e176111cdda0badf51cb0d9211b Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Sun, 15 Feb 2026 19:30:12 +1100 Subject: [PATCH] using different HAS_BQ27220 for renderbatteryindicator --- examples/companion_radio/ui-new/UITask.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index f7ea68c3..8539a7f1 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -116,9 +116,13 @@ class HomeScreen : public UIScreen { AdvertPath recent[UI_RECENT_LIST_SIZE]; -void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) { - // Use voltage-based estimation to match BLE app readings +void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts, int* outIconX = nullptr) { 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; @@ -127,6 +131,7 @@ void renderBatteryIndicator(DisplayDriver& display, uint16_t batteryMilliVolts) if (pct > 100) pct = 100; batteryPercentage = (uint8_t)pct; } +#endif display.setColor(DisplayDriver::GREEN);