coroutine: kinda works now

This commit is contained in:
Kevin Hester
2020-10-10 09:57:57 +08:00
parent 4b9ea4f808
commit 49b4ed2a89
31 changed files with 392 additions and 150 deletions

View File

@@ -561,7 +561,9 @@ void _screen_header()
}
#endif
Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) {}
Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) {
cmdQueue.setReader(this);
}
void Screen::handleSetOn(bool on)
{
@@ -643,14 +645,24 @@ void Screen::setup()
nodeStatusObserver.observe(&nodeStatus->onNewStatus);
}
uint32_t Screen::runOnce()
int32_t Screen::runOnce()
{
// If we don't have a screen, don't ever spend any CPU for us.
if (!useDisplay) {
enabled = false;
return 0;
return RUN_SAME;
}
// Show boot screen for first 3 seconds, then switch to normal operation.
static bool showingBootScreen = true;
if (showingBootScreen && (millis() > 3000)) {
stopBootScreen();
showingBootScreen = false;
}
// Update the screen last, after we've figured out what to show.
debug_info()->setChannelNameStatus(getChannelName());
// Process incoming commands.
for (;;) {
ScreenCmd cmd;