0.04: Fix widget hiding code (fix #1046)

pull/1047/head
Gordon Williams 2021-12-09 15:56:58 +00:00
parent 61553056da
commit 52ed2c3b5d
5 changed files with 21 additions and 14 deletions

View File

@ -2642,12 +2642,12 @@
"id": "widviz", "id": "widviz",
"name": "Widget Visibility Widget", "name": "Widget Visibility Widget",
"shortName": "Viz Widget", "shortName": "Viz Widget",
"version": "0.02", "version": "0.03",
"description": "Swipe left to hide top bar widgets, swipe right to redisplay.", "description": "Swipe left to hide top bar widgets, swipe right to redisplay.",
"icon": "eye.png", "icon": "eye.png",
"type": "widget", "type": "widget",
"tags": "widget", "tags": "widget",
"supports": ["BANGLEJS"], "supports": ["BANGLEJS","BANGLESJ2"],
"storage": [ "storage": [
{"name":"widviz.wid.js","url":"widget.js"} {"name":"widviz.wid.js","url":"widget.js"}
] ]
@ -4670,7 +4670,7 @@
"id": "pebble", "id": "pebble",
"name": "Pebble Clock", "name": "Pebble Clock",
"shortName": "Pebble", "shortName": "Pebble",
"version": "0.03", "version": "0.04",
"description": "A pebble style clock to keep the rebellion going", "description": "A pebble style clock to keep the rebellion going",
"readme": "README.md", "readme": "README.md",
"icon": "pebble.png", "icon": "pebble.png",

View File

@ -1,3 +1,4 @@
0.01: first release 0.01: first release
0.02: included deployment of pebble.settings.js in apps.json 0.02: included deployment of pebble.settings.js in apps.json
0.03: Changed time+calendar font to LECO1976Regular, changed to slanting boot 0.03: Changed time+calendar font to LECO1976Regular, changed to slanting boot
0.04: Fix widget hiding code (fix #1046)

View File

@ -34,7 +34,7 @@ function draw() {
// turn the warning on once we have dipped below 30% // turn the warning on once we have dipped below 30%
if (E.getBattery() < 30) if (E.getBattery() < 30)
batteryWarning = true; batteryWarning = true;
// turn the warning off once we have dipped above 40% // turn the warning off once we have dipped above 40%
if (E.getBattery() > 40) if (E.getBattery() > 40)
batteryWarning = false; batteryWarning = false;
@ -57,7 +57,7 @@ function draw() {
g.setFontAlign(0, -1); g.setFontAlign(0, -1);
g.drawString(da[0].toUpperCase(), w/4, ha); // day of week g.drawString(da[0].toUpperCase(), w/4, ha); // day of week
g.drawString(getSteps(), 3*w/4, ha); g.drawString(getSteps(), 3*w/4, ha);
// time // time
// white on red for battery warning // white on red for battery warning
g.setColor(!batteryWarning ? g.theme.bg : '#f00'); g.setColor(!batteryWarning ? g.theme.bg : '#f00');
@ -71,7 +71,7 @@ function draw() {
// contrast bar // contrast bar
g.setColor(g.theme.fg); g.setColor(g.theme.fg);
g.fillRect(0, h3, w, h3 + t); g.fillRect(0, h3, w, h3 + t);
// the bottom // the bottom
g.setColor(settings.bg); g.setColor(settings.bg);
g.fillRect(0, h3 + t, w, h); g.fillRect(0, h3 + t, w, h);
@ -111,9 +111,10 @@ g.clear();
Bangle.loadWidgets(); Bangle.loadWidgets();
/* /*
* we are not drawing the widgets as we are taking over the whole screen * we are not drawing the widgets as we are taking over the whole screen
* so we will blank out the draw() functions of each widget * so we will blank out the draw() functions of each widget and change the
* area to the top bar doesn't get cleared.
*/ */
for (let wd of WIDGETS) {wd.draw=()=>{};} for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
loadSettings(); loadSettings();
setInterval(draw, 15000); // refresh every 15s setInterval(draw, 15000); // refresh every 15s
draw(); draw();

View File

@ -1,3 +1,3 @@
0.01: New Widget 0.01: New Widget
0.02: swipe left,right update 0.02: swipe left,right update
0.03: Fix widget visibility code to the top bar isn't cleared by drawWidgets

View File

@ -6,16 +6,21 @@
if (!Bangle.isLCDOn() || saved) return; if (!Bangle.isLCDOn() || saved) return;
saved = []; saved = [];
for (var wd of WIDGETS) { for (var wd of WIDGETS) {
saved.push(wd.draw); saved.push({d:wd.draw,a:wd.area});
wd.draw=()=>{}; wd.draw=()=>{};
wd.area="";
} }
g.setColor(0,0,0); g.setColor(0,0,0);
g.fillRect(0,0,239,23); g.fillRect(0,0,g.getWidth(),23);
} }
function reveal(){ function reveal(){
if (!Bangle.isLCDOn() || !saved) return; if (!Bangle.isLCDOn() || !saved) return;
for (var wd of WIDGETS) wd.draw = saved.shift(); for (var wd of WIDGETS) {
var o = saved.shift();
wd.draw = o.d;
wd.area = o.a;
}
Bangle.drawWidgets(); Bangle.drawWidgets();
saved=null; saved=null;
} }