mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-04 00:52:17 +00:00
coroutines: wip compiles but does not link
This commit is contained in:
@@ -561,7 +561,7 @@ void _screen_header()
|
||||
}
|
||||
#endif
|
||||
|
||||
Screen::Screen(uint8_t address, int sda, int scl) : 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) {}
|
||||
|
||||
void Screen::handleSetOn(bool on)
|
||||
{
|
||||
@@ -573,9 +573,12 @@ void Screen::handleSetOn(bool on)
|
||||
DEBUG_MSG("Turning on screen\n");
|
||||
dispdev.displayOn();
|
||||
dispdev.displayOn();
|
||||
enabled = true;
|
||||
setInterval(0); // Draw ASAP
|
||||
} else {
|
||||
DEBUG_MSG("Turning off screen\n");
|
||||
dispdev.displayOff();
|
||||
enabled = false;
|
||||
}
|
||||
screenOn = on;
|
||||
}
|
||||
@@ -583,8 +586,6 @@ void Screen::handleSetOn(bool on)
|
||||
|
||||
void Screen::setup()
|
||||
{
|
||||
concurrency::PeriodicTask::setup();
|
||||
|
||||
// We don't set useDisplay until setup() is called, because some boards have a declaration of this object but the device
|
||||
// is never found when probing i2c and therefore we don't call setup and never want to do (invalid) accesses to this device.
|
||||
useDisplay = true;
|
||||
@@ -642,12 +643,12 @@ void Screen::setup()
|
||||
nodeStatusObserver.observe(&nodeStatus->onNewStatus);
|
||||
}
|
||||
|
||||
void Screen::doTask()
|
||||
uint32_t Screen::runOnce()
|
||||
{
|
||||
// If we don't have a screen, don't ever spend any CPU for us.
|
||||
if (!useDisplay) {
|
||||
setPeriod(0);
|
||||
return;
|
||||
enabled = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Process incoming commands.
|
||||
@@ -684,8 +685,8 @@ void Screen::doTask()
|
||||
|
||||
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;
|
||||
enabled = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Switch to a low framerate (to save CPU) when we are not in transition
|
||||
@@ -711,7 +712,7 @@ void Screen::doTask()
|
||||
// soon, otherwise just 1 fps (to save CPU) We also ask to be called twice
|
||||
// as fast as we really need so that any rounding errors still result with
|
||||
// the correct framerate
|
||||
setPeriod(1000 / targetFramerate);
|
||||
return (1000 / targetFramerate);
|
||||
}
|
||||
|
||||
void Screen::drawDebugInfoTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
@@ -801,7 +802,7 @@ void Screen::handleOnPress()
|
||||
// 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 (ui.getUiState()->frameState == FIXED) {
|
||||
setPeriod(1); // redraw ASAP
|
||||
setInterval(0); // redraw ASAP
|
||||
ui.nextFrame();
|
||||
|
||||
DEBUG_MSG("Setting fast framerate\n");
|
||||
@@ -1062,7 +1063,7 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg)
|
||||
if (nodeDB.updateTextMessage || nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) {
|
||||
setFrames(); // Regen the list of screens
|
||||
prevFrame = -1; // Force a GUI update
|
||||
setPeriod(1); // Update the screen right away
|
||||
setInterval(0); // Update the screen right away
|
||||
}
|
||||
nodeDB.updateGUI = false;
|
||||
nodeDB.updateTextMessage = false;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "TypedQueue.h"
|
||||
#include "commands.h"
|
||||
#include "concurrency/LockGuard.h"
|
||||
#include "concurrency/PeriodicTask.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
#include "power.h"
|
||||
#include <string>
|
||||
|
||||
@@ -62,7 +62,7 @@ class DebugInfo
|
||||
* multiple times simultaneously. All state-changing calls are queued and executed
|
||||
* when the main loop calls us.
|
||||
*/
|
||||
class Screen : public concurrency::PeriodicTask
|
||||
class Screen : public concurrency::OSThread
|
||||
{
|
||||
CallbackObserver<Screen, const meshtastic::Status *> powerStatusObserver =
|
||||
CallbackObserver<Screen, const meshtastic::Status *>(this, &Screen::handleStatusUpdate);
|
||||
@@ -184,7 +184,7 @@ class Screen : public concurrency::PeriodicTask
|
||||
/// Updates the UI.
|
||||
//
|
||||
// Called periodically from the main loop.
|
||||
void doTask() final;
|
||||
uint32_t runOnce() final;
|
||||
|
||||
private:
|
||||
struct ScreenCmd {
|
||||
@@ -202,7 +202,7 @@ class Screen : public concurrency::PeriodicTask
|
||||
return true; // claim success if our display is not in use
|
||||
else {
|
||||
bool success = cmdQueue.enqueue(cmd, 0);
|
||||
setPeriod(1); // handle ASAP
|
||||
setInterval(0); // handle ASAP
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user