Merge pull request #3805 from bobrippling/fix/sched-clkinfo-trigger

sched: prevent timers from firing immediately
master
Gordon Williams 2025-04-29 09:26:35 +01:00 committed by GitHub
commit bd1d9b7875
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 5 deletions

View File

@ -55,4 +55,4 @@
to select an alarm in the main menu. to select an alarm in the main menu.
0.50: Bangle.js 2: Long touch of alarm in main menu toggle it on/off. Touching the icon on 0.50: Bangle.js 2: Long touch of alarm in main menu toggle it on/off. Touching the icon on
the right will do the same. the right will do the same.
0.51: Fix long-touch to enable alarm/timer not updating time (fix #3804) 0.51: Fix long-touch to enable alarm/timer not updating time (fix #3804)

View File

@ -87,11 +87,10 @@ function showMainMenu(scroll, group, scrollback) {
}; };
const getGroups = settings.showGroup && !group; const getGroups = settings.showGroup && !group;
const groups = getGroups ? {} : undefined; const groups = getGroups ? {} : undefined;
var showAlarm;
const getIcon = (e)=>{return e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff);}; const getIcon = (e)=>{return e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff);};
alarms.forEach((e, index) => { alarms.forEach((e, index) => {
showAlarm = !settings.showGroup || (group ? e.group === group : !e.group); const showAlarm = !settings.showGroup || (group ? e.group === group : !e.group);
if(showAlarm) { if(showAlarm) {
const label = trimLabel(getLabel(e),40); const label = trimLabel(getLabel(e),40);
menu[label] = { menu[label] = {

View File

@ -31,4 +31,5 @@
0.28: Added an icon for disabled events 0.28: Added an icon for disabled events
0.29: Improve clkinfo startup time by 10ms 0.29: Improve clkinfo startup time by 10ms
0.30: Fix possible bug in toggling an alarm to on, from clkinfo 0.30: Fix possible bug in toggling an alarm to on, from clkinfo
0.31: Ensure we reschedule alarms after setTimeZone has been called (fix #3791) 0.31: Ensure we reschedule alarms after setTimeZone has been called (fix #3791)
0.32: clkinfo ensures an alarm won't trigger immediately (copying `alarm`'s behaviour)

View File

@ -46,6 +46,9 @@ exports.resetTimer = function(alarm, time) {
time = time || new Date(); time = time || new Date();
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000); var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
alarm.t = (currentTime + alarm.timer) % 86400000; alarm.t = (currentTime + alarm.timer) % 86400000;
alarm.last = "timer" in alarm || alarm.t >= require("time_utils").getCurrentTimeMillis()
? 0
: new Date().getDate();
}; };
/// Get time until the given alarm (object). Return undefined if alarm not enabled, or if 86400000 or more, alarm could be *more* than a day in the future /// Get time until the given alarm (object). Return undefined if alarm not enabled, or if 86400000 or more, alarm could be *more* than a day in the future
exports.getTimeToAlarm = function(alarm, time) { exports.getTimeToAlarm = function(alarm, time) {

View File

@ -1,7 +1,7 @@
{ {
"id": "sched", "id": "sched",
"name": "Scheduler", "name": "Scheduler",
"version": "0.31", "version": "0.32",
"description": "Scheduling library for alarms and timers", "description": "Scheduling library for alarms and timers",
"icon": "app.png", "icon": "app.png",
"type": "scheduler", "type": "scheduler",