diff --git a/TODO.md b/TODO.md index f01ba5b9..aefd2fb5 100644 --- a/TODO.md +++ b/TODO.md @@ -2,12 +2,6 @@ Items to complete soon (next couple of alpha releases). -* (fixed I think) text messages are not showing on local screen if screen was on - -* (needs testing) fixed the following during a plane flight: - Have state machine properly enter deep sleep based on loss of mesh and phone comms. - Default to enter deep sleep if no LORA received for two hours (indicates user has probably left the mesh). - * lower wait_bluetooth_secs to 30 seconds once we have the GPS power on (but GPS in sleep mode) across light sleep. For the time being I have it set at 2 minutes to ensure enough time for a GPS lock from scratch. @@ -192,3 +186,7 @@ Items after the first final candidate release. until the phone pulls those packets. Ever so often power on bluetooth just so we can see if the phone wants to send some packets. Possibly might need ULP processor to help with this wake process. * do hibernation mode to get power draw down to 2.5uA https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/ * fix GPS.zeroOffset calculation it is wrong +* (needs testing) fixed the following during a plane flight: + Have state machine properly enter deep sleep based on loss of mesh and phone comms. + Default to enter deep sleep if no LORA received for two hours (indicates user has probably left the mesh). +* (fixed I think) text messages are not showing on local screen if screen was on diff --git a/lib/BluetoothOTA/src/BluetoothUtil.cpp b/lib/BluetoothOTA/src/BluetoothUtil.cpp index 4573f43a..4cbb5755 100644 --- a/lib/BluetoothOTA/src/BluetoothUtil.cpp +++ b/lib/BluetoothOTA/src/BluetoothUtil.cpp @@ -212,7 +212,7 @@ class MySecurity : public BLESecurityCallbacks } // Remove our custom screen - screen_set_frames(); + screen.setFrames(); } }; diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index ed7b0d61..6a406c19 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -25,6 +25,8 @@ static void sdsEnter() static void lsEnter() { + screen.setOn(false); + while (!service.radio.rf95.canSleep()) delay(10); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives) @@ -80,6 +82,7 @@ static void lsExit() static void nbEnter() { + screen.setOn(false); setBluetoothEnable(false); // FIXME - check if we already have packets for phone and immediately trigger EVENT_PACKETS_FOR_PHONE @@ -96,10 +99,7 @@ static void onEnter() setBluetoothEnable(true); } -static void onExit() -{ - screen.setOn(false); -} + static void wakeForPing() { } @@ -113,7 +113,7 @@ State stateSDS(sdsEnter, NULL, NULL, "SDS"); State stateLS(lsEnter, lsIdle, lsExit, "LS"); State stateNB(nbEnter, NULL, NULL, "NB"); State stateDARK(darkEnter, NULL, NULL, "DARK"); -State stateON(onEnter, NULL, onExit, "ON"); +State stateON(onEnter, NULL, NULL, "ON"); Fsm powerFSM(&stateDARK); void PowerFSM_setup() diff --git a/src/screen.cpp b/src/screen.cpp index 39ad4c6f..5f92bf22 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -140,6 +140,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 { MeshPacket &mp = devicestate.rx_text_message; NodeInfo *node = nodeDB.getNode(mp.from); + // DEBUG_MSG("drawing text message from 0x%x: %s\n", mp.from, mp.payload.variant.data.payload.bytes); // Demo for drawStringMaxWidth: // with the third parameter you can define the width after which words will be wrapped. @@ -448,7 +449,7 @@ void drawDebugInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, i snprintf(batStr, sizeof(batStr), "Batt %x%%", (isCharging << 1) + isUSBPowered); static char gpsStr[20]; - if(myNodeInfo.has_gps) + if (myNodeInfo.has_gps) snprintf(gpsStr, sizeof(gpsStr), "GPS %d%%", 75); // FIXME, use something based on hdop else gpsStr[0] = '\0'; // Just show emptystring @@ -508,11 +509,14 @@ void Screen::setOn(bool on) { if (on) { + DEBUG_MSG("Turning on screen\n"); dispdev.displayOn(); setPeriod(1); // redraw ASAP } - else + else { + DEBUG_MSG("Turning off screen\n"); dispdev.displayOff(); + } screenOn = on; } } @@ -630,7 +634,7 @@ void Screen::doTask() if (millis() > 3 * 1000) // we show the boot screen for a few seconds only { showingBootScreen = false; - screen_set_frames(); + setFrames(); } } else // standard screen loop handling ehre @@ -638,7 +642,7 @@ void Screen::doTask() // If the # nodes changes, we need to regen our list of screens if (nodeDB.updateGUI || nodeDB.updateTextMessage) { - screen_set_frames(); + setFrames(); nodeDB.updateGUI = false; nodeDB.updateTextMessage = false; } @@ -674,7 +678,7 @@ void screen_start_bluetooth(uint32_t pin) } // restore our regular frame list -void screen_set_frames() +void Screen::setFrames() { DEBUG_MSG("showing standard frames\n"); diff --git a/src/screen.h b/src/screen.h index ed3c780b..9637f928 100644 --- a/src/screen.h +++ b/src/screen.h @@ -35,6 +35,10 @@ public: /// Handle a button press void onPress(); + + /// Rebuilt our list of screens + void setFrames(); +private: }; extern Screen screen;