BangleApps/apps/sleeplogalarm/widget.js

28 lines
1020 B
JavaScript
Raw Normal View History

2022-11-10 15:52:35 +00:00
// check if enabled in settings
2022-11-11 16:17:07 +00:00
if ((require("Storage").readJSON("sleeplogalarm.settings.json", true) || {enabled: true}).enabled) {
// insert neccessary settings into widget
WIDGETS.sleeplogalarm = {
area: "tl",
width: 0,
2022-11-11 16:17:07 +00:00
drawTime: settings.drawTime,
color: settings.color,
2022-11-11 16:17:07 +00:00
time: 0,
earlier: settings.earlier,
2022-11-10 15:52:35 +00:00
draw: function () {
// draw zzz
g.reset().setColor(this.color).drawImage(atob("BwoBD8SSSP4EEEDg"), this.x + 1, this.y);
2022-11-11 16:17:07 +00:00
// draw time of alarm if enabled
if (this.drawTime && this.time) {
// directly include Font4x5Numeric
2022-11-11 16:17:07 +00:00
g.setFontCustom(atob("CAZMA/H4PgvXoK1+DhPg7W4P1uCEPg/X4O1+AA=="), 46, atob("AgQEAgQEBAQEBAQE"), 5).setFontAlign(1, 1);
g.drawString(0|(this.time / 36E5), this.x + this.width + 1, this.y + 12);
g.drawString(0|((this.time / 36E5)%1 * 60), this.x + this.width + 1, this.y + 23);
}
2022-11-10 15:52:35 +00:00
},
2022-11-11 16:17:07 +00:00
reload: require("sleeplogalarm").widReload()
};
2022-11-10 15:52:35 +00:00
// load widget
WIDGETS.sleeplogalarm.reload();
2022-11-10 16:06:35 +00:00
}