1
0
Fork 0

message13

master
sebi5361 2019-12-02 20:23:21 +01:00
parent bdfbb52766
commit 3fe78154c3
1 changed files with 91 additions and 97 deletions

View File

@ -1,7 +1,5 @@
(function(){ (function(){
// place your const, vars, functions or classes here
const ox=10; // x offset const ox=10; // x offset
const oy=80; const oy=80;
const pw=20; // pixel width const pw=20; // pixel width
@ -58,20 +56,21 @@
[1,1], [1,1],
[0,1]]]; [0,1]]];
let idTimeout = null; // timer interval id let idTimeout = null;
function drawTime() { function drawTime() {
g.clear(); g.clear();
drawWidgets();
let d = Date(); let d = Date();
let h = d.getHours(); let h = d.getHours();
let m = d.getMinutes(); let m = d.getMinutes();
let digit = [Math.floor(h/10), h%10, Math.floor(m/10), m%10]; // time digit let digits = [Math.floor(h/10), h%10, Math.floor(m/10), m%10]; // time digits
for (let id=0; id<4; id++){ for (let id=0; id<4; id++){
for (let xp=0; xp<2; xp++){ for (let xp=0; xp<2; xp++){
for (let yp=0; yp<3; yp++){ for (let yp=0; yp<3; yp++){
if (pixels[digit[id]][yp][xp]==1){ if (pixels[digits[id]][yp][xp]==1){
g.fillRect(xSpace[id][xp], ySpace[yp], xSpace[id][xp]+pw, ySpace[yp]+pw); g.fillRect(xSpace[id][xp], ySpace[yp], xSpace[id][xp]+pw, ySpace[yp]+pw);
} }
} }
@ -84,12 +83,6 @@
idTimeout = setTimeout(drawTime, delta); idTimeout = setTimeout(drawTime, delta);
} }
function stopPlanning() {
if(idTimeout) {
clearTimeout(idTimeout);
}
}
Bangle.on('gesture', function(gesture) { Bangle.on('gesture', function(gesture) {
if (gesture && !Bangle.isLCDOn()) { if (gesture && !Bangle.isLCDOn()) {
Bangle.setLCDPower(true); Bangle.setLCDPower(true);
@ -99,10 +92,11 @@
// special function to handle display switch on // special function to handle display switch on
Bangle.on('lcdPower', function(on){ Bangle.on('lcdPower', function(on){
if (on) { if (on) {
drawWidgets();
drawTime(); drawTime();
} else { } else {
stopPlanning(); if(idTimeout) {
clearTimeout(idTimeout);
}
} }
}); });