I have managed to add some features and squeeze some additional performance out of the watchface. Using it daily is quite possible now. To do that, I had to render part of the watchface to a buffer, to be able to overlay it with analog hands without having to redraw the whole thing on every refresh.
I did however not manage to create a working solution with a buffer bit depth other than 16 bit. I expected 4 bit to be enough for Bangle 2, but that garbled all colors.
I have also tried using 8 bit color, but had the same problem as with 4 bit, just other wrong colors.
In essence I am trying to do something like this:
var img16 = { width : 16, height : 16, bpp : 16, transparent : 1, buffer : require("heatshrink").decompress(atob("AA//AA34gABFgEfAIwf/D70H/4BG8ABF/EfAIv/8ABFD/4ffgEQAIsEgABFwABGwgBGD/4ffwkfAIuH8ABF/kQAIv/+ABFD/4ffA"))};
var img3 = { width : 16, height : 16, bpp : 3, buffer : require("heatshrink").decompress(atob("gEP/+SoVJAtNt2mS23d2wFpA"))};
var b = Graphics.createArrayBuffer(176,176,8);
b.drawImage(img16,0,0,{scale:5});//top left in buffer
b.drawImage(img3,0,96,{scale:5});//bottom left in buffer
g.drawImage(b.asImage());
g.drawImage(img16,96,0,{scale:5});//top right direct
g.drawImage(img3,96,96,{scale:5});//bottom right direct
Changing the bit depth of the b buffer to 16 makes this example work just fine. I could not get it to work correctly for 8 bit.
4 bit color with a transparent color defined would use the minimum possible amount of RAM, but that probably needs a palette and matching conversion of the images used in the watchface?
If a 4 bit palette for drawing the contents of b to g gives me correct colors, does dithering of images with bigger bit depths still work when drawing to the 4 bit buffer?
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 have managed to add some features and squeeze some additional performance out of the watchface. Using it daily is quite possible now. To do that, I had to render part of the watchface to a buffer, to be able to overlay it with analog hands without having to redraw the whole thing on every refresh.
I did however not manage to create a working solution with a buffer bit depth other than 16 bit. I expected 4 bit to be enough for Bangle 2, but that garbled all colors.
I have also tried using 8 bit color, but had the same problem as with 4 bit, just other wrong colors.
In essence I am trying to do something like this:
Changing the bit depth of the
b
buffer to 16 makes this example work just fine. I could not get it to work correctly for 8 bit.4 bit color with a transparent color defined would use the minimum possible amount of RAM, but that probably needs a palette and matching conversion of the images used in the watchface?
If a 4 bit palette for drawing the contents of
b
tog
gives me correct colors, does dithering of images with bigger bit depths still work when drawing to the 4 bit buffer?3 Attachments