pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

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

Open TheRaf974 opened this issue 1 year ago • 0 comments

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.

TheRaf974 avatar Feb 06 '24 22:02 TheRaf974