Skip to content

Commit

Permalink
Use a 4 bit buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
halemmerich committed Mar 14, 2022
1 parent a6172f5 commit 3543a71
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
30 changes: 30 additions & 0 deletions apps/imageclock/app.js
Expand Up @@ -10,6 +10,36 @@ var endPerfLog = () => {};
var printPerfLog = () => print("Deactivated");
var resetPerfLog = () => {performanceLog = {};};

var colormap={
"#000":0,
"#00f":1,
"#0f0":2,
"#0ff":3,
"#f00":4,
"#f0f":5,
"#ff0":6,
"#fff":7
};

var palette = new Uint16Array([
0x0000, //black #000
0x001f, //blue #00f
0x07e0, //green #0f0
0x07ff, //cyan #0ff
0xf800, //red #f00
0xf81f, //magenta #f0f
0xffe0, //yellow #ff0
0xffff, //white #fff
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
])

var p0 = g;
var p1;

Expand Down
14 changes: 10 additions & 4 deletions apps/imageclock/custom.html
Expand Up @@ -621,7 +621,7 @@ <h4>Upload watchface:</h4>
var lastSetColor;
var lastSetBgColor;

if (plane != 0) code += "if (!p" + plane + ") p" + plane + " = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),16,{msb:true});\n";
if (plane != 0) code += "if (!p" + plane + ") p" + plane + " = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),4,{msb:true});\n";

if (properties.Redraw && properties.Redraw.Clear){
if (wrapInTimeouts && plane != 0){
Expand All @@ -646,7 +646,7 @@ <h4>Upload watchface:</h4>

if (addDebug()) code += 'print("Copying of plane ' + previousPlane + ' to display");'+"\n";
//code += "g.drawImage(p" + i + ".asImage());";
code += "p0.drawImage({width: p" + previousPlane + ".getWidth(), height: p" + previousPlane + ".getHeight(), bpp: p" + previousPlane + ".getBPP(), buffer: p" + previousPlane + ".buffer});\n";
code += "p0.drawImage({width: p" + previousPlane + ".getWidth(), height: p" + previousPlane + ".getHeight(), bpp: p" + previousPlane + ".getBPP(), buffer: p" + previousPlane + ".buffer, palette: palette});\n";


code += "drawingTime += Date.now() - ct;\n";
Expand Down Expand Up @@ -716,11 +716,17 @@ <h4>Upload watchface:</h4>
var colorsetting = "";
if (c.value.ForegroundColor && lastSetColor != c.value.ForegroundColor){
lastSetColor = c.value.ForegroundColor;
colorsetting += planeName + ".setColor(\"" + c.value.ForegroundColor + "\");\n";
if (plane > 0)
colorsetting += planeName + ".setColor(colormap[\"" + c.value.ForegroundColor + "\"]);\n";
else
colorsetting += planeName + ".setColor(\"" + c.value.ForegroundColor + "\");\n";
}
if (c.value.BackgroundColor && lastSetBgColor != c.value.BackgroundColor){
lastSetBgColor = c.value.BackgroundColor;
colorsetting += planeName + ".setBgColor(\"" + c.value.BackgroundColor + "\");\n";
if (plane > 0)
colorsetting += planeName + ".setBgColor(colormap[\"" + c.value.BackgroundColor + "\"]);\n";
else
colorsetting += planeName + ".setBgColor(\"" + c.value.BackgroundColor + "\");\n";
}

if (addDebug()) code += 'print("Element condition is ' + condition + '");' + "\n";
Expand Down

0 comments on commit 3543a71

Please sign in to comment.