add a real BOOT state, to avoid glitch from redrawing bootscreen twice

also its the right thing to do ;-)
This commit is contained in:
geeksville 2020-03-18 15:00:17 -07:00
parent 0d94458c4e
commit 53765298e1
5 changed files with 38 additions and 13 deletions

View File

@ -25,7 +25,7 @@ static void sdsEnter()
static void lsEnter() static void lsEnter()
{ {
DEBUG_MSG("lsEnter begin\n"); DEBUG_MSG("lsEnter begin, ls_secs=%u\n", radioConfig.preferences.ls_secs);
screen.setOn(false); screen.setOn(false);
while (!service.radio.rf95.canSleep()) while (!service.radio.rf95.canSleep())
@ -124,16 +124,23 @@ static void screenPress()
screen.onPress(); screen.onPress();
} }
static void bootEnter() {
}
State stateSDS(sdsEnter, NULL, NULL, "SDS"); State stateSDS(sdsEnter, NULL, NULL, "SDS");
State stateLS(lsEnter, lsIdle, lsExit, "LS"); State stateLS(lsEnter, lsIdle, lsExit, "LS");
State stateNB(nbEnter, NULL, NULL, "NB"); State stateNB(nbEnter, NULL, NULL, "NB");
State stateDARK(darkEnter, NULL, NULL, "DARK"); State stateDARK(darkEnter, NULL, NULL, "DARK");
State stateBOOT(bootEnter , NULL, NULL, "BOOT");
State stateON(onEnter, NULL, NULL, "ON"); State stateON(onEnter, NULL, NULL, "ON");
Fsm powerFSM(&stateDARK); Fsm powerFSM(&stateBOOT);
void PowerFSM_setup() void PowerFSM_setup()
{ {
powerFSM.add_transition(&stateDARK, &stateON, EVENT_BOOT, NULL, "Boot"); powerFSM.add_timed_transition(&stateBOOT, &stateON, 3 * 1000, NULL,
"boot timeout");
powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WAKE_TIMER, wakeForPing, "Wake timer"); powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WAKE_TIMER, wakeForPing, "Wake timer");
// Note we don't really use this transition, because when we wake from light sleep we _always_ transition to NB and then it // Note we don't really use this transition, because when we wake from light sleep we _always_ transition to NB and then it

View File

@ -4,12 +4,12 @@
// See sw-design.md for documentation // See sw-design.md for documentation
#define EVENT_PRESS 1 #define EVENT_PRESS 1
#define EVENT_WAKE_TIMER 2 #define EVENT_WAKE_TIMER 2
#define EVENT_RECEIVED_PACKET 3 #define EVENT_RECEIVED_PACKET 3
#define EVENT_PACKET_FOR_PHONE 4 #define EVENT_PACKET_FOR_PHONE 4
#define EVENT_RECEIVED_TEXT_MSG 5 #define EVENT_RECEIVED_TEXT_MSG 5
#define EVENT_BOOT 6 // #define EVENT_BOOT 6 // now done with a timed transition
#define EVENT_BLUETOOTH_PAIR 7 #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 #define EVENT_NODEDB_UPDATED 8 // NodeDB has a big enough change that we think you should turn on the screen
#define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth #define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth

View File

@ -243,18 +243,21 @@ void setup()
if (ssd1306_found) if (ssd1306_found)
screen.setup(); screen.setup();
screen.showBootscreen();
// Now that the screen is on, show our bootscreen
screen_print("Started...\n");
// Init GPS // Init GPS
gps.setup(); gps.setup();
screen_print("Started...\n");
service.init(); service.init();
// This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values
PowerFSM_setup(); // we will transition to ON in a couple of seconds, FIXME, only do this for cold boots, not waking from SDS
// setBluetoothEnable(false); we now don't start bluetooth until we enter the proper state // setBluetoothEnable(false); we now don't start bluetooth until we enter the proper state
setCPUFast(false); // 80MHz is fine for our slow peripherals setCPUFast(false); // 80MHz is fine for our slow peripherals
PowerFSM_setup();
powerFSM.trigger(EVENT_BOOT); // transition to ON, FIXME, only do this for cold boots, not waking from SDS
} }
void initBluetooth() void initBluetooth()

View File

@ -57,7 +57,7 @@ Screen screen;
static bool showingBluetooth; static bool showingBluetooth;
/// If set to true (possibly from an ISR), we should turn on the screen the next time our idle loop runs. /// If set to true (possibly from an ISR), we should turn on the screen the next time our idle loop runs.
static bool showingBootScreen = true; // start by showing the bootscreen static bool showingBootScreen = false; // start by showing the bootscreen
bool Screen::isOn() { return screenOn; } bool Screen::isOn() { return screenOn; }
@ -584,7 +584,7 @@ void Screen::setup()
// Scroll buffer // Scroll buffer
dispdev.setLogBuffer(3, 32); dispdev.setLogBuffer(3, 32);
setOn(true); // update our screenOn bool setOn(false); // start with the screen off
#ifdef BICOLOR_DISPLAY #ifdef BICOLOR_DISPLAY
dispdev.flipScreenVertically(); // looks better without this on lora32 dispdev.flipScreenVertically(); // looks better without this on lora32
@ -593,10 +593,22 @@ void Screen::setup()
// dispdev.setFont(Custom_ArialMT_Plain_10); // dispdev.setFont(Custom_ArialMT_Plain_10);
ui.disableAutoTransition(); // we now require presses ui.disableAutoTransition(); // we now require presses
ui.update(); // force an immediate draw of the bootscreen, because on some ssd1306 clones, the first draw command is discarded
#endif #endif
} }
void Screen::showBootscreen() {
if(!disp)
return;
showingBootScreen = true;
setOn(true);
// Add frames - we subtract one from the framecount so there won't be a visual glitch when we take the boot screen out of the sequence.
ui.setFrames(bootFrames, bootFrameCount);
ui.update(); // force an immediate draw of the bootscreen, because on some ssd1306 clones, the first draw command is discarded
}
#define TRANSITION_FRAMERATE 30 // fps #define TRANSITION_FRAMERATE 30 // fps
#define IDLE_FRAMERATE 10 // in fps #define IDLE_FRAMERATE 10 // in fps

View File

@ -38,6 +38,9 @@ public:
/// Rebuilt our list of screens /// Rebuilt our list of screens
void setFrames(); void setFrames();
/// Show our logo (and turn the screen on)
void showBootscreen();
private: private:
}; };