Merge pull request #443 from cyberman54/development
TTGO Beam v10 (AXP192) battery monitor enhanced
This commit is contained in:
commit
a22abf6b93
@ -16,6 +16,7 @@ void AXP192_power(bool on);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AXP192_init(void);
|
void AXP192_init(void);
|
||||||
|
void AXP192_displaypower(void);
|
||||||
uint16_t read_voltage(void);
|
uint16_t read_voltage(void);
|
||||||
void calibrate_voltage(void);
|
void calibrate_voltage(void);
|
||||||
uint8_t getBattLevel(void);
|
uint8_t getBattLevel(void);
|
||||||
|
@ -31,7 +31,8 @@ void doHousekeeping() {
|
|||||||
ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d",
|
ESP_LOGD(TAG, "LMiCtask %d bytes left | Taskstate = %d",
|
||||||
uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask));
|
uxTaskGetStackHighWaterMark(lmicTask), eTaskGetState(lmicTask));
|
||||||
ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d",
|
ESP_LOGD(TAG, "Lorasendtask %d bytes left | Taskstate = %d",
|
||||||
uxTaskGetStackHighWaterMark(lorasendTask), eTaskGetState(lorasendTask));
|
uxTaskGetStackHighWaterMark(lorasendTask),
|
||||||
|
eTaskGetState(lorasendTask));
|
||||||
#endif
|
#endif
|
||||||
#if (HAS_GPS)
|
#if (HAS_GPS)
|
||||||
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
|
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
|
||||||
@ -57,6 +58,12 @@ void doHousekeeping() {
|
|||||||
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||||
batt_voltage = read_voltage();
|
batt_voltage = read_voltage();
|
||||||
ESP_LOGI(TAG, "Voltage: %dmV", batt_voltage);
|
ESP_LOGI(TAG, "Voltage: %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
|
// display BME680/280 sensor data
|
||||||
|
@ -16,9 +16,10 @@ void pover_event_IRQ(void) {
|
|||||||
// put your power event handler code here
|
// put your power event handler code here
|
||||||
|
|
||||||
if (pmu.isVbusOverVoltageIRQ())
|
if (pmu.isVbusOverVoltageIRQ())
|
||||||
ESP_LOGI(TAG, "USB voltage too high.");
|
ESP_LOGI(TAG, "USB voltage %.1fV too high.", pmu.getVbusVoltage());
|
||||||
if (pmu.isVbusPlugInIRQ())
|
if (pmu.isVbusPlugInIRQ())
|
||||||
ESP_LOGI(TAG, "USB plugged.");
|
ESP_LOGI(TAG, "USB plugged, %.0fmAh @ %.1fV", pmu.getVbusCurrent(),
|
||||||
|
pmu.getVbusVoltage());
|
||||||
if (pmu.isVbusRemoveIRQ())
|
if (pmu.isVbusRemoveIRQ())
|
||||||
ESP_LOGI(TAG, "USB unplugged.");
|
ESP_LOGI(TAG, "USB unplugged.");
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ void pover_event_IRQ(void) {
|
|||||||
if (pmu.isBattRemoveIRQ())
|
if (pmu.isBattRemoveIRQ())
|
||||||
ESP_LOGI(TAG, "Battery was removed.");
|
ESP_LOGI(TAG, "Battery was removed.");
|
||||||
if (pmu.isChargingIRQ())
|
if (pmu.isChargingIRQ())
|
||||||
ESP_LOGI(TAG, "Battery is charging.");
|
ESP_LOGI(TAG, "Battery charging.");
|
||||||
if (pmu.isChargingDoneIRQ())
|
if (pmu.isChargingDoneIRQ())
|
||||||
ESP_LOGI(TAG, "Battery charging done.");
|
ESP_LOGI(TAG, "Battery charging done.");
|
||||||
if (pmu.isBattTempLowIRQ())
|
if (pmu.isBattTempLowIRQ())
|
||||||
@ -74,6 +75,17 @@ void AXP192_power(bool on) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AXP192_displaypower(void) {
|
||||||
|
if (pmu.isBatteryConnect())
|
||||||
|
if (pmu.isChargeing())
|
||||||
|
ESP_LOGI(TAG, "Battery charging @ %.0fmAh", pmu.getBattChargeCurrent());
|
||||||
|
else
|
||||||
|
ESP_LOGI(TAG, "Battery discharging @ %0.fmAh",
|
||||||
|
pmu.getBattDischargeCurrent());
|
||||||
|
else
|
||||||
|
ESP_LOGI(TAG, "No Battery");
|
||||||
|
}
|
||||||
|
|
||||||
void AXP192_init(void) {
|
void AXP192_init(void) {
|
||||||
|
|
||||||
// block i2c bus access
|
// block i2c bus access
|
||||||
@ -89,8 +101,7 @@ void AXP192_init(void) {
|
|||||||
AXP192_power(true);
|
AXP192_power(true);
|
||||||
|
|
||||||
// I2C access of AXP202X library currently is not mutexable
|
// I2C access of AXP202X library currently is not mutexable
|
||||||
// so we need to disable AXP interrupts
|
// so we better should disable AXP interrupts... ?
|
||||||
|
|
||||||
#ifdef PMU_INT
|
#ifdef PMU_INT
|
||||||
pinMode(PMU_INT, INPUT_PULLUP);
|
pinMode(PMU_INT, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(PMU_INT), PMUIRQ, FALLING);
|
attachInterrupt(digitalPinToInterrupt(PMU_INT), PMUIRQ, FALLING);
|
||||||
@ -101,14 +112,7 @@ void AXP192_init(void) {
|
|||||||
#endif // PMU_INT
|
#endif // PMU_INT
|
||||||
|
|
||||||
ESP_LOGI(TAG, "AXP192 PMU initialized.");
|
ESP_LOGI(TAG, "AXP192 PMU initialized.");
|
||||||
|
AXP192_displaypower();
|
||||||
if (pmu.isBatteryConnect())
|
|
||||||
if (pmu.isChargeing())
|
|
||||||
ESP_LOGI(TAG, "Battery deteced, charging.");
|
|
||||||
else
|
|
||||||
ESP_LOGI(TAG, "Battery deteced, not charging.");
|
|
||||||
else
|
|
||||||
ESP_LOGI(TAG, "No Battery deteced.");
|
|
||||||
}
|
}
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user