diff --git a/TODO.md b/TODO.md index f15230148..9571e984f 100644 --- a/TODO.md +++ b/TODO.md @@ -24,6 +24,7 @@ being I have it set at 2 minutes to ensure enough time for a GPS lock from scrat Items to complete before the first beta release. +* "AXP192 interrupt is not firing, remove this temporary polling of battery state" * make mesh aware network timing state machine (sync wake windows to gps time) * turn light sleep on aggressively (while lora is on but BLE off) * research and implement better mesh algorithm diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 563d6b7dc..1811fee35 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -6,6 +6,7 @@ #include "screen.h" #include "PowerFSM.h" #include "GPS.h" +#include "main.h" static void sdsEnter() { @@ -28,6 +29,8 @@ static void lsEnter() delay(10); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives) gps.prepareSleep(); // abandon in-process parsing + + if(!isUSBPowered) // FIXME - temp hack until we can put gps in sleep mode, if we have AC when we go to sleep then leave GPS on setGPSPower(false); // kill GPS power } diff --git a/src/main.h b/src/main.h index 00e286557..5d2db07cf 100644 --- a/src/main.h +++ b/src/main.h @@ -1,4 +1,6 @@ #pragma once extern bool axp192_found; -extern bool ssd1306_found; \ No newline at end of file +extern bool ssd1306_found; +extern bool isCharging; +extern bool isUSBPowered; \ No newline at end of file diff --git a/src/main.ino b/src/main.ino index 0cbdbe031..9ba9023f2 100644 --- a/src/main.ino +++ b/src/main.ino @@ -175,8 +175,8 @@ void axp192Init() axp.clearIRQ(); #endif - isCharging = axp.isChargeing(); - isUSBPowered = axp.isVBUSPlug(); + isCharging = axp.isChargeing() ? 1 : 0; + isUSBPowered = axp.isVBUSPlug() ? 1 : 0; } else { @@ -356,11 +356,15 @@ void loop() DEBUG_MSG("pmu irq!\n"); - isCharging = axp.isChargeing(); - isUSBPowered = axp.isVBUSPlug(); + isCharging = axp.isChargeing() ? 1 : 0; + isUSBPowered = axp.isVBUSPlug() ? 1 : 0; axp.clearIRQ(); } + + // FIXME AXP192 interrupt is not firing, remove this temporary polling of battery state + isCharging = axp.isChargeing() ? 1 : 0; + isUSBPowered = axp.isVBUSPlug() ? 1 : 0; #endif } #endif diff --git a/src/screen.cpp b/src/screen.cpp index 437ffcb9b..fdfdbe7bd 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include "screen.h" #include "mesh-pb-constants.h" #include "NodeDB.h" +#include "main.h" #define FONT_HEIGHT 14 // actually 13 for "ariel 10" but want a little extra space #define FONT_HEIGHT_16 (ArialMT_Plain_16[1] + 1) @@ -442,8 +443,12 @@ void drawDebugInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, i static char channelStr[20]; snprintf(channelStr, sizeof(channelStr), "%s", channelSettings.name); + // We don't show battery levels yet - for now just lie and show debug info + static char batStr[20]; + snprintf(batStr, sizeof(channelStr), "Batt %x%%", (isCharging << 1) + isUSBPowered); + const char *fields[] = { - "Batt 89%", + batStr, "GPS 75%", usersStr, channelStr,