Add check for widgets that clear the screen!

Remove clear of the screen on reload (will break currently running app)
pull/3629/head
Gordon Williams 2024-10-28 17:27:31 +00:00
parent a4f5978fb6
commit f0c9ae183c
8 changed files with 29 additions and 37 deletions

View File

@ -1,2 +1,3 @@
0.01: New app! 0.01: New app!
0.02: Minor code improvements 0.02: Minor code improvements
0.03: Remove clearing of the screen (will break running apps) and fix lint errors

View File

@ -2,8 +2,8 @@
"id": "banglebridge", "id": "banglebridge",
"name": "BangleBridge", "name": "BangleBridge",
"shortName": "BangleBridge", "shortName": "BangleBridge",
"version": "0.02", "version": "0.03",
"description": "Widget that allows Bangle Js to record pair and end data using Bluetooth Low Energy in combination with the BangleBridge Android App", "description": "Widget that allows Bangle.js to record pair and end data using Bluetooth Low Energy in combination with the BangleBridge Android App (**Note:** this has nothing to do with Gadgetbridge)",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",
"tags": "widget", "tags": "widget",

View File

@ -35,8 +35,7 @@
}); });
setInterval(function () { setInterval(function () {
//acclS = accelN.x + "##" + accelN.y + "##" + accelN.z + "\n" + accelN.diff + "##" + accelN.mag;
acclS = accelN.x + "##" + accelN.y + "##" + accelN.z + "\n" + accelN.diff + "##" + accelN.mag;
data[3] = accelN; data[3] = accelN;
}, 2 * 1000); }, 2 * 1000);
@ -45,8 +44,7 @@
function btt() { function btt() {
setInterval(function () { setInterval(function () {
//bttS = E.getBattery(); //return String
bttS = E.getBattery(); //return String
data[2] = E.getBattery(); data[2] = E.getBattery();
}, 15 * 1000); }, 15 * 1000);
@ -65,9 +63,9 @@
setInterval(function () { setInterval(function () {
compssS = "A: " + compssN.x + " ## " + compssN.y + " ## " + compssN.z + "\n" + /*compssS = "A: " + compssN.x + " ## " + compssN.y + " ## " + compssN.z + "\n" +
"B: " + compssN.dx + " ## " + compssN.dy + " ## " + compssN.dz + " ## " + "\n" + "B: " + compssN.dx + " ## " + compssN.dy + " ## " + compssN.dz + " ## " + "\n" +
"C: " + compssN.heading; //return String "C: " + compssN.heading; *///return String
data[4] = compssN; data[4] = compssN;
}, 2 * 1000); }, 2 * 1000);
@ -86,8 +84,8 @@
setInterval(function () { setInterval(function () {
gpsS = "A: " + gpsN.lat + " ## " + gpsN.lon + " ## " + gpsN.alt + "\n" + "B: " + gpsN.speed + " ## " + gpsN.course + " ## " + gpsN.time + "\n" + /*gpsS = "A: " + gpsN.lat + " ## " + gpsN.lon + " ## " + gpsN.alt + "\n" + "B: " + gpsN.speed + " ## " + gpsN.course + " ## " + gpsN.time + "\n" +
"C: " + gpsN.satellites + " ## " + gpsN.fix; //return String "C: " + gpsN.satellites + " ## " + gpsN.fix; *///return String
// work out how to display the current time // work out how to display the current time
var d = new Date(); var d = new Date();
var year = d.getFullYear(); var year = d.getFullYear();
@ -150,7 +148,7 @@
//console.log("Index ==> "+ index); //console.log("Index ==> "+ index);
msr[indexFinal] = nueva; msr[indexFinal] = nueva;
item = nueva; //item = nueva;
lastInsert = indexFinal; lastInsert = indexFinal;
} }
@ -180,7 +178,7 @@
hrmN = normalize(hrmN); hrmN = normalize(hrmN);
var roundedRate = parseFloat(hrmN).toFixed(2); var roundedRate = parseFloat(hrmN).toFixed(2);
hrmS = String.valueOf(roundedRate); //return String //hrmS = String.valueOf(roundedRate); //return String
//console.log("array----->" + msr); //console.log("array----->" + msr);
data[0] = roundedRate; data[0] = roundedRate;
@ -205,7 +203,7 @@
setInterval(function () { setInterval(function () {
stepS = String.valueOf(stepN); //return String //stepS = String.valueOf(stepN); //return String
data[1] = stepN; data[1] = stepN;
}, 2 * 1000); }, 2 * 1000);
@ -243,7 +241,6 @@
flip = 0; flip = 0;
//Bangle.buzz(1000); //Bangle.buzz(1000);
g.clear();
} else { //when on } else { //when on
flip = 1; flip = 1;
@ -283,7 +280,7 @@
com: data[4], com: data[4],
gps: data[5] gps: data[5]
}; };
/* g.clear(); /*
g.drawString(compssS,100,200); g.drawString(compssS,100,200);
*/ */

View File

@ -515,12 +515,6 @@ module.exports = {
"no-undef" "no-undef"
] ]
}, },
"apps/widbt_notify/widget.js": {
"hash": "16372ffcbc6bd1419ca326c7da40c2195f82a4bfceb6f123c15872624c4f0adf",
"rules": [
"no-undef"
]
},
"apps/widbgjs/widget.js": { "apps/widbgjs/widget.js": {
"hash": "9852ce9aafb0a1ca3029d497282c8cdf07438ea36a3323313bad5b7569b1081b", "hash": "9852ce9aafb0a1ca3029d497282c8cdf07438ea36a3323313bad5b7569b1081b",
"rules": [ "rules": [
@ -1157,12 +1151,6 @@ module.exports = {
"no-undef" "no-undef"
] ]
}, },
"apps/banglebridge/widget.js": {
"hash": "4ee8d6749e1d0e28c58ad871fd9f6ccbca2d716bb4fbd3511ba4c34a6a5897e1",
"rules": [
"no-undef"
]
},
"apps/bad/bad.app.js": { "apps/bad/bad.app.js": {
"hash": "d1354613102818190dd4e6e28fd715db7dc4d51b8e618cae61a3135529cc97eb", "hash": "d1354613102818190dd4e6e28fd715db7dc4d51b8e618cae61a3135529cc97eb",
"rules": [ "rules": [

View File

@ -17,3 +17,4 @@
Add option to disable vibration when charger connects Add option to disable vibration when charger connects
0.18: Only redraw when values change 0.18: Only redraw when values change
0.19: Match draw() API e.g. to allow wid_edit to alter this widget 0.19: Match draw() API e.g. to allow wid_edit to alter this widget
0.20: Remove clear of the screen on reload (will break currently running app)

View File

@ -2,7 +2,7 @@
"id": "widbatpc", "id": "widbatpc",
"name": "Battery Level Widget (with percentage)", "name": "Battery Level Widget (with percentage)",
"shortName": "Battery Widget", "shortName": "Battery Widget",
"version": "0.19", "version": "0.20",
"description": "Show the current battery level and charging status in the top right of the clock, with charge percentage", "description": "Show the current battery level and charging status in the top right of the clock, with charge percentage",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",

View File

@ -156,7 +156,6 @@
// need to redraw all widgets, because changing the "charger" setting // need to redraw all widgets, because changing the "charger" setting
// can affect the width and mess with the whole widget layout // can affect the width and mess with the whole widget layout
setWidth(); setWidth();
g.clear();
Bangle.drawWidgets(); Bangle.drawWidgets();
} }

View File

@ -348,11 +348,17 @@ apps.forEach((app,appIdx) => {
} }
} }
// something that needs to be evaluated with 'eval(require("Storage").read(fn))' // something that needs to be evaluated with 'eval(require("Storage").read(fn))'
if (/\.clkinfo?\.js$/.test(file.name) || if (/\.clkinfo\.js$/.test(file.name) ||
/\.settings?\.js$/.test(file.name)) { /\.settings\.js$/.test(file.name)) {
if (!fileContents.trim().endsWith(")")) if (!fileContents.trim().endsWith(")"))
WARN(`App ${app.id} file ${file.name} should be evaluated as a function but doesn't end in ')'`, {file:appDirRelative+file.url}); WARN(`App ${app.id} file ${file.name} should be evaluated as a function but doesn't end in ')'`, {file:appDirRelative+file.url});
} }
if (/\.clkinfo\.js$/.test(file.name) ||
/\.wid\.js$/.test(file.name)) {
if (fileContents.indexOf("g.clear(")>=0 ||
fileContents.indexOf("g.reset().clear()")>=0)
ERROR(`App ${app.id} widget/clkinfo ${file.name} should never totally clear the screen`, {file:appDirRelative+file.url});
}
} }
for (const key in file) { for (const key in file) {
if (!STORAGE_KEYS.includes(key)) ERROR(`App ${app.id} file ${file.name} has unknown key ${key}`, {file:appDirRelative+file.url}); if (!STORAGE_KEYS.includes(key)) ERROR(`App ${app.id} file ${file.name} has unknown key ${key}`, {file:appDirRelative+file.url});