From 50ff7977d6601f83b2a9525c3f00538181ff3d6f Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Thu, 19 Sep 2019 17:06:09 +0200 Subject: [PATCH] AXP192 Battery monitoring display enhanced --- src/cyclic.cpp | 7 +++++-- src/power.cpp | 14 ++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 1cdd9b14..d728d1bc 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -57,13 +57,16 @@ void doHousekeeping() { // read battery voltage into global variable #if (defined BAT_MEASURE_ADC || defined HAS_PMU) batt_voltage = read_voltage(); - ESP_LOGI(TAG, "Voltage: %dmV", batt_voltage); + if (batt_voltage = 0xffff) + ESP_LOGI(TAG, "Battery: external power"); + else + ESP_LOGI(TAG, "Battery: %dmV", batt_voltage); #ifdef HAS_PMU if (I2C_MUTEX_LOCK()) { AXP192_displaypower(); I2C_MUTEX_UNLOCK(); } -#endif // HAS_PMU +#endif #endif // display BME680/280 sensor data diff --git a/src/power.cpp b/src/power.cpp index 5dccf6d0..2cb0e1ff 100644 --- a/src/power.cpp +++ b/src/power.cpp @@ -78,12 +78,18 @@ void AXP192_power(bool on) { void AXP192_displaypower(void) { if (pmu.isBatteryConnect()) if (pmu.isChargeing()) - ESP_LOGI(TAG, "Battery charging @ %.0fmAh", pmu.getBattChargeCurrent()); + ESP_LOGI(TAG, "Battery charging %.0fmAh @ Temp %.1f°C", + pmu.getBattChargeCurrent(), pmu.getTSTemp()); else - ESP_LOGI(TAG, "Battery discharging @ %0.fmAh", - pmu.getBattDischargeCurrent()); + ESP_LOGI(TAG, "Battery not charging, Temp %.1f°C", pmu.getTSTemp()); else ESP_LOGI(TAG, "No Battery"); + + if (pmu.isVBUSPlug()) + ESP_LOGI(TAG, "USB present, %.0fmAh @ %.1fV", pmu.getVbusCurrent(), + pmu.getVbusVoltage()); + else + ESP_LOGI(TAG, "USB not present"); } void AXP192_init(void) { @@ -111,7 +117,7 @@ void AXP192_init(void) { pmu.clearIRQ(); #endif // PMU_INT - ESP_LOGI(TAG, "AXP192 PMU initialized."); + ESP_LOGI(TAG, "AXP192 PMU initialized, chip Temp %.1f°C", pmu.getTemp()); AXP192_displaypower(); } I2C_MUTEX_UNLOCK(); // release i2c bus access