I'm trying to improve the handling of the GraphicsBuffer for my 3-color (white/black/red) ePaper display.
So the display expects all pixels for black and all pixels for red to be send with a separate command. So the way it is now setup is, that I have created 2 separate GraphicBuffers of 1bpp each, e.g.
var g_red=Graphics.createArrayBuffer(264, 176, 1, {msb: true});
var g_black=Graphics.createArrayBuffer(264, 176, 1, {msb: true});
Then I write both buffers to the ePaper using different commands:
//write red
writeCommand(CMD.DATA_START_TRANSMISSION_1);
for (let i=1;i<g_red.buffer.length;i++) writeData(g_red.buffer[i]);
//write black
writeCommand(CMD.DATA_START_TRANSMISSION_2);
for (let i=1;i<g_black.buffer.length;i++) writeData(g_black.buffer[i]);
While this is working fine it bothers me, that I have 2 separate buffers to draw to. If I want to draw something in red, I have to use g_red.drawString(...) and for black g_black.drawString(...)
What I was hoping for was to use a 2bpp buffer and then be able to use setColor do something like this:
var g_both=Graphics.createArrayBuffer(264, 176, 2, {msb: true});
//draw in red
var g_both.setColor(red).drawString(...);
//draw in black
var g_both.setColor(black).drawString(...);
But now, how do I transfer this to the ePaper. It is not as easy is sending every other byte of the buffer using one of the above commands right?
When I try this, I get weird interlaced results:
writeCommand(CMD.DATA_START_TRANSMISSION_1);
for (let i=0;i<g_both.buffer.length;i+=2) writeData(g_both.buffer[i]);
writeCommand(CMD.DATA_START_TRANSMISSION_2);
for (let i=1;i<g_both.buffer.length;i+=2) writeData(g_both.buffer[i]);
So if I understand this correctly: lets assume I want to only set the first 8 pixels of the display. When I want to set the first 2 pixels and the last 2 pixels to black, I would have to send the bit value 11000011 or 99 in decimal to the black buffer.
Now if I want pixels 3-6 to be red, I would need to send bit value 00111100 or 60 to the red buffer.
I cannot wrap my head around how this would work with a 2bpp graphics buffer though.
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.
Hey guys,
I'm trying to improve the handling of the GraphicsBuffer for my 3-color (white/black/red) ePaper display.
So the display expects all pixels for black and all pixels for red to be send with a separate command. So the way it is now setup is, that I have created 2 separate GraphicBuffers of 1bpp each, e.g.
Then I write both buffers to the ePaper using different commands:
While this is working fine it bothers me, that I have 2 separate buffers to draw to. If I want to draw something in red, I have to use
g_red.drawString(...)
and for blackg_black.drawString(...)
What I was hoping for was to use a 2bpp buffer and then be able to use setColor do something like this:
But now, how do I transfer this to the ePaper. It is not as easy is sending every other byte of the buffer using one of the above commands right?
When I try this, I get weird interlaced results:
So if I understand this correctly: lets assume I want to only set the first 8 pixels of the display. When I want to set the first 2 pixels and the last 2 pixels to black, I would have to send the bit value 11000011 or 99 in decimal to the black buffer.
Now if I want pixels 3-6 to be red, I would need to send bit value 00111100 or 60 to the red buffer.
I cannot wrap my head around how this would work with a 2bpp graphics buffer though.
Hope the above is not too confusing.