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
Fix Alarms #1555
Comments
TimerClock is my current clock and it implements its own alarm system unrelated to anything else. It doesn't appear to work with SleepPhaseAlarm, which I assume is designed to work with the default alarm app. A common API would be useful here! I've been making some changes to TimerClock (no PRs, yet). If I have time I might look into making it compatible with the default alarm app (or whatever SleepPhaseAlarm is trying to do), unless something happens here first! I think it would be a good idea if alarms required the ID of the app that creates them, so apps could query the global alarm list for 'their' alarms. |
Yes, SleepPhaseAlarm checks only the config alarm.json of the default alarm for enabled buzzers. |
Ok, great - please keep doing that as I'll use @andrewgoz great - yes, having an app ID would be great (I think #1513 did that too). And yes, making TimerClock use the built in alarm/timer system when done would be great |
There's now a branch for the new alarms at https://github.com/espruino/BangleApps/tree/new_alarm Maybe you could take a look and see if that does what you need? specifically @peerdavid and @andrewgoz I think it should be enough to do timers for clocks/etc 'Hard alarm' from Q Alarm should be ok to implement on top of this too - it'd just mean that to switch the 'hard' bit on/off you'd need to run the separate app at the moment |
Oh wow thank you so much -- I had a first look and the API seems perfect to me. I really love that we are able to set an ID. This weekend I will have some time - so I will integrate and test it into some of my clocks then I can give better feedback :) Thanks again, |
Great! It'd be good if you spot anything that's missing. Also any thoughts about things that can be done to make it less likely someone wants to fork the alarm app in future :) I tried to add the |
I just had a brief look but the new_alarm branch looks awesome. Here are my thoughts and ideas how to change/improve it even more to reduce the chances of a fork.
|
Thanks!
|
4.+5. Sounds reasonable, works for me. |
Just added vibration. Wrt name - Seems like an idea but why couldn't we just display 'msg' there instead of 'name'? I think maybe leave it for the moment - I don't want to get carried away adding stuff or we'll never actually get this bug-free and finished and merged in. It seems like if it's needed we could easily add It's not like the app can never change or be added to, and I don't intend to avoid forks by making the Alarm app do everything. Really, I just don't want to make any design decisions that mean people think they have to fork rather than contributing back to the main app. |
I had intended to comment a few days ago but what you've done covers almost everything I wanted to say anyway, I think. My opinions:
(and related to that final bullet point, if I am not mistaken exiting the alarm using the physical button rather than the on screen button can leave the widget showing even if it was timer/non-repeating and will never alarm again.) |
@gfwilliams I just tested the new alarm library in my fork: I updated the lcars, not analog and black&white clock and the simple timer app. I implemented the timers of the clocks such that its optional i.e. if alarm is not installed, then this functionality is simply not provided but the clock can still be used. For the simple timer I used it as a dependency in metadata as the app is useless otherwise. Overall I really like the API, it feels great that I don't have to re-implement the timer etc. Also everything that I need is provided and easy to use. I (probably) found two little bugs:
Thank you so much for doing this especially as I really failed to implement such library -- it really really helps a lot and reduces duplicated code for all my apps. David |
Could the alarm also handle being set on specific dates/times ? Or being recurrent ? |
I was wondering about this over the weekend. Specific dates would be useful, or days of months rather than days of week. Should the library be separated out of the default alarms app and be a more general scheduling library? Essentially a Bangle cron. What if the library, boot code and widget were one thing, with the alarm app separate? Putting a field in the file along the lines of "isAlarm" could control whether the alarm icon shows (you probably don't want to show it for every scheduled thing, only alarms and timers). |
Not entirely sure I understand - so if
Please could you paste up some example code? Is it possible the same ID was used? In which case the new timer would overwrite the old one?
Good point - I'd say being recurrent is probably a step too far (since then you're considering day/week/month/etc), but we could have an optional
Yes, I was wondering about that. It would definitely be nice to be able to replace the default alarm 'app' easily. Maybe just an app called
Yes, good idea. |
Ok, I've now refactored it into a new library called But in my opinion that's probably about ready. Any thoughts about things like Perhaps things like the Chrono widget we could actually just strip it right back, delete the app and turn it into a simple widget that displayed the time until the nearest alarm went off. |
Hi @gfwilliams thanks for your answer. Here are the steps to reproduce the problem -- I execute all 3 comments to simulate what happens if I add timer 1, add timer 2 and delete timer 2:
I would expect that "timer1" fires after 1 minute, but this never happens. Also I have seen that the icon (widgets) was no more shown after executing the last command. Here is an output of my json file as well as a screenshot of the bangle (no alarm icon): Let me know if I can do something else to help :) David |
Excellent, thanks! That's all I need I think - I'll check it out now |
Ok, I'm pretty sure it's sorted if not try now. What does everyone think - ok to merge? the actual error seems to be caused by the 'undefined' at the end:
That itself was a bug, but looks like Espruino's JSON.stringify didn't convert undefined->null as it is supposed to (just fixed that too), and that could have caused errors like this all over |
I still think there should be an I would also be inclined to slim it down to the essentials and let apps handle any additional data separately as I mentioned above - if apps start putting a lot into data {} it could get big. Isn't it better to have the bare minimum in sched? In terms of doing the scheduling, I think everything is covered. I think this will open up a lot of possibilities. |
@gfwilliams I just tested it on my watch and it works fine now. Thank you so much! |
Just added docs for this, but it doesn't need extra code. I really don't think adding a separate file per app is going to be a great idea. If someone's actually going to do something crazy then yes, they can do and store whatever they want in their app. But if someone just wants to store a number or two it's not going to matter. The vibration is something that's built in and I can totally see you might want to have different alarms with different vibration patterns so I think it makes a lot of sense to keep. Just merged this with master - seems good enough for now |
The current Alarm system is stupid. We now have:
They are all almost identical, but all of them have issues, none of them work together, and none sync with Gadgetbridge.
Plenty of apps also implement their own timers, which stop when the app is exited:
There are outstanding issues like:
And I've lost track of the hours I've spent trying to debug and maintain the 3 different alarm apps, which I could have spent making real improvements to a single app.
Also it'd be nice to have an API where other apps can query the alarm state, like #1513
So the plan is to:
The text was updated successfully, but these errors were encountered: