Skip to content

[alarm/sched] Timer doesn't fire (or fires immediately) when enabling from list #3804

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

Open
Blockguy24 opened this issue Apr 17, 2025 · 3 comments · May be fixed by #3805
Open

[alarm/sched] Timer doesn't fire (or fires immediately) when enabling from list #3804

Blockguy24 opened this issue Apr 17, 2025 · 3 comments · May be fixed by #3805
Labels

Comments

@Blockguy24
Copy link

Affected hardware version

Bangle 2

Your firmware version

2v25

The bug

Description

On the Bangle.js 2, a timer can be quickly enabled by pressing its icon or long pressing the item in the list. However, this causes some unexpected behaviour. Most of the time the timer never fires, but sometimes it fires immediately after enabling it this way.

Expected Behaviour

Enabling the timer via this shortcut should have the same effect as opening its menu and setting it to be Enabled.

Suspected cause

When enabling via the main menu, neither prepareTimerForSave (or prepareAlarmForSave for alarms) is called, so an old expiration time is used for the timer instead of it being updated when it is enabled.

Installed apps

  • alarm (0.50)
  • sched (0.31)
  • boot (0.65)
@bobrippling bobrippling linked a pull request Apr 17, 2025 that will close this issue
@bobrippling
Copy link
Collaborator

Seems to me like the fix would be to replicate this code (in alarm):

timer.t = (require("time_utils").getCurrentTimeMillis() + timer.timer) % 86400000;
timer.last = 0;

into the clkinfo, or more specifically, into sched's resetTimer():

/// Set a timer's firing time based off the timer's `timer` property + the given time (or now)
exports.resetTimer = function(alarm, time) {
time = time || new Date();
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
alarm.t = (currentTime + alarm.timer) % 86400000;
};

Essentially setting alarm.last = 0 (with a few tweaks).

Does #3805 resolve it for you? I can deploy the code if that'd help, I just have another deployment in use for #3803 atm.

@Blockguy24
Copy link
Author

I tried the update but it didn't really change much, the timer will still either not fire or fire immediately

@bobrippling
Copy link
Collaborator

Thanks - that mustn't be the bug, although I think you're right that it's related to .last

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants