Add a function that returns the remaining time before an alarm trigger #1628

Closed
opened 2024-02-06 16:14:09 -06:00 by TheRaf974 · 1 comment
TheRaf974 commented 2024-02-06 16:14:09 -06:00 (Migrated from github.com)

I'ld like to make a PR to add function that returns the remaining time before an alarm trigger.

I'm using an alarm to add a cooldown to an input button that'll be used by people. At the beginning, I was manually checking the difference of time with the last use of the button but it looked better to me to use a timer.

However, if someone press the button while in cooldown, I would like to let him know the time remaining before the button can be pressed effectively.

Looking in the RP2040 datasheet chapter 4.6.3, I found we can get the remaining time with something like :
timer_hw->alarm[alarm_pool] - timer_hw->timerawl

I think there might be situations where a function like this can be useful. Also, my code may needs somes adjustements.

I'ld like to make a PR to add function that returns the remaining time before an alarm trigger. I'm using an alarm to add a cooldown to an input button that'll be used by people. At the beginning, I was manually checking the difference of time with the last use of the button but it looked better to me to use a timer. However, if someone press the button while in cooldown, I would like to let him know the time remaining before the button can be pressed effectively. Looking in the [RP2040 datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf) chapter 4.6.3, I found we can get the remaining time with something like : `timer_hw->alarm[alarm_pool] - timer_hw->timerawl` I think there might be situations where a function like this can be useful. Also, my code may needs somes adjustements.
kilograham commented 2024-08-09 14:54:53 -05:00 (Migrated from github.com)

added

added
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1628
No description provided.