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

cannot generate timer events at "minutes" #8

Open
allegfede opened this issue Dec 12, 2019 · 3 comments
Open

cannot generate timer events at "minutes" #8

allegfede opened this issue Dec 12, 2019 · 3 comments
Labels
FAQ Frequently Asked Question support Help using the library

Comments

@allegfede
Copy link

Hi, i have to handle events that will occour in minutes (not milliseconds), but i noticed that using this code:

// in the global
auto play_time_timer = timer_create_default();

// in the setup
play_time_timer.in(play_time*1000, CT_win);

// in the loop
play_time_timer.tick();

// and the called procedure
bool CT_win(void *argument){
Serial.print("timer complete!");
return false;
}

works only if play_time if less than 33 seconds (so global delay less than 33000 milliseconds).

I suppose have to deal with the INT limit, but how i can make a minute counting timer?

@contrem
Copy link
Owner

contrem commented Dec 13, 2019

Make sure you're using the correct integer type for holding the values you expect to handle, and to qualify any constants with appropriate integer suffixes.

Use unsigned long for play_time and it should work. For more correctness, also qualify the 1000 constant with UL:

play_time_timer.in(play_time * 1000UL, CT_win);

@allegfede
Copy link
Author

allegfede commented Dec 13, 2019 via email

@contrem contrem added the support Help using the library label Dec 13, 2019
@contrem contrem added the FAQ Frequently Asked Question label Dec 27, 2019
@hartono837

This comment has been minimized.

Repository owner locked as resolved and limited conversation to collaborators Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FAQ Frequently Asked Question support Help using the library
Projects
None yet
Development

No branches or pull requests

3 participants