animations: updatestatus: avoid writing past end of LED array
This commit is contained in:
parent
d36de899fd
commit
81bebad459
@ -8,7 +8,7 @@ UpdateStatus::handleEvent(const InputEvent& evt)
|
||||
if (evt.intent == InputEvent::FirmwareUpdate) {
|
||||
static int updateCount = 0;
|
||||
updateCount++;
|
||||
//Log.info("Update count %d", updateCount);
|
||||
Log.info("Update count %d", updateCount);
|
||||
m_updateReady = true;
|
||||
}
|
||||
}
|
||||
@ -22,11 +22,12 @@ UpdateStatus::loop()
|
||||
void
|
||||
UpdateStatus::render(Display* dpy) const
|
||||
{
|
||||
int pos = m_pos % dpy->pixelCount();
|
||||
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);
|
||||
dpy->pixelAt(pos + i) = CRGB(255, 0, 0);
|
||||
dpy->pixelAt(pos + i + 1) = CRGB(0, 255, 0);
|
||||
dpy->pixelAt(pos + i + 2) = CRGB(0, 0, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,5 @@ public:
|
||||
|
||||
private:
|
||||
bool m_updateReady = false;
|
||||
uint8_t m_pos = 0;
|
||||
int m_pos = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user