diff --git a/apps/bigdclock/ChangeLog b/apps/bigdclock/ChangeLog index ec66c5568..ae5ae9224 100644 --- a/apps/bigdclock/ChangeLog +++ b/apps/bigdclock/ChangeLog @@ -1 +1,2 @@ 0.01: Initial version +0.02: setTimeout bug fix; no leading zero on date; lightmode; 12 hour format; cleanup diff --git a/apps/bigdclock/bigdclock.app.js b/apps/bigdclock/bigdclock.app.js index 983ca0d1c..ce2368e87 100644 --- a/apps/bigdclock/bigdclock.app.js +++ b/apps/bigdclock/bigdclock.app.js @@ -10,40 +10,17 @@ Graphics.prototype.setFontOpenSans = function(scale) { ); }; -// the following 2 sections are used from waveclk to schedule minutely updates -// timeout used to update every minute var drawTimeout; // schedule a draw for the next minute function queueDraw() { if (drawTimeout) clearTimeout(drawTimeout); drawTimeout = setTimeout(function () { - drawTimeout = undefined; draw(); - }, 60300 - (Date.now() % 60000)); -} - -function drawBackground() { - g.setBgColor(0, 0, 0); - g.setColor(1, 1, 1); - g.clear(); -} - -function digit(num) { - return String.fromCharCode(num + 48); -} - -function timeString(h, m) { - return digit(h / 10) + digit(h % 10) + ":" + digit(m / 10) + digit(m % 10); -} - -function dayString(w) { - return digit(w / 10) + digit(w % 10); + }, 60300 - (Date.now() % 60000)); // We aim for 300ms into the next minute to ensure we make it! } function draw() { - g.reset(); - drawBackground(); var date = new Date(); var h = date.getHours(), m = date.getMinutes(); @@ -51,22 +28,26 @@ function draw() { w = date.getDay(); // d=1..31; w=0..6 const level = E.getBattery(); const width = level + (level/2); + var is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"]; - g.setBgColor(0, 0, 0); - g.setColor(1, 1, 1); + g.reset(); + g.clear(); g.setFontOpenSans(); g.setFontAlign(0, -1); - g.drawString(timeString(h, m), g.getWidth() / 2, 30); - g.drawString(dayString(d), g.getWidth() * 3 / 4, 98); + if (is12Hour) { + if (h > 12) h -= 12; + if (h == 0) h = 12; + g.drawString(h + ":" + ("0"+m).substr(-2), g.getWidth() / 2, 30); + } else { + g.drawString(("0"+h).substr(-2) + ":" + ("0"+m).substr(-2), g.getWidth() / 2, 30); + } + g.setFontAlign(1, -1); + g.drawString(d, g.getWidth() -6, 98); g.setFont('Vector', 52); g.setFontAlign(-1, -1); g.drawString("SUMOTUWETHFRSA".slice(2*w,2*w+2), 6, 103); - g.setColor(0, 1, 0); - g.fillRect(0, 90, g.getWidth(), 94); - g.reset(); - g.setColor(1,1,1); g.fillRect(9,159,166,171); g.fillRect(167,163,170,167); if (Bangle.isCharging()) { @@ -78,17 +59,18 @@ function draw() { } g.fillRect(12,162,12+width,168); if (level < 100) { - g.setColor(0,0,0); + g.setColor(g.theme.bg); g.fillRect(12+width+1,162,162,168); } + + g.setColor(0, 1, 0); + g.fillRect(0, 90, g.getWidth(), 94); + // widget redraw Bangle.drawWidgets(); queueDraw(); } -Bangle.loadWidgets(); -draw(); - //the following section is also from waveclk Bangle.on('lcdPower', on => { if (on) { @@ -99,6 +81,7 @@ Bangle.on('lcdPower', on => { } }); -Bangle.setUI("clock"); +Bangle.loadWidgets(); +draw(); -Bangle.drawWidgets(); +Bangle.setUI("clock"); diff --git a/apps/bigdclock/metadata.json b/apps/bigdclock/metadata.json index 275a33343..c6be19138 100644 --- a/apps/bigdclock/metadata.json +++ b/apps/bigdclock/metadata.json @@ -1,7 +1,7 @@ { "id": "bigdclock", "name": "Big digit clock containing just the essentials", - "shortName":"Big digit clock", - "version":"0.01", + "shortName":"Big digit clk", + "version":"0.02", "description": "A clock containing just the essentials, made as easy to read as possible for those of us that need glasses. It contains the time, the day-of-week, the day-of-month, and the current battery state-of-charge.", "icon": "bigdclock.png", "type": "clock", diff --git a/apps/bigdclock/screenshot.png b/apps/bigdclock/screenshot.png index 96f2dd4ef..8a12b266e 100644 Binary files a/apps/bigdclock/screenshot.png and b/apps/bigdclock/screenshot.png differ