Skip to content
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

Alarm: Simplify alarm alerting screen (and fix bug with alerting on time value change) #2211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ljahn
Copy link

@ljahn ljahn commented Dec 28, 2024

Fixes #2206

When Alerting, the handlers for swiping and hard- and software buttons correctly deal with this.
The handler for time value changes did not.

Now a value change will also stop the alert.
For the scenario presented in #2206 (makeshift snooze), this means that after setting a new time, the new alarm also needs to be enabled again. However, I think this is not a problem, because the UI clearly presents that the alarm is disabled and it can be re-enabled exactly like setting an alarm always works.

Edit: Now fixing the problem by making the value change impossible in the first place by simplifying the alerting screen.

Copy link

github-actions bot commented Dec 28, 2024

Build size and comparison to main:

Section Size Difference
text 372880B 64B
data 948B 0B
bss 22536B 0B

@mark9064 mark9064 added enhancement Enhancement to an existing app/feature UI/UX User interface/User experience labels Dec 28, 2024
@mark9064
Copy link
Member

mark9064 commented Dec 28, 2024

Though I hate to break the makeshift snooze, I think it's the right way to go here as the UI should be consistent with disabling the alarm anytime the parameters are changed

Sorry I misread what this is doing. I think it's a bad idea to stop the alert on changing the time values, since those buttons are large and maybe too easily activated by the sensitive touch panel. Maybe it would be best to disable all buttons other than the stop button when ringing? It doesn't make too much sense to me what the semantics of changing the time on a ringing alarm are

I'd like to understand why it's currently broken though - did you manage to get to the bottom of this?

@ljahn
Copy link
Author

ljahn commented Dec 28, 2024

I think the reason is this:
SetAlerting creates an lv_task to automatically call StopAlerting after one minute. This task will call an invalid function reference and lead to a crash under the following condition:

All exit paths but the time value change (so not considering this fix) call StopAlerting themselves, which also terminates the lv_task. However, the value change callback only calls DisableAlarm, because its normal use case is for setting up an alarm, where you have to re-confirm enabling the alarm after every change you make. DisableAlarm still sets isAlerting in the alarmController to false, probably because someone thought a currently alerting but also disabled alarm makes no sense, this was introduced in a0cd439. That causes the destructor of Alarm to think there is nothing to do regarding the alerting when the alarm screen is dismissed. Therefore it does not call StopAlerting and the lv_task is left with an invalid function pointer, because Alarm does not exist anymore once the lv_task finally goes to call the callback function.

@ljahn
Copy link
Author

ljahn commented Dec 28, 2024

I also think we should do what you said and fully disable the time change buttons while the alarm is ringing. While we are at it, lets go one step further and disable all other buttons as well. The info button does not do anything useful in that situation anyway, it shows some meaningless value, and why should you be able to change the recurrence when you are not allowed to change the time. So in line with #2082, I would make the alarm disable screen have only one button, the Stop button.

I updated the PR to reflect this. This is what it looks like:
InfiniSim_2024-12-29_001905

Pressing the big red or the physical button brings you back to the normal alarm settings display and stops the alarm.

#2082 also calls for a snooze function, but this leads to additional questions that would warrant an own pull request and discussion.

@mark9064
Copy link
Member

Really nice analysis of the root cause, thanks for writing it up :)

The new UI looks good to me, agree that snooze can go in a separate PR (and the stop button could easily be half width with snooze for the other half, so that should work)

Code at a glance looks sensible, I should be able to review it properly soon

@mark9064 mark9064 added this to the 1.16.0 milestone Dec 30, 2024
@ljahn ljahn changed the title Fix: Alarm stop alerting on time value chage Alarm: Simplify alarm alerting screen (and fix bug with alerting on time value change) Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to an existing app/feature UI/UX User interface/User experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting time while alarm is going off reboots watch upon new alarm going off
2 participants