Perhaps this doesn't pose an issue since running compiled code on the ESP32 is fast enough, but here's a suggestion, at least for helping with maintainability. Take it with a grain of salt 😅
Calling findPosition() to search for a pixel index during the render loop is inefficient and makes it hard to understand how the LED pixels are laid out:
Perhaps this doesn't pose an issue since running compiled code on the ESP32 is fast enough, but here's a suggestion, at least for helping with maintainability. Take it with a grain of salt 😅
Calling
findPosition()
to search for a pixel index during the render loop is inefficient and makes it hard to understand how the LED pixels are laid out:https://github.com/ph1p/ikea-led-obegraensad/blob/6edc2edb43a3a0e2f0a464008d015ae93846756c/src/screen.cpp#L164
You could instead change the
positions
array to be the search results offindPosition()
.Here's a fiddle that does this: https://jsfiddle.net/atesgoral/njkx749g/14/
It uses a new lookup table called
remapped
:Your render loop just can be:
This might require moving rotations to the render loop first.