From 038413f46f397f2cd4ce73bcd56cea352d1fcd3c Mon Sep 17 00:00:00 2001 From: Neil Hao Date: Tue, 28 May 2024 19:30:15 +0800 Subject: [PATCH] User experience improvement - app battery icon (#3979) * 'app_battery_icon' * Undo VS automatic modifications to this file * 'app_battery_icon_2' --- .vscode/extensions.json | 2 +- src/PowerStatus.h | 11 ++++++++++- variants/station-g2/variant.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 783791f0b..4fc84fa78 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -6,4 +6,4 @@ "platformio.platformio-ide", "trunk.io" ], -} \ No newline at end of file +} diff --git a/src/PowerStatus.h b/src/PowerStatus.h index 56d19b758..592a03328 100644 --- a/src/PowerStatus.h +++ b/src/PowerStatus.h @@ -59,9 +59,18 @@ class PowerStatus : public Status int getBatteryVoltageMv() const { return batteryVoltageMv; } /** - * Note: 0% battery means 'unknown/this board doesn't have a battery installed' + * Note: for boards with battery pin or PMU, 0% battery means 'unknown/this board doesn't have a battery installed' */ +#if defined(HAS_PMU) || defined(BATTERY_PIN) uint8_t getBatteryChargePercent() const { return getHasBattery() ? batteryChargePercent : 0; } +#endif + + /** + * Note: for boards without battery pin and PMU, 101% battery means 'the board is using external power' + */ +#if !defined(HAS_PMU) && !defined(BATTERY_PIN) + uint8_t getBatteryChargePercent() const { return getHasBattery() ? batteryChargePercent : 101; } +#endif bool matches(const PowerStatus *newStatus) const { diff --git a/variants/station-g2/variant.h b/variants/station-g2/variant.h index f781ceb24..8f0b4b220 100755 --- a/variants/station-g2/variant.h +++ b/variants/station-g2/variant.h @@ -40,6 +40,7 @@ Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 #define SX126X_MAX_POWER 19 #endif +/* #define BATTERY_PIN 4 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define ADC_CHANNEL ADC1_GPIO4_CHANNEL #define ADC_MULTIPLIER 4 @@ -50,3 +51,4 @@ Board Information: https://wiki.uniteng.com/en/meshtastic/station-g2 #define BAT_NOBATVOLT 4460 #define CELL_TYPE_LION // same curve for liion/lipo #define NUM_CELLS 2 +*/