Wow - looks like @allObjects has this sorted at a display driver level. Just for others reading there is the http://www.espruino.com/TM1640 display driver, but that wouldn't handle scrolling directly.
But just as some background though: Graphics.createArrayBuffer(...) will create a graphics instance writing to an ArrayBuffer but there are a whole bunch of options about how the data is stored in that buffer, like vertical_byte you see in @allObjects code above.
With vertical_byte and 8 pixels deep (as in his example) you can the shift the array just one byte at a time and scroll the display horizontally, however with other pixel formats you're going to have trouble.
Rather than messing with pixels directly you can also use drawImage:
let b = Graphics.createArrayBuffer(64,8,1);
// ... draw to b here
var img = b.asImage();
// now to render...
var x=0;
setInterval(functiion() {
g.drawImage(img, -x, 0);
g.flip();
x++;
ix (x>64) x=0;
},100);
However this will be slower than @allObjects solution :)
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.
Wow - looks like @allObjects has this sorted at a display driver level. Just for others reading there is the http://www.espruino.com/TM1640 display driver, but that wouldn't handle scrolling directly.
But just as some background though:
Graphics.createArrayBuffer(...)
will create a graphics instance writing to an ArrayBuffer but there are a whole bunch of options about how the data is stored in that buffer, likevertical_byte
you see in @allObjects code above.With
vertical_byte
and 8 pixels deep (as in his example) you can the shift the array just one byte at a time and scroll the display horizontally, however with other pixel formats you're going to have trouble.Rather than messing with pixels directly you can also use
drawImage
:However this will be slower than @allObjects solution :)