added strikethrough for old values

pull/2577/head
Phil Roggenbuck 2023-02-14 21:40:16 +01:00 committed by GitHub
parent 9c005ca4b8
commit 9eec5c6028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 21 deletions

View File

@ -11,12 +11,13 @@ try {
settings = Object.assign({
'unitIsMmol': true,
'expireThreshold': 600000,
'reloadInterval': 300000,
//'reloadInterval': 300000, // 2add in the future
'hide': false
}, d || {});
return d;
} catch(e){
return null;
//console.log(e.toString());
return;
}
}
@ -24,15 +25,15 @@ return null;
try {
const d = require('Storage').readJSON("widbgjs.json", 1) || {};
storedData = Object.assign({
'bg': null,
'bg': 100,
'bgTimeStamp': null,
'bgDirection': null
'bgDirection': "Flat"
}, d || {});
return d;
} catch(e) {
Bangle.removeFile("widbgjs.json");
}
return null;
return;
}
function calculateRotation(bgDirection) {
@ -110,6 +111,7 @@ return null;
if(settings.hide) {
return;
}
console.log(settings.unitIsMmol.toString());
loadVals();
outpt = getBG(storedData.bg);
@ -124,16 +126,19 @@ return;
g.setFont('Vector', 22);
g.setColor(g.theme.fg);
// check if the value is too old
if (!isBgTooOld(storedData.bgTimeStamp)) {
g.drawImage(atob("FBQBAGAADwAB+AA/wAduAGZgAGAABgAAYAAGAABgAAYAAGAABgAAYAAGAABgAAYAAGAABgA="), this.x + 60, this.y + 9, { rotate: calculateRotation(storedData.bgDirection) });
// if the value is too old strikethrough it
if (isBgTooOld(storedData.bgTimeStamp)) {
g.fillRect(this.x + 5, this.y + 9, g.stringWidth(outpt),this.y + 10);
}
g.drawImage(atob("FBQBAGAADwAB+AA/wAduAGZgAGAABgAAYAAGAABgAAYAAGAABgAAYAAGAABgAAYAAGAABgA="), this.x + 60, this.y + 9, { rotate: calculateRotation(storedData.bgDirection)});
g.setColor(g.theme.fg).drawString(outpt, this.x + 5, this.y);
}
setInterval(function () {
WIDGETS["widbgjs"].draw(WIDGETS["widbgjs"]);
}, 5 * 60000); // update every 5 minutes (%* 60000
}, 5 * 60000); // update every 5 minutes (5 * 60000)
// add your widget