mirror of https://github.com/espruino/BangleApps
app widget tiniy battery
parent
b6e6530724
commit
706a97a7b6
11
apps.json
11
apps.json
|
@ -888,5 +888,16 @@
|
|||
{"name":"barclock.app.js","url":"clock-bar.js"},
|
||||
{"name":"barclock.img","url":"clock-bar-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "widtbat",
|
||||
"name": "Tiny Battery Widget",
|
||||
"icon": "widget.png",
|
||||
"version":"0.01",
|
||||
"description": "Tiny blueish battery widget, vibs and changes level coler when charging",
|
||||
"tags": "widget,tool,system",
|
||||
"type":"widget",
|
||||
"storage": [
|
||||
{"name":"widtbat.wid.js","url":"widget.js"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
001 New widget
|
|
@ -0,0 +1,18 @@
|
|||
/* jshint esversion: 6 */
|
||||
(() => {
|
||||
const CBS = 0x41f, CBC = 0x07E0;
|
||||
var batS = require("heatshrink").decompress(atob("j0TwIHEv///kD////EfAYPwuEAgPB4EAg/HCgMfzgDBvwOC/IOC84ONDoUcFgc/AYOAHYRDE"));
|
||||
var xo = 6, xl = 22, yo = 9, h = 17;
|
||||
|
||||
function draw() {
|
||||
g.reset().setColor(CBS).drawImage(batS, this.x + 1, this.y + 4);
|
||||
g.setColor(0).fillRect(this.x + xo, this.y + yo, this.x + xl, this.y + h);
|
||||
var cbc = (Bangle.isCharging()) ? CBC : CBS;
|
||||
g.setColor(cbc).fillRect(this.x + xo, this.y + yo, this.x + (xl - xo) / 100 * E.getBattery() + xo, this.y + h);
|
||||
}
|
||||
Bangle.on('charging', function(charging) {
|
||||
if (charging) Bangle.buzz();
|
||||
Bangle.drawWidgets();
|
||||
});
|
||||
WIDGETS["widtbat"] = { area:"tr", width:32, draw: draw };
|
||||
})();
|
Binary file not shown.
After Width: | Height: | Size: 911 B |
Loading…
Reference in New Issue