mirror of https://github.com/espruino/BangleApps
qmsched: add widget
parent
1d649a58fd
commit
b21d432cce
|
@ -3242,18 +3242,19 @@
|
|||
]
|
||||
},
|
||||
{ "id": "qmsched",
|
||||
"name": "Quiet Mode Schedule",
|
||||
"name": "Quiet Mode Schedule and Widget",
|
||||
"shortName":"Quiet Mode",
|
||||
"icon": "app.png",
|
||||
"version":"0.02",
|
||||
"description": "Automatically turn Quiet Mode on or off at set times",
|
||||
"readme": "README.md",
|
||||
"tags": "tool",
|
||||
"tags": "tool,widget",
|
||||
"storage": [
|
||||
{"name":"qmsched","url":"lib.js"},
|
||||
{"name":"qmsched.app.js","url":"app.js"},
|
||||
{"name":"qmsched.boot.js","url":"boot.js"},
|
||||
{"name":"qmsched.img","url":"icon.js","evaluate":true}
|
||||
{"name":"qmsched.img","url":"icon.js","evaluate":true},
|
||||
{"name":"qmsched.wid.js","url":"widget.js"}
|
||||
],
|
||||
"data": [
|
||||
{"name":"qmsched.json"}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
0.01: First version
|
||||
0.02: Simplify scheduling logic
|
||||
0.02: Add widget
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Quiet Mode Schedule
|
||||
# Quiet Mode Schedule and Widget
|
||||
|
||||
Automatically turn Quiet Mode on or off at set times.
|
||||
Automatically turn Quiet Mode on or off at set times, and display a widget when enabled.
|
||||
|
||||
### Edit Schedule:
|
||||
 
|
||||
|
||||
### Widget:
|
||||
 
|
||||
|
|
|
@ -14,4 +14,5 @@ exports.setMode = function(mode) {
|
|||
if (s.brightness && s.brightness!=1) Bangle.setLCDBrightness(s.brightness);
|
||||
}
|
||||
if (mode && s.qmTimeout) Bangle.setLCDTimeout(s.qmTimeout);
|
||||
if (typeof (WIDGETS)!=="undefined" && "qmsched" in WIDGETS) {WIDGETS["qmsched"].draw();}
|
||||
};
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
|
@ -0,0 +1,32 @@
|
|||
WIDGETS["qmsched"] = {
|
||||
area: "tl", width: 24, draw: function() {
|
||||
const mode = (require("Storage").readJSON("setting.json", 1) || {}).quiet|0;
|
||||
if (mode===0) { // Off
|
||||
if (this.width!==0) {
|
||||
this.width = 0;
|
||||
Bangle.drawWidgets();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// not Off: make sure width is correct
|
||||
if (this.width!==24) {
|
||||
this.width = 24;
|
||||
Bangle.drawWidgets();
|
||||
return; // drawWidgets will call draw again
|
||||
}
|
||||
let x = this.x, y = this.y;
|
||||
g.clearRect(x, y, x+23, y+23);
|
||||
// quiet mode: draw dim red one-way-street sign
|
||||
x = this.x+11;y = this.y+11; // center of widget
|
||||
g.setColor(0.8, 0, 0).fillCircle(x, y, 8);
|
||||
g.setColor(g.theme.bg).fillRect(x-6, y-2, x+6, y+2);
|
||||
if (mode>1) {return;} // no alarms
|
||||
// alarms still on: draw alarm icon in bottom-right corner
|
||||
x = this.x+18;y = this.y+17; // center of alarm
|
||||
g.setColor(1, 1, 0)
|
||||
.fillCircle(x, y, 3) // alarm body
|
||||
.fillRect(x-5, y+2, x+5, y+3) // bottom ridge
|
||||
.fillRect(x-1, y-5, x+1, y+5).drawLine(x, y-6, x, y+6) // top+bottom
|
||||
.drawLine(x+5, y-3, x+3, y-5).drawLine(x-5, y-3, x-3, y-5); // wriggles
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue