brunocalou / timer Goto Github PK
View Code? Open in Web Editor NEWArduino timer library
License: MIT License
Arduino timer library
License: MIT License
in Timer::update repeat_count decrements from -1 until it overflows and hits zero, stopping the counter. The fix would be to add if(repeat_count > 0) repeat_count -= 1
warning: overflow in implicit constant conversion [-Woverflow]
Hello Bruno,
First I have to thank you for the library, it is helping me a lot to learn C++ basic with Arduino. I have a question regarding management of multiple timers, as I am unable to understand how does it work.
Here is a scenario:
We have 5 timers, like in your multi-timer example and I want to handle them independently (like start/stop/pause) in two groups, like first 3 and last 2. I know how this can be managed individually one by one, but as you have provided TimerManager class I would like to have that “nice” solution. I have tried numbers of options, but, as I am lacking knowledge of a professional, was unable to achieve anything but constant compile errors (mostly “Compilation error: expected primary-expression before '*' token” after trying with i.e. “TimerManager::instance().add(Timer *timer5);”).
Or, maybe approach is to add/remove timers to one single group and then to start/stop/pause them? Whatever it is, I have no idea how to setup a code to manage that…
Can you help with an advice/example for this scenario?
Thank you in advance,
Vidoje.
Hello Bruno,
Congratulations on the great library! I'm using it for a personal home automation project.
Can you tell us if the code was tested for millis() rollover? How does it behaves after 9h and 32min? I haven't detected any issues so far, but my setup is not sensitive enough to detect a single timer being skipped or firing ahead of time.
If you are already dealing with the rollover, it would be nice if you specified that in the documentation.
Also, do you have plans to release a version with a flag so the times can be specified in microseconds?
Thanks!
Hi,
Great tool! thank you for sharing.
Is it possible to use microseconds instead milliseconds? If yes, how to?
Is it OK: Test.setInterval(0.1); if I want an interval of 100usec?
In the documentation for the Timer
class, you note that void stop()
pauses the timer, whereas void pause()
resets the timer.
Are these function descriptions the wrong way around? Although, documentation for a function called stop
which says "the timer will not stop" is also confusing.
Is a call to stop()
then start()
effective as a reset?
Hi,
I get the following error while compiling for a Nano 33:
Blink:12:1: error: 'Timer' does not name a type; did you mean 'time'? Timer timer;
The lib is under Arduino/libraries/Timer
Any suggestion please?
Thanks
Hi Bruno
I really like this library of yours and will be using it as part of my Universal Timer project very shortly. I did notice (but am not surprised) that the callback function does not allow parameters to be supplied to the callback function - I have to write a wrapper that then supplies the parameters.
Is there any way that you could allow a construct such as:
timer.setCallback(1000, myFunctionHere(24, 85.1, "GO", true);
Or is this more a restriction of C++. I have to admit I have not inspected your code as I'm tied up creating the YouTube video for the Universal Timer project right now! Very lazy of me, I know.
Anyway, if there is a way of doing the above do let me know (I don't mind forking the code) and thanks again for a great library. Tudo bem!
Ralph Bacon
www.youtube.com/ralphbacon
I'd like to use this but see no mention of ESP32. From what I've seen it uses the generic millis so hopefully..
I added it to the libraries as instructed - but don't see it appearing in the list when using library manager .
I don't understand how to write the code to delay in hour or minute :(
Hi Bruno,
I'm having an issue where the error is "Including this file is deprecated. Please #include <arduino-timer.h> instead." Does this mean there is no longer support for this timer? I've written my code to suit using your library as it worked perfectly with my code before but now sadly its not. I'm using the same code where it worked previously but now on an ESP32 is that the issue.
Many thanks for your time.
The repeat_count and total_repeat_count members are supposed to be able to hold the value "-1" to denote repeating forever. But unfortunately these members (and the final arg of setInterval) are declared unsigned, which does not work with current compilers (tested on a Mega board). Changing these to plain int makes it work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.