Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2019-11-11 13:01:58 +00:00
commit 21a52670fa
1 changed files with 45 additions and 52 deletions

View File

@ -1,70 +1,63 @@
/* jshint esversion: 6 */ /* jshint esversion: 6 */
(function() { (function() {
const xyMin = 0;
const xyMax = g.getWidth();
//const appScreen = { x1: xyMin, y1: 24, x2: xyMax, y2: xyMax }; const timeFontSize = 6;
const dateFontSize = 3;
const gmtFontSize = 2;
const font = "6x8";
const timeFontSize = 6; const xyCenter = g.getWidth() / 2;
const dateFontSize = 3; const yposTime = 75;
const gmtFontSize = 2; const yposDate = 130;
const font = "6x8"; const yposYear = 175;
const yposGMT = 220;
const xyCenter = xyMax / 2; function drawSimpleClock() {
const yposTime = 75;
const yposDate = 130;
const yposYear = 175;
const yposGMT = 220;
function drawSimpleClock() {
// get date // get date
var d = new Date(); var d = new Date();
var da = d.toString().split(" "); var da = d.toString().split(" ");
//g.clearRect(appScreen.x1, appScreen.y1, appScreen.x2, appScreen.y2);
// drawSting centered // drawSting centered
g.setFontAlign(0, 0); g.setFontAlign(0, 0);
// draw time // draw time
var time = da[4].substr(0, 5); var time = da[4].substr(0, 5);
//g.clearRect(xyMin, yposTime, xyMax, yposTime + g.getFontHeight());
g.setFont(font, timeFontSize); g.setFont(font, timeFontSize);
g.drawString(time, xyCenter, yposTime,true); g.drawString(time, xyCenter, yposTime, true);
// draw Day, name of month, Date // draw Day, name of month, Date
var date = [ da[0], da[1], da[2] ].join(" "); var date = [da[0], da[1], da[2]].join(" ");
g.setFont(font, dateFontSize); g.setFont(font, dateFontSize);
//g.clearRect(xyMin, yposDate, xyMax, yposDate + g.getFontHeight());
g.drawString(date, xyCenter, yposDate,true); g.drawString(date, xyCenter, yposDate, true);
// draw year // draw year
g.setFont(font, dateFontSize); g.setFont(font, dateFontSize);
//g.clearRect(xyMin, yposYear, xyMax, yposDate + g.getFontHeight()); g.drawString(d.getFullYear(), xyCenter, yposYear, true);
g.drawString(d.getFullYear(), xyCenter, yposYear,true);
// draw gmt // draw gmt
var gmt = da[5]; var gmt = da[5];
g.setFont(font, gmtFontSize); g.setFont(font, gmtFontSize);
g.drawString(gmt, xyCenter, yposGMT,true); g.drawString(gmt, xyCenter, yposGMT, true);
} }
// handle switch display on by pressing BTN1 // handle switch display on by pressing BTN1
Bangle.on('lcdPower', function(on) { Bangle.on('lcdPower', function(on) {
if (on) { if (on) {
drawSimpleClock(); drawSimpleClock();
drawWidgets(); drawWidgets();
} }
}); });
// clean app screen // clean app screen
g.clear(); g.clear();
// refesh every 15 sec // refesh every 15 sec
setInterval(drawSimpleClock, 15E3); setInterval(drawSimpleClock, 15E3);
// draw now
drawSimpleClock(); // draw now
drawSimpleClock();
})(); })();