1
0
Fork 0
BangleApps/apps/sleeplogalarm/widget.js

32 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
var 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 zzz
2022-11-11 23:16:39 +00:00
g.reset().setColor(settings.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);
2022-11-10 15:52:35 +00:00
},
2022-11-11 23:16:39 +00:00
drawTime: () => {},
2022-11-11 16:17:07 +00:00
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 (this.drawTime) WIDGETS.sleeplogalarm.drawTime = function(time) {
// 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 + 12);
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
}