Skip to content

Commit c13b57a

Browse files
authored
Merge pull request #3953 from thinkpoop/master
[widalarmeta] Add option to only show when on clock
2 parents 6e66203 + 7fc8762 commit c13b57a

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

apps/widalarmeta/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
0.10: Change 4x5 font to 6x8, teletext is now default font
1515
0.11: Bugfix: handle changes in alarms (e.g. done without a load, such as via fastload)
1616
0.12: Redraw when screen turns on or watch is unlocked
17+
0.13: Add option to only show when on clock

apps/widalarmeta/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "widalarmeta",
33
"name": "Alarm & Timer ETA",
44
"shortName": "Alarm ETA",
5-
"version": "0.12",
5+
"version": "0.13",
66
"description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).",
77
"icon": "widget.png",
88
"type": "widget",

apps/widalarmeta/settings.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
padHours: true,
88
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
99
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
10+
whenToShow: 0, // 0=always, 1=on clock only
1011
}, require("Storage").readJSON(CONFIGFILE,1) || {});
1112

1213
function writeSettings() {
@@ -59,5 +60,14 @@
5960
writeSettings();
6061
}
6162
},
63+
/*LANG*/'When To Show': {
64+
value: settings.whenToShow,
65+
min: 0, max: 1,
66+
format: v => [/*LANG*/"Always", /*LANG*/"On Clock Only"][v === undefined ? 0 : v],
67+
onchange: v => {
68+
settings.whenToShow = v;
69+
writeSettings();
70+
}
71+
},
6272
});
6373
})

apps/widalarmeta/widget.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
padHours: true,
99
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
1010
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
11+
whenToShow: 0, // 0=always, 1=on clock only
1112
}, require("Storage").readJSON("widalarmeta.json",1) || {});
1213

1314
if (config.font == 0) {
@@ -38,6 +39,13 @@
3839
} // getNextAlarm
3940

4041
function draw(_w, fromInterval) {
42+
43+
// If only show on clock and not on clock
44+
if (config.whenToShow === 1 && !Bangle.CLOCK) {
45+
this.nextAlarm = undefined; // make sure to reload later
46+
return;
47+
}
48+
4149
if (this.nextAlarm === undefined) {
4250
let alarm = getNextAlarm();
4351
if (alarm === undefined) {
@@ -55,6 +63,7 @@
5563
let calcWidth = 0;
5664
let drawSeconds = false;
5765

66+
// Determine text and width
5867
if (next > 0 && next <= config.maxhours*60*60*1000) {
5968
const hours = Math.floor((next-1) / 3600000).toString();
6069
const minutes = Math.floor(((next-1) % 3600000) / 60000).toString();

0 commit comments

Comments
 (0)