Which bit is slow for you? The drawImage in the animate function?
It's not helping that you have an image double the size of the screen - and it'll be iterating through every pixel (even the ones that are offscreen) I think.
You could have just a single fullscreen graphics (for the new screen) and could then use g.scroll to scroll the existing screen contents off, and then draw the new graphics on? That could help by a factor of 2 or so I guess.
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.
Which bit is slow for you? The
drawImage
in theanimate
function?It's not helping that you have an image double the size of the screen - and it'll be iterating through every pixel (even the ones that are offscreen) I think.
You could have just a single fullscreen graphics (for the new screen) and could then use
g.scroll
to scroll the existing screen contents off, and then draw the new graphics on? That could help by a factor of 2 or so I guess.It seems slightly counter-intuitive, but you could also use http://www.espruino.com/Reference#l_GrapĀhics_drawImages to draw just the single image, but just in the small area that's new.
... so for instance if you scroll by 8 pixels, you do
g.scroll(-8,0)
and theng.drawImages([{x:R.x-8, y:0, ...}], {x:R.w-8,y:0,width:8,height:R.h})
It's slightly slower than drawImage but it allows you to render just an area of the image, which could help in this case