build for esp32 mask project
This commit is contained in:
@ -34,6 +34,12 @@ struct Task : public virtual Loopable {
|
||||
State state = Running;
|
||||
};
|
||||
|
||||
struct TaskFunc: public Task {
|
||||
TaskFunc(std::function<void()> func) : Task("lambda"), func(func) {}
|
||||
void loop() override {func();}
|
||||
std::function<void()> func;
|
||||
};
|
||||
|
||||
struct Figment: public Task {
|
||||
Figment() : Task() {}
|
||||
Figment(State initialState) : Task(initialState) {}
|
||||
|
@ -137,7 +137,7 @@ protected:
|
||||
void setEvent(InputEvent::Intent intent, Variant &&v);
|
||||
|
||||
private:
|
||||
Ringbuf<InputEvent, 5> m_eventQueue;
|
||||
Ringbuf<InputEvent, 12> m_eventQueue;
|
||||
};
|
||||
|
||||
class InputMapper: public BufferedInputSource {
|
||||
@ -157,12 +157,20 @@ class OnlineTaskMixin : public virtual Loopable {
|
||||
void handleEvent(const InputEvent &evt) override {
|
||||
if (evt.intent == InputEvent::NetworkStatus) {
|
||||
m_online = evt.asInt();
|
||||
if (m_online) {
|
||||
onOnline();
|
||||
} else {
|
||||
onOffline();
|
||||
}
|
||||
}
|
||||
if (m_online) {
|
||||
handleEventOnline(evt);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void onOnline() {}
|
||||
virtual void onOffline() {}
|
||||
|
||||
virtual void handleEventOnline(const InputEvent &evt) {}
|
||||
|
||||
void loop() override {
|
||||
|
@ -37,10 +37,27 @@ MainLoop::loop()
|
||||
task->handleEvent(evt);
|
||||
}
|
||||
}
|
||||
unsigned int slowest = 0;
|
||||
unsigned int frameSpeed = 0;
|
||||
unsigned int frameStart = millis();
|
||||
unsigned int taskCount = 0;
|
||||
Task* slowestTask = NULL;
|
||||
for(Task* task : scheduler) {
|
||||
//Log.notice("Running %s", task->name);
|
||||
//unsigned int start = millis();
|
||||
unsigned int start = ESP.getCycleCount();
|
||||
task->loop();
|
||||
//Log.notice("next");
|
||||
//unsigned int runtime = millis() - start;
|
||||
unsigned int runtime = ESP.getCycleCount() - start;
|
||||
frameSpeed += runtime;
|
||||
taskCount++;
|
||||
if (runtime > slowest) {
|
||||
slowest = runtime;
|
||||
slowestTask = task;
|
||||
}
|
||||
}
|
||||
frameSpeed = millis() - frameStart;
|
||||
if (frameSpeed >= 23) {
|
||||
Log.notice("Slow frame: %dms, %d tasks, longest task %s was %dms", frameSpeed, taskCount, slowestTask->name, slowest/160000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,12 @@ Renderer::loop()
|
||||
for(Display* dpy : m_displays) {
|
||||
for(Figment* figment : m_figments) {
|
||||
if (figment->state == Task::Running) {
|
||||
//Log.notice("Rendering %s", figment->name);
|
||||
unsigned int frameStart = ESP.getCycleCount();
|
||||
figment->render(dpy);
|
||||
//Log.notice("next");
|
||||
} else {
|
||||
//Log.notice("Not rendering %s", figment->name);
|
||||
unsigned int runtime = (ESP.getCycleCount() - frameStart) / 160000;
|
||||
if (runtime >= 8) {
|
||||
Log.notice("SLOW RENDER: %s took %dms!", figment->name, runtime);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user