This new(?) TeensyTimerTool message thread has been very helpful...
I (C++ noob) and helping my friend (C noob) with writing control software on a Teensy3.5 to implement a custom hardware solution.
We have been trying to use TeensyTimerTool.
Due to needing delays of upto a few minutes we have used the TCK64 timer type.
I have looked at the source code in the library, but admit to being confused. I have also looked at the wiki web pages.
Apologies, but I didn't see any clear reference to these "special" time units that can be used (100us etc.).
In this thread I came across "You can use ns, us, ms, s, min, h" which answers my question, however I would suggest that someone who is able updates the wiki to add this very useful information.
The timer functions have been put in a cpp called "timer.cpp". I mention this as some code which compiles in the ".ino" does not compile in a ".cpp" because I think of missing #includes.
We want to use a set of One Shot timers.
I apologise because I am confused. The examples are trivial cases which don't quite match our need to call a one shot timer many times during execution of the code.
So do I declare all our one shot timers in the setup() *once* using begin?
The examples appear to show "begin()" repeated several times on the same timer. If a timer expires do you have to do a new "begin()".
To trigger one I use mytimer.trigger(time)?
To re-trigger a timer, do I call "trigger()" again or do I need to call another "begin()"?
To stop an oneshot timer I can use mytimer.stop()?
We need to do this if a higher priority event occurs. I think I read that stop() is a fairly new function. I did search for this function, but my C++ is too poor to help my understand where to look. Again in the wiki I think that stop() and any other functions (wrong term I know) for OneShotTimer's are not yet documented. Apologies if I am wrong.
OK, my bad, found it. <your documents folder>\Arduino\libraries\TeensyTimerTool\src\API> oneShotTimer.h , however I am getting confused as to where everything referenced is defined, so still confused
All the examples appear to pass fixed values to the timer functions. In our code there are variables which define the delay in seconds. These user defined delays can be adjusted in the GUI (not yet implemented but we have a dummy set of functions to return the user value as an unsigned int representing the seconds).
Code:
int??? led_timeout = 1s * settings_timeout_timer();
timeout.trigger(led_timeout);
We couldn't figure out what type led_timeout needs to be. None of the int types worked. But the following workaround worked...
Code:
timeout.trigger(1s * settings_timeout_timer());
So just what
type should led_timeout be declared as?
In order to get my int value (func call return value in this case) into the correct type, I think multiplying by "1s" is the most obvious way?
I also wondered what is the tick/delta time for each type of timer. Is this documented? It would be nice to see a table in the wiki. I note that there is a program to show the maximum time. We thought that we might need this information initially as we were going to pass an "int" type to the timer, so needed to know how big a tick was. Using the special(?) time types makes the code much more readable, so we will go this way.
Thank you in advance for any help which makes me less confused. Any pointer to web pages which I have not managed to find, also would be appreciated. I always seem to miss the obvious!!!