1
0
Fork 0

widclk 0.08: Ensure we clear the whole rect so we don't end up leaving old text when time changes (fix #3073)

master
Gordon Williams 2023-11-03 08:42:14 +00:00
parent b6e601b9a4
commit 319d22fab6
6 changed files with 8 additions and 7 deletions

View File

@ -4,3 +4,4 @@
0.05: Don't show clock widget if already showing clock app 0.05: Don't show clock widget if already showing clock app
0.06: Use 7 segment font, update *on* the minute, use less memory 0.06: Use 7 segment font, update *on* the minute, use less memory
0.07: allow turning on/off when quick-switching apps 0.07: allow turning on/off when quick-switching apps
0.08: Ensure we clear the whole rect so we don't end up leaving old text when time changes (fix #3073)

View File

@ -1,7 +1,7 @@
{ {
"id": "widclk", "id": "widclk",
"name": "Digital clock widget", "name": "Digital clock widget",
"version": "0.07", "version": "0.08",
"description": "A simple digital clock widget that appears when not showing a fullscreen clock", "description": "A simple digital clock widget that appears when not showing a fullscreen clock",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",

View File

@ -7,13 +7,13 @@ WIDGETS["wdclk"]={area:"tl",width:Bangle.CLOCK?0:52/* g.stringWidth("00:00") */,
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
} }
if (!this.width) return; // if not visible, return if (!this.width) return; // if not visible, return
g.reset().setFontCustom(atob("AAAAAAAAAAIAAAQCAQAAAd0BgMBdwAAAAAAAdwAB0RiMRcAAAERiMRdwAcAQCAQdwAcERiMRBwAd0RiMRBwAAEAgEAdwAd0RiMRdwAcERiMRdwAFAAd0QiEQdwAdwRCIRBwAd0BgMBAAABwRCIRdwAd0RiMRAAAd0QiEQAAAAAAAAAA="), 32, atob("BgAAAAAAAAAAAAAAAAYCAAYGBgYGBgYGBgYCAAAAAAAABgYGBgYG"), 512+9); g.reset().setFontCustom(atob("AAAAAAAAAAIAAAQCAQAAAd0BgMBdwAAAAAAAdwAB0RiMRcAAAERiMRdwAcAQCAQdwAcERiMRBwAd0RiMRBwAAEAgEAdwAd0RiMRdwAcERiMRdwAFAAd0QiEQdwAdwRCIRBwAd0BgMBAAABwRCIRdwAd0RiMRAAAd0QiEQAAAAAAAAAA="), 32, atob("BgAAAAAAAAAAAAAAAAYCAAYGBgYGBgYGBgYCAAAAAAAABgYGBgYG"), 512+9).setFontAlign(0,0);
var time = require("locale").time(new Date(),1); var time = require("locale").time(new Date(),1);
g.drawString(time, this.x, this.y+3, true); // 5 * 6*2 = 60 g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23).drawString(time, this.x+this.width/2, this.y+12); // 5 * 6*2 = 60
// queue draw in one minute // queue draw in one minute
if (this.drawTimeout) clearTimeout(this.drawTimeout); if (this.drawTimeout) clearTimeout(this.drawTimeout);
this.drawTimeout = setTimeout(()=>{ this.drawTimeout = setTimeout(()=>{
this.drawTimeout = undefined; this.drawTimeout = undefined;
this.draw(); this.draw();
}, 60000 - (Date.now() % 60000)); }, 60000 - (Date.now() % 60000));
}}; }};

View File

@ -3,4 +3,4 @@
0.03: based in widclk v0.05 compatible at same time, bottom area and color 0.03: based in widclk v0.05 compatible at same time, bottom area and color
0.04: refactored to use less memory, and allow turning on/off when quick-switching apps 0.04: refactored to use less memory, and allow turning on/off when quick-switching apps
0.05: Remove cyan color, use theme foreground instead 0.05: Remove cyan color, use theme foreground instead
0.06: Ensure we clear the whole rect so we don't end up leaving old text when time changes

View File

@ -2,7 +2,7 @@
"id": "widclkbttm", "id": "widclkbttm",
"name": "Digital clock (Bottom) widget", "name": "Digital clock (Bottom) widget",
"shortName": "Digital clock Bottom Widget", "shortName": "Digital clock Bottom Widget",
"version": "0.05", "version": "0.06",
"description": "Displays time HH:mm in the bottom of the screen (may not be compatible with some apps)", "description": "Displays time HH:mm in the bottom of the screen (may not be compatible with some apps)",
"icon": "widclkbttm.png", "icon": "widclkbttm.png",
"type": "widget", "type": "widget",

View File

@ -4,7 +4,7 @@ WIDGETS["wdclkbttm"]={area:"br",width:Bangle.CLOCK?0:60,draw:function() {
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
} }
if (!this.width) return; // if not visible, return if (!this.width) return; // if not visible, return
g.reset().setFont("6x8", 2).setFontAlign(-1, 0); g.reset().setFont("6x8", 2).setFontAlign(-1, 0).clearRect(this.x, this.y, this.x+this.width-1, this.y+23);
var time = require("locale").time(new Date(),1); var time = require("locale").time(new Date(),1);
g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60 g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60
// queue draw in one minute // queue draw in one minute