renderbug-cpp/src/animations/UpdateStatus.cpp

36 lines
734 B
C++
Raw Normal View History

2019-05-10 05:17:29 +00:00
#include "./UpdateStatus.h"
2021-03-29 08:10:55 +00:00
#include <FastLED.h>
2019-05-10 05:17:29 +00:00
#include "../Static.h"
void
UpdateStatus::handleEvent(const InputEvent& evt)
{
if (evt.intent == InputEvent::FirmwareUpdate) {
static int updateCount = 0;
updateCount++;
2021-03-29 08:10:55 +00:00
//Log.info("Update count %d", updateCount);
2019-05-10 05:17:29 +00:00
m_updateReady = true;
}
}
void
UpdateStatus::loop()
{
m_pos++;
}
void
UpdateStatus::render(Display* dpy) const
{
if (m_updateReady) {
for(int i = 0; i < 12; i+=3) {
dpy->pixelAt(m_pos + i) = CRGB(255, 0, 0);
dpy->pixelAt(m_pos + i + 1) = CRGB(0, 255, 0);
dpy->pixelAt(m_pos + i + 2) = CRGB(0, 0, 255);
}
}
}
STATIC_ALLOC(UpdateStatus);
STATIC_TASK(UpdateStatus);