Merge pull request #433 from cyberman54/development
TTGO T-Beam V10 power (AXP192 PMU) fixes
This commit is contained in:
commit
ba455ae569
@ -371,7 +371,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius,
|
||||
uint32_t mem, uint8_t reset1, uint8_t reset2) {
|
||||
uint16_t temp = celsius * 10;
|
||||
uint16_t volt = voltage / 10;
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_BATT_CHANNEL;
|
||||
#endif
|
||||
|
@ -28,33 +28,34 @@ void AXP192_init(void) {
|
||||
pmu.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
||||
|
||||
/*
|
||||
// I2C access of AXP202X library currently is not mutexable
|
||||
// so we need to disable AXP interrupts
|
||||
|
||||
|
||||
// I2C access of AXP202X library currently is not mutexable
|
||||
// so we need to disable AXP interrupts
|
||||
|
||||
#ifdef PMU_INT
|
||||
pinMode(PMU_INT, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(PMU_INT),
|
||||
[] {
|
||||
ESP_LOGI(TAG, "Power source changed");
|
||||
// put your code here
|
||||
},
|
||||
FALLING);
|
||||
pmu.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ |
|
||||
AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ,
|
||||
1);
|
||||
pmu.clearIRQ();
|
||||
#endif // PMU_INT
|
||||
*/
|
||||
#ifdef PMU_INT
|
||||
pinMode(PMU_INT, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(PMU_INT),
|
||||
[] {
|
||||
ESP_LOGI(TAG, "Power source changed");
|
||||
// put your code here
|
||||
},
|
||||
FALLING);
|
||||
pmu.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ |
|
||||
AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ,
|
||||
1);
|
||||
pmu.clearIRQ();
|
||||
#endif // PMU_INT
|
||||
*/
|
||||
|
||||
ESP_LOGI(TAG, "AXP192 PMU initialized.");
|
||||
|
||||
if (pmu.isBatteryConnect())
|
||||
if (pmu.isChargeing())
|
||||
ESP_LOGI(TAG, "Running on battery, charging.");
|
||||
ESP_LOGI(TAG, "Battery deteced, charging.");
|
||||
else
|
||||
ESP_LOGI(TAG, "Running on battery, not charging.");
|
||||
else if (pmu.isVBUSPlug())
|
||||
ESP_LOGI(TAG, "Running on USB power.");
|
||||
ESP_LOGI(TAG, "Battery deteced, not charging.");
|
||||
else
|
||||
ESP_LOGI(TAG, "No Battery deteced.");
|
||||
}
|
||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||
} else
|
||||
|
@ -263,14 +263,10 @@ void get_config(uint8_t val[]) {
|
||||
|
||||
void get_status(uint8_t val[]) {
|
||||
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.addStatus(voltage, uptime() / 1000, temperatureRead(), getFreeRAM(),
|
||||
rtc_get_reset_reason(0), rtc_get_reset_reason(1));
|
||||
payload.addStatus(read_voltage(), uptime() / 1000, temperatureRead(),
|
||||
getFreeRAM(), rtc_get_reset_reason(0),
|
||||
rtc_get_reset_reason(1));
|
||||
SendPayload(STATUSPORT, prio_high);
|
||||
};
|
||||
|
||||
@ -300,7 +296,7 @@ void get_bme(uint8_t val[]) {
|
||||
|
||||
void get_batt(uint8_t val[]) {
|
||||
ESP_LOGI(TAG, "Remote command: get battery voltage");
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||
payload.reset();
|
||||
payload.addVoltage(read_voltage());
|
||||
SendPayload(BATTPORT, prio_normal);
|
||||
|
@ -10,7 +10,8 @@ void sendcycle() {
|
||||
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
||||
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.MessagePrio = prio;
|
||||
@ -117,7 +118,7 @@ void sendData() {
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
#if (defined BAT_MEASURE_ADC || defined HAS_PMU)
|
||||
case BATT_DATA:
|
||||
payload.reset();
|
||||
payload.addVoltage(read_voltage());
|
||||
|
Loading…
Reference in New Issue
Block a user