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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
46
lib/README
46
lib/README
@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
Reference in New Issue
Block a user