mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 01:16:55 +00:00
button presses are fixed
This commit is contained in:
parent
5e2044dd63
commit
372a3e000e
4
TODO.md
4
TODO.md
@ -2,7 +2,6 @@
|
||||
|
||||
Items to complete before the first alpha release.
|
||||
|
||||
* scrolling between screens based on press is busted
|
||||
* have state machine properly enter deep sleep based on loss of mesh and phone comms
|
||||
* have gps implement canSleep(), print nmea for debugging and discard buffers on the way into sleep
|
||||
* implement CustomRF95::canSleep
|
||||
@ -164,4 +163,5 @@ Items after the first final candidate release.
|
||||
* document rules for sleep wrt lora/bluetooth/screen/gps. also: if I have text messages (only) for the phone, then give a few seconds in the hopes BLE can get it across before we have to go back to sleep.
|
||||
* wake from light sleep as needed for our next scheduled periodic task (needed for gps position broadcasts etc)
|
||||
* turn bluetooth off based on our sleep policy
|
||||
* blink LED while in LS sleep mode
|
||||
* blink LED while in LS sleep mode
|
||||
* scrolling between screens based on press is busted
|
@ -43,6 +43,8 @@ off during light sleep, but there is a TODO item to fix this.
|
||||
* While in LS/NB/DARK: If we receive new text messages (EVENT_RECEIVED_TEXT_MSG), we go to full ON mode for screen_on_secs (same as if user pressed a button)
|
||||
* While in LS: while we receive packets on the radio (EVENT_RECEIVED_PACKET) we will wake and handle them and stay awake in NB mode for min_wake_secs (default 10 seconds)
|
||||
* While in NB: If we do have packets the phone (EVENT_PACKETS_FOR_PHONE) would want we transition to DARK mode for wait_bluetooth secs.
|
||||
* While in DARK/ON: If we receive EVENT_BLUETOOTH_PAIR we transition to ON and start our screen_on_secs timeout
|
||||
* While in NB/DARK/ON: If we receive EVENT_NODEDB_UPDATED we transition to ON (so the new screen can be shown)
|
||||
|
||||
### events that decrease cpu activity
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mesh-pb-constants.h"
|
||||
#include "NodeDB.h"
|
||||
#include "GPS.h"
|
||||
#include "PowerFSM.h"
|
||||
|
||||
NodeDB nodeDB;
|
||||
|
||||
@ -274,6 +275,7 @@ void NodeDB::updateFrom(const MeshPacket &mp)
|
||||
devicestate.rx_text_message = mp;
|
||||
devicestate.has_rx_text_message = true;
|
||||
updateTextMessage = true;
|
||||
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -292,6 +294,7 @@ void NodeDB::updateFrom(const MeshPacket &mp)
|
||||
if (changed)
|
||||
{
|
||||
updateGUIforNode = info;
|
||||
powerFSM.trigger(EVENT_NODEDB_UPDATED);
|
||||
|
||||
// Not really needed - we will save anyways when we go to sleep
|
||||
// We just changed something important about the user, store our DB
|
||||
|
@ -60,6 +60,8 @@ static void lsIdle()
|
||||
doLightSleep(1);
|
||||
if (wakeCause != ESP_SLEEP_WAKEUP_TIMER)
|
||||
break;
|
||||
|
||||
secsSlept += sleepTime;
|
||||
}
|
||||
setLed(false);
|
||||
|
||||
@ -128,6 +130,13 @@ void PowerFSM_setup()
|
||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_PRESS, NULL, "Press");
|
||||
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, screenPress, "Press"); // reenter On to restart our timers
|
||||
|
||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Bluetooth pairing");
|
||||
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, NULL, "Bluetooth pairing");
|
||||
|
||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||
powerFSM.add_transition(&stateON, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||
|
||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_RECEIVED_TEXT_MSG, NULL, "Received text");
|
||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_RECEIVED_TEXT_MSG, NULL, "Received text");
|
||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_RECEIVED_TEXT_MSG, NULL, "Received text");
|
||||
|
@ -10,6 +10,8 @@
|
||||
#define EVENT_PACKET_FOR_PHONE 4
|
||||
#define EVENT_RECEIVED_TEXT_MSG 5
|
||||
#define EVENT_BOOT 6
|
||||
#define EVENT_BLUETOOTH_PAIR 7
|
||||
#define EVENT_NODEDB_UPDATED 8 // NodeDB has a big enough change that we think you should turn on the screen
|
||||
|
||||
extern Fsm powerFSM;
|
||||
|
||||
|
@ -307,9 +307,6 @@ void loop()
|
||||
screen.loop();
|
||||
service.loop();
|
||||
|
||||
if (nodeDB.updateGUI || nodeDB.updateTextMessage)
|
||||
screen.doWakeScreen();
|
||||
|
||||
ledPeriodic.loop();
|
||||
// axpDebugOutput.loop();
|
||||
loopBLE();
|
||||
|
@ -55,11 +55,8 @@ Screen screen;
|
||||
static bool showingBluetooth;
|
||||
|
||||
/// If set to true (possibly from an ISR), we should turn on the screen the next time our idle loop runs.
|
||||
static bool wakeScreen;
|
||||
static bool showingBootScreen = true; // start by showing the bootscreen
|
||||
|
||||
uint32_t lastPressMs;
|
||||
|
||||
bool Screen::isOn() { return screenOn; }
|
||||
|
||||
void msOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
|
||||
@ -491,18 +488,20 @@ void _screen_header()
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Screen::setOn(bool on)
|
||||
{
|
||||
if (!disp)
|
||||
return;
|
||||
|
||||
if(on != screenOn) {
|
||||
if(on)
|
||||
dispdev.displayOn();
|
||||
else
|
||||
dispdev.displayOff();
|
||||
screenOn = on;
|
||||
if (on != screenOn)
|
||||
{
|
||||
if (on) {
|
||||
dispdev.displayOn();
|
||||
setPeriod(1); // redraw ASAP
|
||||
}
|
||||
else
|
||||
dispdev.displayOff();
|
||||
screenOn = on;
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,14 +526,6 @@ void screen_print(const char *text)
|
||||
// ui.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Screen::doWakeScreen() {
|
||||
wakeScreen = true;
|
||||
setPeriod(1); // wake asap
|
||||
}
|
||||
|
||||
void Screen::setup()
|
||||
{
|
||||
#ifdef I2C_SDA
|
||||
@ -588,32 +579,21 @@ void Screen::setup()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// Turn off the screen this many ms after last press or wake
|
||||
#define SCREEN_SLEEP_MS (60 * 1000)
|
||||
|
||||
#define TRANSITION_FRAMERATE 30 // fps
|
||||
#define IDLE_FRAMERATE 10 // in fps
|
||||
|
||||
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
||||
|
||||
|
||||
|
||||
void Screen::doTask()
|
||||
{
|
||||
if (!disp) { // If we don't have a screen, don't ever spend any CPU for us
|
||||
if (!disp)
|
||||
{ // If we don't have a screen, don't ever spend any CPU for us
|
||||
setPeriod(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wakeScreen) // If a new text message arrived, turn the screen on immedately
|
||||
{
|
||||
lastPressMs = millis(); // if we were told to wake the screen, reset the press timeout
|
||||
screen.setOn(true); // make sure the screen is not asleep
|
||||
wakeScreen = false;
|
||||
}
|
||||
|
||||
if (!screenOn) { // If we didn't just wake and the screen is still off, then stop updating until it is on again
|
||||
if (!screenOn)
|
||||
{ // If we didn't just wake and the screen is still off, then stop updating until it is on again
|
||||
setPeriod(0);
|
||||
return;
|
||||
}
|
||||
@ -661,6 +641,8 @@ void Screen::doTask()
|
||||
setPeriod(1000 / targetFramerate);
|
||||
}
|
||||
|
||||
#include "PowerFSM.h"
|
||||
|
||||
// Show the bluetooth PIN screen
|
||||
void screen_start_bluetooth(uint32_t pin)
|
||||
{
|
||||
@ -670,7 +652,7 @@ void screen_start_bluetooth(uint32_t pin)
|
||||
|
||||
DEBUG_MSG("showing bluetooth screen\n");
|
||||
showingBluetooth = true;
|
||||
screen.doWakeScreen();
|
||||
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
|
||||
|
||||
ui.setFrames(btFrames, 1); // Just show the bluetooth frame
|
||||
// we rely on our main loop to show this screen (because we are invoked deep inside of bluetooth callbacks)
|
||||
@ -709,15 +691,11 @@ void screen_set_frames()
|
||||
/// handle press of the button
|
||||
void Screen::onPress()
|
||||
{
|
||||
// screen_start_bluetooth(123456);
|
||||
|
||||
lastPressMs = millis();
|
||||
screen.doWakeScreen();
|
||||
|
||||
// If screen was off, just wake it, otherwise advance to next frame
|
||||
// If we are in a transition, the press must have bounced, drop it.
|
||||
if (screenOn && ui.getUiState()->frameState == FIXED)
|
||||
if (ui.getUiState()->frameState == FIXED)
|
||||
{
|
||||
setPeriod(1); // redraw ASAP
|
||||
ui.nextFrame();
|
||||
|
||||
DEBUG_MSG("Setting fast framerate\n");
|
||||
|
Loading…
Reference in New Issue
Block a user