TTGO T-Beam V10 power (AXP192 PMU) fixes

This commit is contained in:
Verkehrsrot 2019-09-09 20:02:21 +02:00
parent 6dbbf14ef8
commit 3f97a5cad6
4 changed files with 30 additions and 32 deletions

View File

@ -371,7 +371,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius,
uint32_t mem, uint8_t reset1, uint8_t reset2) { uint32_t mem, uint8_t reset1, uint8_t reset2) {
uint16_t temp = celsius * 10; uint16_t temp = celsius * 10;
uint16_t volt = voltage / 10; uint16_t volt = voltage / 10;
#ifdef BAT_MEASURE_ADC #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
#if (PAYLOAD_ENCODER == 3) #if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_BATT_CHANNEL; buffer[cursor++] = LPP_BATT_CHANNEL;
#endif #endif

View File

@ -28,10 +28,10 @@ void AXP192_init(void) {
pmu.adc1Enable(AXP202_BATT_CUR_ADC1, 1); pmu.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
/* /*
// 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 need to disable AXP interrupts
#ifdef PMU_INT #ifdef PMU_INT
pinMode(PMU_INT, INPUT_PULLUP); pinMode(PMU_INT, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(PMU_INT), attachInterrupt(digitalPinToInterrupt(PMU_INT),
@ -48,13 +48,14 @@ void AXP192_init(void) {
*/ */
ESP_LOGI(TAG, "AXP192 PMU initialized."); ESP_LOGI(TAG, "AXP192 PMU initialized.");
if (pmu.isBatteryConnect()) if (pmu.isBatteryConnect())
if (pmu.isChargeing()) if (pmu.isChargeing())
ESP_LOGI(TAG, "Running on battery, charging."); ESP_LOGI(TAG, "Battery deteced, charging.");
else else
ESP_LOGI(TAG, "Running on battery, not charging."); ESP_LOGI(TAG, "Battery deteced, not charging.");
else if (pmu.isVBUSPlug()) else
ESP_LOGI(TAG, "Running on USB power."); ESP_LOGI(TAG, "No Battery deteced.");
} }
I2C_MUTEX_UNLOCK(); // release i2c bus access I2C_MUTEX_UNLOCK(); // release i2c bus access
} else } else

View File

@ -263,14 +263,10 @@ void get_config(uint8_t val[]) {
void get_status(uint8_t val[]) { void get_status(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get device status"); ESP_LOGI(TAG, "Remote command: get device status");
#ifdef BAT_MEASURE_ADC
uint16_t voltage = read_voltage();
#else
uint16_t voltage = 0;
#endif
payload.reset(); payload.reset();
payload.addStatus(voltage, uptime() / 1000, temperatureRead(), getFreeRAM(), payload.addStatus(read_voltage(), uptime() / 1000, temperatureRead(),
rtc_get_reset_reason(0), rtc_get_reset_reason(1)); getFreeRAM(), rtc_get_reset_reason(0),
rtc_get_reset_reason(1));
SendPayload(STATUSPORT, prio_high); SendPayload(STATUSPORT, prio_high);
}; };
@ -300,7 +296,7 @@ void get_bme(uint8_t val[]) {
void get_batt(uint8_t val[]) { void get_batt(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: get battery voltage"); ESP_LOGI(TAG, "Remote command: get battery voltage");
#ifdef BAT_MEASURE_ADC #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
payload.reset(); payload.reset();
payload.addVoltage(read_voltage()); payload.addVoltage(read_voltage());
SendPayload(BATTPORT, prio_normal); SendPayload(BATTPORT, prio_normal);

View File

@ -10,7 +10,8 @@ void sendcycle() {
// put data to send in RTos Queues used for transmit over channels Lora and SPI // put data to send in RTos Queues used for transmit over channels Lora and SPI
void SendPayload(uint8_t port, sendprio_t prio) { void SendPayload(uint8_t port, sendprio_t prio) {
MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[] MessageBuffer_t
SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[]
SendBuffer.MessageSize = payload.getSize(); SendBuffer.MessageSize = payload.getSize();
SendBuffer.MessagePrio = prio; SendBuffer.MessagePrio = prio;
@ -117,7 +118,7 @@ void sendData() {
break; break;
#endif #endif
#ifdef BAT_MEASURE_ADC #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
case BATT_DATA: case BATT_DATA:
payload.reset(); payload.reset();
payload.addVoltage(read_voltage()); payload.addVoltage(read_voltage());