I'm not quite sure I understand what you want to do - you want to just copy the 'old' buffer back into m?
I think the issue is that the image buffer itself has a really strange pixel order (because of the zigzag:true needed when sending to the LEDs, and also the setRotation(1)). You're then using that as data for drawImage which expects the data to be in a simple scanline format, and not rotated.
If you do just want to restore the old data, try:
var m = Graphics.createArrayBuffer(16,8,24,{zigzag:true});
m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); };
var mCopy = Graphics.createArrayBuffer(16,8,24,{zigzag:true});
// save data away
mCopy.buffer.set(m.buffer);
// copy it back
m.buffer.set(mCopy.buffer);
That should work, and would be way faster as it just copies the raw data rather than trying to encode/decode it into pixels.
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.
I'm not quite sure I understand what you want to do - you want to just copy the 'old' buffer back into
m
?I think the issue is that the image buffer itself has a really strange pixel order (because of the
zigzag:true
needed when sending to the LEDs, and also thesetRotation(1)
). You're then using that as data for drawImage which expects the data to be in a simple scanline format, and not rotated.If you do just want to restore the old data, try:
That should work, and would be way faster as it just copies the raw data rather than trying to encode/decode it into pixels.