From ba4c897cee62a707a949c3985b9d23a8dc120bc8 Mon Sep 17 00:00:00 2001 From: Kyle Gabriel Date: Sun, 25 Aug 2019 13:56:43 -0400 Subject: [PATCH] Rev1 updates --- main/configuration.h | 1 + main/main.ino | 7 +++++-- main/screen.ino | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/main/configuration.h b/main/configuration.h index 8a9f2b2..7e157eb 100644 --- a/main/configuration.h +++ b/main/configuration.h @@ -129,4 +129,5 @@ void ttn_register(void (*callback)(uint8_t message)); #ifdef T_BEAM_V10 #define GPS_POWER_CTRL_CH 3 #define LORA_POWER_CTRL_CH 2 +#define PMU_IRQ 35 #endif diff --git a/main/main.ino b/main/main.ino index 638b16d..6ff88ff 100644 --- a/main/main.ino +++ b/main/main.ino @@ -26,6 +26,11 @@ #ifdef T_BEAM_V10 #include "axp20x.h" +#define AXP192_SLAVE_ADDRESS 0x34 +AXP20X_Class axp; +bool axp192_found = false; +bool pmu_irq = false; +String baChStatus = "No charging"; #endif // Message counter, stored in RTC memory, survives deep sleep @@ -184,8 +189,6 @@ void setup() { } else { Serial.println("AXP192 not found"); } - - Serial1.begin(GPS_BANUD_RATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); #endif // Buttons & LED diff --git a/main/screen.ino b/main/screen.ino index 297c80a..e000c4b 100644 --- a/main/screen.ino +++ b/main/screen.ino @@ -103,6 +103,23 @@ void screen_setup() { } void screen_loop() { + #ifdef T_BEAM_V10 + if (axp192_found && pmu_irq) { + pmu_irq = false; + axp.readIRQ(); + if (axp.isChargingIRQ()) { + baChStatus = "Charging"; + } else { + baChStatus = "No Charging"; + } + if (axp.isVbusRemoveIRQ()) { + baChStatus = "No Charging"; + } + digitalWrite(2, !digitalRead(2)); + axp.clearIRQ(); + } + #endif + display->clear(); _screen_header(); display->drawLogBuffer(0, SCREEN_HEADER_HEIGHT);