From f0c9ae183c8f65ab62934af71f897a3017414636 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 28 Oct 2024 17:27:31 +0000 Subject: [PATCH] Add check for widgets that clear the screen! Remove clear of the screen on reload (will break currently running app) --- apps/banglebridge/ChangeLog | 1 + apps/banglebridge/metadata.json | 4 ++-- apps/banglebridge/widget.js | 35 +++++++++++++++------------------ apps/lint_exemptions.js | 12 ----------- apps/widbatpc/ChangeLog | 1 + apps/widbatpc/metadata.json | 2 +- apps/widbatpc/widget.js | 1 - bin/sanitycheck.js | 10 ++++++++-- 8 files changed, 29 insertions(+), 37 deletions(-) diff --git a/apps/banglebridge/ChangeLog b/apps/banglebridge/ChangeLog index 62542be60..a4b22db22 100644 --- a/apps/banglebridge/ChangeLog +++ b/apps/banglebridge/ChangeLog @@ -1,2 +1,3 @@ 0.01: New app! 0.02: Minor code improvements +0.03: Remove clearing of the screen (will break running apps) and fix lint errors \ No newline at end of file diff --git a/apps/banglebridge/metadata.json b/apps/banglebridge/metadata.json index 86e1face0..1dbb2e1de 100644 --- a/apps/banglebridge/metadata.json +++ b/apps/banglebridge/metadata.json @@ -2,8 +2,8 @@ "id": "banglebridge", "name": "BangleBridge", "shortName": "BangleBridge", - "version": "0.02", - "description": "Widget that allows Bangle Js to record pair and end data using Bluetooth Low Energy in combination with the BangleBridge Android App", + "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 (**Note:** this has nothing to do with Gadgetbridge)", "icon": "widget.png", "type": "widget", "tags": "widget", diff --git a/apps/banglebridge/widget.js b/apps/banglebridge/widget.js index 692822b39..c805b0f39 100644 --- a/apps/banglebridge/widget.js +++ b/apps/banglebridge/widget.js @@ -1,10 +1,10 @@ (() => { /** * Widget measurements - * Description: + * Description: * name: connection.wid.js *icon: conectionIcon.icon - * + * */ //Font @@ -24,7 +24,7 @@ //Sensors code /** - * + * * @author Jorge */ function accel() { @@ -35,8 +35,7 @@ }); 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; }, 2 * 1000); @@ -45,8 +44,7 @@ function btt() { setInterval(function () { - - bttS = E.getBattery(); //return String + //bttS = E.getBattery(); //return String data[2] = E.getBattery(); }, 15 * 1000); @@ -65,9 +63,9 @@ 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" + - "C: " + compssN.heading; //return String + "C: " + compssN.heading; *///return String data[4] = compssN; }, 2 * 1000); @@ -86,8 +84,8 @@ setInterval(function () { - gpsS = "A: " + gpsN.lat + " ## " + gpsN.lon + " ## " + gpsN.alt + "\n" + "B: " + gpsN.speed + " ## " + gpsN.course + " ## " + gpsN.time + "\n" + - "C: " + gpsN.satellites + " ## " + gpsN.fix; //return String + /*gpsS = "A: " + gpsN.lat + " ## " + gpsN.lon + " ## " + gpsN.alt + "\n" + "B: " + gpsN.speed + " ## " + gpsN.course + " ## " + gpsN.time + "\n" + + "C: " + gpsN.satellites + " ## " + gpsN.fix; *///return String // work out how to display the current time var d = new Date(); var year = d.getFullYear(); @@ -150,7 +148,7 @@ //console.log("Index ==> "+ index); msr[indexFinal] = nueva; - item = nueva; + //item = nueva; lastInsert = indexFinal; } @@ -180,7 +178,7 @@ hrmN = normalize(hrmN); var roundedRate = parseFloat(hrmN).toFixed(2); - hrmS = String.valueOf(roundedRate); //return String + //hrmS = String.valueOf(roundedRate); //return String //console.log("array----->" + msr); data[0] = roundedRate; @@ -205,7 +203,7 @@ setInterval(function () { - stepS = String.valueOf(stepN); //return String + //stepS = String.valueOf(stepN); //return String data[1] = stepN; }, 2 * 1000); @@ -240,12 +238,11 @@ g.setFont("Vector", 45); g.drawString(prueba,100,200);*/ if (flip == 1) { //when off - + flip = 0; //Bangle.buzz(1000); - g.clear(); } else { //when on - + flip = 1; g.setFont("Vector", 30); g.drawString(data[0], 65, 180); @@ -283,7 +280,7 @@ com: data[4], gps: data[5] }; - /* g.clear(); + /* g.drawString(compssS,100,200); */ @@ -293,7 +290,7 @@ //draw(); }, 5 * 1000); - + WIDGETS["banglebridge"]={ area: "tl", width: 10, diff --git a/apps/lint_exemptions.js b/apps/lint_exemptions.js index b5c6bc640..3bcbf6fd3 100644 --- a/apps/lint_exemptions.js +++ b/apps/lint_exemptions.js @@ -515,12 +515,6 @@ module.exports = { "no-undef" ] }, - "apps/widbt_notify/widget.js": { - "hash": "16372ffcbc6bd1419ca326c7da40c2195f82a4bfceb6f123c15872624c4f0adf", - "rules": [ - "no-undef" - ] - }, "apps/widbgjs/widget.js": { "hash": "9852ce9aafb0a1ca3029d497282c8cdf07438ea36a3323313bad5b7569b1081b", "rules": [ @@ -1157,12 +1151,6 @@ module.exports = { "no-undef" ] }, - "apps/banglebridge/widget.js": { - "hash": "4ee8d6749e1d0e28c58ad871fd9f6ccbca2d716bb4fbd3511ba4c34a6a5897e1", - "rules": [ - "no-undef" - ] - }, "apps/bad/bad.app.js": { "hash": "d1354613102818190dd4e6e28fd715db7dc4d51b8e618cae61a3135529cc97eb", "rules": [ diff --git a/apps/widbatpc/ChangeLog b/apps/widbatpc/ChangeLog index e9326fd2c..34873124c 100644 --- a/apps/widbatpc/ChangeLog +++ b/apps/widbatpc/ChangeLog @@ -17,3 +17,4 @@ Add option to disable vibration when charger connects 0.18: Only redraw when values change 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) \ No newline at end of file diff --git a/apps/widbatpc/metadata.json b/apps/widbatpc/metadata.json index 4c364a864..5e160b5d4 100644 --- a/apps/widbatpc/metadata.json +++ b/apps/widbatpc/metadata.json @@ -2,7 +2,7 @@ "id": "widbatpc", "name": "Battery Level Widget (with percentage)", "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", "icon": "widget.png", "type": "widget", diff --git a/apps/widbatpc/widget.js b/apps/widbatpc/widget.js index 7ba060d6d..163c0f541 100644 --- a/apps/widbatpc/widget.js +++ b/apps/widbatpc/widget.js @@ -156,7 +156,6 @@ // need to redraw all widgets, because changing the "charger" setting // can affect the width and mess with the whole widget layout setWidth(); - g.clear(); Bangle.drawWidgets(); } diff --git a/bin/sanitycheck.js b/bin/sanitycheck.js index ec2644f6b..b2332b16f 100755 --- a/bin/sanitycheck.js +++ b/bin/sanitycheck.js @@ -348,11 +348,17 @@ apps.forEach((app,appIdx) => { } } // something that needs to be evaluated with 'eval(require("Storage").read(fn))' - if (/\.clkinfo?\.js$/.test(file.name) || - /\.settings?\.js$/.test(file.name)) { + if (/\.clkinfo\.js$/.test(file.name) || + /\.settings\.js$/.test(file.name)) { 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}); } + 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) { if (!STORAGE_KEYS.includes(key)) ERROR(`App ${app.id} file ${file.name} has unknown key ${key}`, {file:appDirRelative+file.url});