forked from FOSS/BangleApps
message13
parent
bdfbb52766
commit
3fe78154c3
|
@ -1,7 +1,5 @@
|
|||
(function(){
|
||||
|
||||
// place your const, vars, functions or classes here
|
||||
|
||||
const ox=10; // x offset
|
||||
const oy=80;
|
||||
const pw=20; // pixel width
|
||||
|
@ -58,20 +56,21 @@
|
|||
[1,1],
|
||||
[0,1]]];
|
||||
|
||||
let idTimeout = null; // timer interval id
|
||||
let idTimeout = null;
|
||||
|
||||
function drawTime() {
|
||||
g.clear();
|
||||
drawWidgets();
|
||||
let d = Date();
|
||||
let h = d.getHours();
|
||||
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 xp=0; xp<2; xp++){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -84,12 +83,6 @@
|
|||
idTimeout = setTimeout(drawTime, delta);
|
||||
}
|
||||
|
||||
function stopPlanning() {
|
||||
if(idTimeout) {
|
||||
clearTimeout(idTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
Bangle.on('gesture', function(gesture) {
|
||||
if (gesture && !Bangle.isLCDOn()) {
|
||||
Bangle.setLCDPower(true);
|
||||
|
@ -99,10 +92,11 @@
|
|||
// special function to handle display switch on
|
||||
Bangle.on('lcdPower', function(on){
|
||||
if (on) {
|
||||
drawWidgets();
|
||||
drawTime();
|
||||
} else {
|
||||
stopPlanning();
|
||||
if(idTimeout) {
|
||||
clearTimeout(idTimeout);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue