Robin2:
This line of code
LED1 = myTimer1.timerOnOff(!LED1, 500, 100);
suggests to me that it will be ON for 500 and off for 100.
For it to work the other way I would expect the function to be named timeroffOn()
Maybe it would be less confusing to name it timerHighLow() to indicate the return values. Then it is up to the user whether a HIGH or a LOW is used to turn something on.
The basic idea of this function was to create an onDelay and an offDelay. So it is not the onTime, it is the delay time to switch it on.
I did rename the function variables
delayOnTime -> delayTimeSwitchOn
and
delayOffTime -> delayTimeSwitchOff
to make it more clear what it means.
Robin2:
ANOTHER THING ...
I had not thought about it before now but I don't understand the purpose of the first parameter in this code
LED1 = myTimer1.timerOnOff(!LED1, 500, 100);
Why is the timer linked to the state of the LED?
To send the inverted output back to the input just restarts the timer evertime when the time is elapsed.
On this way it clears the input as soon as the output gets set to start the switch off delay.
This is what the timerOnOff() function does.
// in : _______------------______---______________------------_------
// out: ___________----------_________________________---------------
It sets the output delayed to the input by the given time durations.
If you would not send the inverted output back, then it would look like as followed.
LED1 = myTimer1.timerOnOff(1, 500, 100);
// in : --------------------------------------------------------------
// out: ___________---------------------------------------------------
I did create in the meanwhile a new function timerCycleOnOff() which is better to use for LED flashing or other cyclically intervals.
It uses offTime which equals the time the LED would be off and onTime which eqals the time the LED would be on.
bool timerCycleOnOff(uint32_t offTime, uint32_t onTime)
// example with timerCycleOnOff() which does the same as the other LED flashing samples before
LED1 = myTimer1.timerCycleOnOff(500, 100);
Robin2:
I don't like it when programmers only use an example to explain something. Examples on their own only demonstrate one particular situation. If the reader has another usage in mind the example can be useless. There should be explanatory text and then an example can used to illustrate the text.
I personally look in the most cases at first into the examples to understand how the library functions work in general in a user program. After that I look into the reference to see which parameters these functions have and which I have to change to adapt it to my application. However, I think this is more a personal preference, I think a documentation should have a reference as well as examples.
The timerReset() function itself is described there in the README.md. Do you think it requires a more detailed description?
Robin2:
(And your URL is incorrect - but I did find the example)
Thanks, I did correct it.