Skip to content

[widalarmeta] Add option to only show when on clock #3953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/widalarmeta/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
0.10: Change 4x5 font to 6x8, teletext is now default font
0.11: Bugfix: handle changes in alarms (e.g. done without a load, such as via fastload)
0.12: Redraw when screen turns on or watch is unlocked
0.13: Add option to only show when on clock
2 changes: 1 addition & 1 deletion apps/widalarmeta/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "widalarmeta",
"name": "Alarm & Timer ETA",
"shortName": "Alarm ETA",
"version": "0.12",
"version": "0.13",
"description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).",
"icon": "widget.png",
"type": "widget",
Expand Down
10 changes: 10 additions & 0 deletions apps/widalarmeta/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
padHours: true,
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
whenToShow: 0, // 0=always, 1=on clock only
}, require("Storage").readJSON(CONFIGFILE,1) || {});

function writeSettings() {
Expand Down Expand Up @@ -59,5 +60,14 @@
writeSettings();
}
},
/*LANG*/'When To Show': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to wanting this renamed to "Only on clock" or similar and then have it as a regular boolean setting with the standard checkbox formatting. Something to consider for a future update maybe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I wasn't sure if some future person might want a "Not On Clock", but didn't add that to avoid unused features.

value: settings.whenToShow,
min: 0, max: 1,
format: v => [/*LANG*/"Always", /*LANG*/"On Clock Only"][v === undefined ? 0 : v],
onchange: v => {
settings.whenToShow = v;
writeSettings();
}
},
});
})
9 changes: 9 additions & 0 deletions apps/widalarmeta/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
padHours: true,
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
whenToShow: 0, // 0=always, 1=on clock only
}, require("Storage").readJSON("widalarmeta.json",1) || {});

if (config.font == 0) {
Expand Down Expand Up @@ -38,6 +39,13 @@
} // getNextAlarm

function draw(_w, fromInterval) {

// If only show on clock and not on clock
if (config.whenToShow === 1 && !Bangle.CLOCK) {
this.nextAlarm = undefined; // make sure to reload later
return;
}

if (this.nextAlarm === undefined) {
let alarm = getNextAlarm();
if (alarm === undefined) {
Expand All @@ -55,6 +63,7 @@
let calcWidth = 0;
let drawSeconds = false;

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