mirror of https://github.com/espruino/BangleApps
widclk/close/etc - allow turning on/off when quick-switching apps
f6b38b3443 (r88164680)
pull/2209/head
parent
a42b79a7c7
commit
ac6f7b1521
|
@ -3,3 +3,4 @@
|
|||
0.04: Fix regression stopping correct widget updates
|
||||
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.07: allow turning on/off when quick-switching apps
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widclk",
|
||||
"name": "Digital clock widget",
|
||||
"version": "0.06",
|
||||
"version": "0.07",
|
||||
"description": "A simple digital clock widget",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
/* Simple clock that appears in the widget bar if no other clock
|
||||
is running. We update once per minute, but don't bother stopping
|
||||
if the */
|
||||
|
||||
// don't show widget if we know we have a clock app running
|
||||
if (!Bangle.CLOCK) WIDGETS["wdclk"]={area:"tl",width:52/* g.stringWidth("00:00") */,draw:function() {
|
||||
g.reset().setFontCustom(atob("AAAAAAAAAAIAAAQCAQAAAd0BgMBdwAAAAAAAdwAB0RiMRcAAAERiMRdwAcAQCAQdwAcERiMRBwAd0RiMRBwAAEAgEAdwAd0RiMRdwAcERiMRdwAFAAd0QiEQdwAdwRCIRBwAd0BgMBAAABwRCIRdwAd0RiMRAAAd0QiEQAAAAAAAAAA="), 32, atob("BgAAAAAAAAAAAAAAAAYCAAYGBgYGBgYGBgYCAAAAAAAABgYGBgYG"), 512+9);
|
||||
WIDGETS["wdclk"]={area:"tl",width:Bangle.CLOCK?0:52/* g.stringWidth("00:00") */,draw:function() {
|
||||
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
|
||||
this.width = Bangle.CLOCK?0:52;
|
||||
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
|
||||
}
|
||||
if (!this.width) return; // if size not right, return
|
||||
g.reset().setFontCustom(atob("AAAAAAAAAAIAAAQCAQAAAd0BgMBdwAAAAAAAdwAB0RiMRcAAAERiMRdwAcAQCAQdwAcERiMRBwAd0RiMRBwAAEAgEAdwAd0RiMRdwAcERiMRdwAFAAd0QiEQdwAdwRCIRBwAd0BgMBAAABwRCIRdwAd0RiMRAAAd0QiEQAAAAAAAAAA="), 32, atob("BgAAAAAAAAAAAAAAAAYCAAYGBgYGBgYGBgYCAAAAAAAABgYGBgYG"), 512+9);
|
||||
var time = require("locale").time(new Date(),1);
|
||||
g.drawString(time, this.x, this.y+3, true); // 5 * 6*2 = 60
|
||||
// queue draw in one minute
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
0.01: Fork of widclk v0.04 github.com/espruino/BangleApps/tree/master/apps/widclk
|
||||
0.02: Modification for bottom widget area and text 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
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"id": "widclkbttm",
|
||||
"name": "Digital clock (Bottom) widget",
|
||||
"shortName": "Digital clock Bottom Widget",
|
||||
"version": "0.03",
|
||||
"description": "Displays time in the bottom area.",
|
||||
"version": "0.04",
|
||||
"description": "Displays time in the bottom of the screen (may not be compatible with some apps)",
|
||||
"icon": "widclkbttm.png",
|
||||
"type": "widget",
|
||||
"tags": "widget",
|
||||
|
|
|
@ -1,31 +1,16 @@
|
|||
(function() {
|
||||
// don't show widget if we know we have a clock app running
|
||||
if (Bangle.CLOCK) return;
|
||||
|
||||
let intervalRef = null;
|
||||
var width = 5 * 6*2;
|
||||
var text_color=0x07FF;//cyan
|
||||
|
||||
function draw() {
|
||||
g.reset().setFont("6x8", 2).setFontAlign(-1, 0).setColor(text_color);
|
||||
var time = require("locale").time(new Date(),1);
|
||||
g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60
|
||||
WIDGETS["wdclkbttm"]={area:"br",width:Bangle.CLOCK?0:60,draw:function() {
|
||||
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
|
||||
this.width = Bangle.CLOCK?0:60;
|
||||
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
|
||||
}
|
||||
function clearTimers(){
|
||||
if(intervalRef) {
|
||||
clearInterval(intervalRef);
|
||||
intervalRef = null;
|
||||
}
|
||||
}
|
||||
function startTimers(){
|
||||
intervalRef = setInterval(()=>WIDGETS["wdclkbttm"].draw(), 60*1000);
|
||||
WIDGETS["wdclkbttm"].draw();
|
||||
}
|
||||
Bangle.on('lcdPower', (on) => {
|
||||
clearTimers();
|
||||
if (on) startTimers();
|
||||
});
|
||||
|
||||
WIDGETS["wdclkbttm"]={area:"br",width:width,draw:draw};
|
||||
if (Bangle.isLCDOn) intervalRef = setInterval(()=>WIDGETS["wdclkbttm"].draw(), 60*1000);
|
||||
})()
|
||||
if (!this.width) return; // if size not right, return
|
||||
g.reset().setFont("6x8", 2).setFontAlign(-1, 0).setColor("#0ff"); // cyan
|
||||
var time = require("locale").time(new Date(),1);
|
||||
g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60
|
||||
// queue draw in one minute
|
||||
if (this.drawTimeout) clearTimeout(this.drawTimeout);
|
||||
this.drawTimeout = setTimeout(()=>{
|
||||
this.drawTimeout = undefined;
|
||||
this.draw();
|
||||
}, 60000 - (Date.now() % 60000));
|
||||
}};
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New widget!
|
||||
0.01: New widget!
|
||||
0.02: allow turning on/off when quick-switching apps
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widclose",
|
||||
"name": "Close Button",
|
||||
"version": "0.01",
|
||||
"version": "0.02",
|
||||
"description": "A button to close the current app",
|
||||
"readme": "README.md",
|
||||
"icon": "icon.png",
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
if (!Bangle.CLOCK) WIDGETS.close = {
|
||||
area: "tr", width: 24, sortorder: 10, // we want the right-most spot please
|
||||
WIDGETS.close = {
|
||||
area: "tr", width: Bangle.CLOCK?0:24, sortorder: 10, // we want the right-most spot please
|
||||
draw: function() {
|
||||
Bangle.removeListener("touch", this.touch);
|
||||
Bangle.on("touch", this.touch);
|
||||
g.reset().setColor("#f00").drawImage(atob( // hardcoded red to match setUI back button
|
||||
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
|
||||
this.width = Bangle.CLOCK?0:24;
|
||||
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
|
||||
}
|
||||
if (this.width) g.reset().setColor("#f00").drawImage(atob( // red to match setUI back button
|
||||
// b/w version of preview.png, 24x24
|
||||
"GBgBABgAAf+AB//gD//wH//4P//8P//8fn5+fjx+fxj+f4H+/8P//8P/f4H+fxj+fjx+fn5+P//8P//8H//4D//wB//gAf+AABgA"
|
||||
), this.x, this.y);
|
||||
}, touch: function(_, c) {
|
||||
const w = WIDGETS.close;
|
||||
if (w && c.x>=w.x && c.x<=w.x+24 && c.y>=w.y && c.y<=w.y+24) load();
|
||||
}, touch: function(_, c) { // if touched
|
||||
const w = WIDGETS.close; // if in range, go back to the clock
|
||||
if (w && c.x>=w.x && c.x<w.x+w.width && c.y>=w.y && c.y<=w.y+24) load();
|
||||
}
|
||||
};
|
||||
};
|
||||
Bangle.on("touch", WIDGETS.close.touch);
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New widget!
|
||||
0.01: New widget!
|
||||
0.02: allow turning on/off when quick-switching apps
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widcloselaunch",
|
||||
"name": "Close Button to launcher",
|
||||
"version": "0.01",
|
||||
"version": "0.02",
|
||||
"description": "A button to close the current app and go to launcher",
|
||||
"readme": "README.md",
|
||||
"icon": "icon.png",
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
if (!Bangle.CLOCK) WIDGETS.close = {
|
||||
area: "tr", width: 24, sortorder: 10, // we want the right-most spot please
|
||||
WIDGETS.close = {
|
||||
area: "tr", width: Bangle.CLOCK?0:24, sortorder: 10, // we want the right-most spot please
|
||||
draw: function() {
|
||||
Bangle.removeListener("touch", this.touch);
|
||||
Bangle.on("touch", this.touch);
|
||||
g.reset().setColor("#f00").drawImage(atob( // hardcoded red to match setUI back button
|
||||
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
|
||||
this.width = Bangle.CLOCK?0:24;
|
||||
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
|
||||
}
|
||||
if (this.width) g.reset().setColor("#f00").drawImage(atob( // red to match setUI back button
|
||||
// b/w version of preview.png, 24x24
|
||||
"GBgBABgAAf+AB//gD//wH//4P//8P//8fn5+fjx+fxj+f4H+/8P//8P/f4H+fxj+fjx+fn5+P//8P//8H//4D//wB//gAf+AABgA"
|
||||
), this.x, this.y);
|
||||
}, touch: function(_, c) {
|
||||
const w = WIDGETS.close;
|
||||
if (w && c.x>=w.x && c.x<=w.x+24 && c.y>=w.y && c.y<=w.y+24) Bangle.showLauncher();
|
||||
if (w && c.x>=w.x && c.x<w.x+w.width && c.y>=w.y && c.y<=w.y+24) Bangle.showLauncher();
|
||||
}
|
||||
};
|
||||
Bangle.on("touch", WIDGETS.close.touch);
|
||||
|
|
Loading…
Reference in New Issue