BangleApps/apps/sleeplogalarm/widget.js

35 lines
1.2 KiB
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) {
2022-11-11 23:16:39 +00:00
// read settings
2023-05-29 21:52:46 +00:00
let settings = require("sleeplogalarm").getSettings();
// insert neccessary settings into widget
WIDGETS.sleeplogalarm = {
area: "tl",
width: 0,
2022-11-11 16:17:07 +00:00
time: 0,
earlier: settings.earlier,
2022-11-10 15:52:35 +00:00
draw: function () {
// draw if width is set
if (this.width) {
// draw zzz
g.reset().setColor(settings.wid.color).drawImage(atob("BwoBD8SSSP4EEEDg"), this.x + 1, this.y);
// call function to draw the time of alarm if a alarm is found
if (this.time) this.drawTime(this.time + 1);
}
2022-11-10 15:52:35 +00:00
},
2022-11-11 23:16:39 +00:00
drawTime: () => {},
reload: require("sleeplogalarm").widReload
};
2022-11-10 15:52:35 +00:00
2022-11-11 23:16:39 +00:00
// add function to draw the time of alarm if enabled
if (settings.wid.time) WIDGETS.sleeplogalarm.drawTime = function(time) {
2022-11-11 23:16:39 +00:00
// directly include Font4x5Numeric
g.setFontCustom(atob("CAZMA/H4PgvXoK1+DhPg7W4P1uCEPg/X4O1+AA=="), 46, atob("AgQEAgQEBAQEBAQE"), 5).setFontAlign(1, 1);
g.drawString(0|(time / 36E5), this.x + this.width + 1, this.y + 17);
2022-11-11 23:16:39 +00:00
g.drawString(0|((time / 36E5)%1 * 60), this.x + this.width + 1, this.y + 23);
};
2022-11-10 15:52:35 +00:00
// load widget
WIDGETS.sleeplogalarm.reload();
2022-11-10 16:06:35 +00:00
}