Right, so what I meant is that while your display accepts the data as you say, the Graphics library in 1v61 will interleave red and green (like it would for any other bit depth). I'm not going to do a fancy colour diagram, but the data will look like:
So the code I had with the crazy shifting stuff will turn that into what you had (eventually).
If you don't want to use graphics and just want to carry on as you are, and you want to do it quickly, I'd suggest just repeating the code you have 16 times (once for each nibble):
You might find that putting it into a Uint16Array and doing a view of it was easier, but to be honest you'd have to benchmark:
var u16 = new Uint16Array([0,
((rowValue & 0x0F0F) << 4) | ((rowValue & 0xF0F0) >> 4),
...]);
var u8 = new Uint8Array(u16.buffer, 1); // <-- 1 because the '0' above took up 2 bytes
i2c.writeTo(address,u8);
PS. Multiply-AND tricks are fun. If you think about what is going on with a multply, it's like a repeated shift-add:
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.
Right, so what I meant is that while your display accepts the data as you say, the Graphics library in 1v61 will interleave red and green (like it would for any other bit depth). I'm not going to do a fancy colour diagram, but the data will look like:
So the code I had with the crazy shifting stuff will turn that into what you had (eventually).
If you don't want to use graphics and just want to carry on as you are, and you want to do it quickly, I'd suggest just repeating the code you have 16 times (once for each nibble):
You might find that putting it into a Uint16Array and doing a view of it was easier, but to be honest you'd have to benchmark:
PS. Multiply-AND tricks are fun. If you think about what is going on with a multply, it's like a repeated shift-add:
So if you multiply by 5 (0b0101) you've got:
So it's potentially 64 shift and adds in a single operation :)