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
var d = new Date();
var da = d.toString().split(" ");
// get date // drawSting centered
var d = new Date(); g.setFontAlign(0, 0);
var da = d.toString().split(" ");
//g.clearRect(appScreen.x1, appScreen.y1, appScreen.x2, appScreen.y2); // draw time
var time = da[4].substr(0, 5);
g.setFont(font, timeFontSize);
g.drawString(time, xyCenter, yposTime, true);
// drawSting centered // draw Day, name of month, Date
g.setFontAlign(0, 0); var date = [da[0], da[1], da[2]].join(" ");
g.setFont(font, dateFontSize);
// draw time g.drawString(date, xyCenter, yposDate, true);
var time = da[4].substr(0, 5);
//g.clearRect(xyMin, yposTime, xyMax, yposTime + g.getFontHeight());
g.setFont(font, timeFontSize);
g.drawString(time, xyCenter, yposTime,true);
// draw Day, name of month, Date // draw year
var date = [ da[0], da[1], da[2] ].join(" "); g.setFont(font, dateFontSize);
g.setFont(font, dateFontSize); g.drawString(d.getFullYear(), xyCenter, yposYear, true);
//g.clearRect(xyMin, yposDate, xyMax, yposDate + g.getFontHeight());
g.drawString(date, xyCenter, yposDate,true);
// draw year // draw gmt
g.setFont(font, dateFontSize); var gmt = da[5];
//g.clearRect(xyMin, yposYear, xyMax, yposDate + g.getFontHeight()); g.setFont(font, gmtFontSize);
g.drawString(d.getFullYear(), xyCenter, yposYear,true); g.drawString(gmt, xyCenter, yposGMT, true);
// draw gmt
var gmt = da[5];
g.setFont(font, gmtFontSize);
g.drawString(gmt, xyCenter, yposGMT,true);
}
// handle switch display on by pressing BTN1
Bangle.on('lcdPower', function(on) {
if (on) {
drawSimpleClock();
drawWidgets();
} }
});
// clean app screen // handle switch display on by pressing BTN1
g.clear(); Bangle.on('lcdPower', function(on) {
if (on) {
drawSimpleClock();
drawWidgets();
}
});
// refesh every 15 sec // clean app screen
setInterval(drawSimpleClock, 15E3); g.clear();
// draw now
drawSimpleClock(); // refesh every 15 sec
setInterval(drawSimpleClock, 15E3);
// draw now
drawSimpleClock();
})(); })();