renderbug-cpp/lib/Figments/Renderer.cpp

53 lines
1.2 KiB
C++

#include "./Renderer.h"
#include "./Display.h"
#include <ArduinoLog.h>
#ifndef __NOINIT_ATTR // Pre-defined on esp32
#define __NOINIT_ATTR __attribute__ ((section (".noinit")))
#endif
__NOINIT_ATTR const char* s_lastFigmentName;
const char*
Renderer::lastFigmentName()
{
return s_lastFigmentName;
}
void
Renderer::loop()
{
for(Display* dpy : m_displays) {
for(Figment* figment : m_figments) {
if (figment->state == Task::Running) {
#if defined(BOARD_ESP32) or defined(BOARD_ESP8266)
unsigned int frameStart = ESP.getCycleCount();
#endif
Log.verbose("Render %s", figment->name);
s_lastFigmentName = figment->name;
figment->render(dpy);
#if defined(BOARD_ESP32) or defined(BOARD_ESP8266)
unsigned int runtime = (ESP.getCycleCount() - frameStart) / 160000;
#else
unsigned int runtime = 0;
#endif
if (runtime >= 8) {
Log.warning("SLOW RENDER: %s took %dms!", figment->name, runtime);
}
}
};
}
FastLED.show();
FastLED.countFPS();
}
void
Renderer::onStart()
{
for(Display* dpy : m_displays) {
dpy->clear();
}
FastLED.show();
}