forked from FOSS/BangleApps
Updated word clock to not use an offscreen buffer, as it seems to really struggle with memory usage
parent
966c1c4b1e
commit
773ab1429e
|
@ -1,13 +1,6 @@
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var buf = Graphics.createArrayBuffer(240, 240, 2, { msb: true });
|
|
||||||
|
|
||||||
function flip() {
|
|
||||||
var palette = new Uint16Array([0,,,0xFFFF]);
|
|
||||||
g.drawImage({ width: buf.getWidth(), height: buf.getHeight(), bpp: 2, palette : palette, buffer: buf.buffer }, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const allWords = [
|
const allWords = [
|
||||||
"ATWENTYD",
|
"ATWENTYD",
|
||||||
"QUARTERY",
|
"QUARTERY",
|
||||||
|
@ -69,10 +62,9 @@
|
||||||
var midx;
|
var midx;
|
||||||
var midxA=[];
|
var midxA=[];
|
||||||
|
|
||||||
buf.clear();
|
g.setFontVector(wordFontSize);
|
||||||
buf.setFontVector(wordFontSize);
|
g.setColor(passivColor);
|
||||||
buf.setColor(passivColor);
|
g.setFontAlign(0, -1, 0);
|
||||||
buf.setFontAlign(0, -1, 0);
|
|
||||||
|
|
||||||
// draw allWords
|
// draw allWords
|
||||||
var c;
|
var c;
|
||||||
|
@ -81,7 +73,7 @@
|
||||||
allWords.forEach((line) => {
|
allWords.forEach((line) => {
|
||||||
x = xs;
|
x = xs;
|
||||||
for (c in line) {
|
for (c in line) {
|
||||||
buf.drawString(line[c], x, y);
|
g.drawString(line[c], x, y);
|
||||||
x += dx;
|
x += dx;
|
||||||
}
|
}
|
||||||
y += dy;
|
y += dy;
|
||||||
|
@ -105,14 +97,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// write hour in active color
|
// write hour in active color
|
||||||
buf.setColor(activeColor);
|
g.setColor(activeColor);
|
||||||
buf.setFontVector(wordFontSize);
|
g.setFontVector(wordFontSize);
|
||||||
|
|
||||||
hours[hidx][0].split('').forEach((c, pos) => {
|
hours[hidx][0].split('').forEach((c, pos) => {
|
||||||
x = xs + (hours[hidx][pos + 1] / 10 | 0) * dx;
|
x = xs + (hours[hidx][pos + 1] / 10 | 0) * dx;
|
||||||
y = ys + (hours[hidx][pos + 1] % 10) * dy;
|
y = ys + (hours[hidx][pos + 1] % 10) * dy;
|
||||||
|
|
||||||
buf.drawString(c, x, y);
|
g.drawString(c, x, y);
|
||||||
});
|
});
|
||||||
|
|
||||||
// write min words in active color
|
// write min words in active color
|
||||||
|
@ -120,18 +112,15 @@
|
||||||
mins[idx][0].split('').forEach((c, pos) => {
|
mins[idx][0].split('').forEach((c, pos) => {
|
||||||
x = xs + (mins[idx][pos + 1] / 10 | 0) * dx;
|
x = xs + (mins[idx][pos + 1] / 10 | 0) * dx;
|
||||||
y = ys + (mins[idx][pos + 1] % 10) * dy;
|
y = ys + (mins[idx][pos + 1] % 10) * dy;
|
||||||
buf.drawString(c, x, y);
|
g.drawString(c, x, y);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// display digital time
|
// display digital time
|
||||||
buf.setColor(activeColor);
|
g.setColor(activeColor);
|
||||||
buf.setFontVector(timeFontSize);
|
g.setFontVector(timeFontSize);
|
||||||
buf.drawString(time, 120, 200);
|
g.clearRect(0,200,240,240);
|
||||||
|
g.drawString(time, 120, 200);
|
||||||
// display buf
|
|
||||||
flip();
|
|
||||||
drawWidgets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.on('lcdPower', function(on) {
|
Bangle.on('lcdPower', function(on) {
|
||||||
|
|
Loading…
Reference in New Issue