Hello,
I've got an 8x16 LED matrix and I'm using the Graphics module to draw a simple game onto it. I'm using an Array to hold some background pixels with I then loop and use Graphics.setPixel() to output. Everything works fine but looping my array for active pixels seems very slow. So my question is, is there a fast/better way to be doing the following?
// Create empty array
var board = Array();
for (var r=0; r < 16; r++) {
board[r] = Array();
for (var c=0; c < 8; c++) {
board[r][c] = 0;
}
}
// (un)set pixels in array code here
// Loop and output pixels
for(var r=0; r < 16; r++) {
for(var c=0; c < 8; c++) {
if(board[r][c] == 1) {
martix.setPixel(c,r);
}
}
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hello,
I've got an 8x16 LED matrix and I'm using the Graphics module to draw a simple game onto it. I'm using an Array to hold some background pixels with I then loop and use Graphics.setPixel() to output. Everything works fine but looping my array for active pixels seems very slow. So my question is, is there a fast/better way to be doing the following?