From 7f8f70655d9ccd0684b7ce168bfe9984fee056c7 Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:48:06 +1100 Subject: [PATCH] Added battery temperature to battery gauge page display. Updated firmware date --- examples/companion_radio/MyMesh.h | 2 +- examples/companion_radio/ui-new/UITask.cpp | 7 +++++++ variants/lilygo_tdeck_pro/TDeckBoard.cpp | 17 +++++++++++++---- variants/lilygo_tdeck_pro/TDeckBoard.h | 4 ++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 4c8a29d4..f9b10dbd 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -8,7 +8,7 @@ #define FIRMWARE_VER_CODE 8 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "22 Feb 2026" +#define FIRMWARE_BUILD_DATE "23 Feb 2026" #endif #ifndef FIRMWARE_VERSION diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 1c1ff0e6..3c14aa92 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -647,6 +647,13 @@ public: display.drawTextLeftAlign(0, y, "remaining cap"); sprintf(buf, "%d mAh", remCap); display.drawTextRightAlign(display.width()-1, y, buf); + y += 10; + + // Battery temperature + int16_t battTemp = board.getBattTemperature(); + display.drawTextLeftAlign(0, y, "temperature"); + sprintf(buf, "%d.%d C", battTemp / 10, abs(battTemp % 10)); + display.drawTextRightAlign(display.width()-1, y, buf); #endif } else if (_page == HomePage::SHUTDOWN) { display.setColor(DisplayDriver::GREEN); diff --git a/variants/lilygo_tdeck_pro/TDeckBoard.cpp b/variants/lilygo_tdeck_pro/TDeckBoard.cpp index 7cf55d82..8e2f1ceb 100644 --- a/variants/lilygo_tdeck_pro/TDeckBoard.cpp +++ b/variants/lilygo_tdeck_pro/TDeckBoard.cpp @@ -46,10 +46,9 @@ void TDeckBoard::begin() { MESH_DEBUG_PRINTLN("TDeckBoard::begin() - GPS Serial2 initialized at %d baud", GPS_BAUDRATE); #endif - // 4G Modem power management - // On 4G builds, ModemManager::begin() handles power-on — don't kill it here. - // On non-4G builds, disable modem power to save current and turn off red LED. - #if defined(MODEM_POWER_EN) && !defined(HAS_4G_MODEM) + // Disable 4G modem power (only present on 4G version, not audio version) + // This turns off the red status LED on the modem module + #ifdef MODEM_POWER_EN pinMode(MODEM_POWER_EN, OUTPUT); digitalWrite(MODEM_POWER_EN, LOW); // Cut power to modem MESH_DEBUG_PRINTLN("TDeckBoard::begin() - 4G modem power disabled"); @@ -354,4 +353,14 @@ uint16_t TDeckBoard::getDesignCapacity() { #else return 0; #endif +} + +int16_t TDeckBoard::getBattTemperature() { + #if HAS_BQ27220 + uint16_t raw = bq27220_read16(BQ27220_REG_TEMPERATURE); + // BQ27220 returns 0.1°K, convert to 0.1°C (273.1K = 0°C) + return (int16_t)(raw - 2731); + #else + return 0; + #endif } \ No newline at end of file diff --git a/variants/lilygo_tdeck_pro/TDeckBoard.h b/variants/lilygo_tdeck_pro/TDeckBoard.h index 06097cab..c9a09b29 100644 --- a/variants/lilygo_tdeck_pro/TDeckBoard.h +++ b/variants/lilygo_tdeck_pro/TDeckBoard.h @@ -7,6 +7,7 @@ #include // BQ27220 Fuel Gauge Registers +#define BQ27220_REG_TEMPERATURE 0x06 // Temperature (0.1°K) #define BQ27220_REG_VOLTAGE 0x08 #define BQ27220_REG_CURRENT 0x0C // Instantaneous current (mA, signed) #define BQ27220_REG_SOC 0x2C @@ -82,6 +83,9 @@ public: // Read design capacity in mAh (the configured battery size) uint16_t getDesignCapacity(); + // Read battery temperature in 0.1°C units (e.g., 256 = 25.6°C) + int16_t getBattTemperature(); + // Configure BQ27220 design capacity (checks on boot, writes only if wrong) bool configureFuelGauge(uint16_t designCapacity_mAh = BQ27220_DESIGN_CAPACITY_MAH);