AXP192 Battery monitoring display enhanced

This commit is contained in:
Verkehrsrot 2019-09-19 17:06:09 +02:00
parent 79e54774f1
commit 50ff7977d6
2 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -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