arduino-timer icon indicating copy to clipboard operation
arduino-timer copied to clipboard

cannot generate timer events at "minutes"

Open allegfede opened this issue 4 years ago • 3 comments

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?

allegfede avatar Dec 12 '19 11:12 allegfede

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);

contrem avatar Dec 13 '19 08:12 contrem

thanks for the reply. I'll try asap.

On Fri, 13 Dec 2019 at 09:04, Michael Contreras [email protected] wrote:

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 https://en.cppreference.com/w/c/language/integer_constant.

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);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/contrem/arduino-timer/issues/8?email_source=notifications&email_token=AAK4JWQTEUEJ53QVM2O22WDQYM62RA5CNFSM4JZ5M42KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGZHFEQ#issuecomment-565342866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK4JWVCVSBFP5EVUSKKJ6DQYM62RANCNFSM4JZ5M42A .

-- Sourceforge: https://sourceforge.net/u/allegfede/

YouTube Channel: https://www.youtube.com/c/v1p3rslab

VIMEO HD videos: http://www.vimeo.com/user1912745/videos

allegfede avatar Dec 13 '19 11:12 allegfede

how to make function in void loop , timer.every (1000,repeat_x_times,10). and what is opaque= NULL.thanks very much

hartono837 avatar Jan 04 '20 16:01 hartono837