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...
g.drawImage(img, -x, 0);
ix (x>64) x=0;
However this will be slower than @allObjects solution :)
© Espruino, powered by microcosm.
Report a problem