I am trying this library so is there a way to use 0.1 second with it?
did u try timer.setCounter(0, 0, 0.1);
??
it consider 0.1 as 1 second
can anybody modify library to be set as:
timer.setCounter(hour, minute, second, millisecond);
Hello Eleckits
Brew it yourself by using the "Blink without Delay" example to be found in the IDE.
If it is open source, yes.
by the way, I am developing mobile app for set time then send value to arduino board over bluetooth to countdown according to values that set via app
can you help me to modify the library?
Up to you.
I looked at it, and it's not really designed for this kind of use. There are many other timing libraries than can work in milliseconds. Just use another one.
can you recommend another library to test?
No, I recommend coding it. It's too simple to use a library.
Which library?
No library. The timing function 'millis()' is perfectly sufficient. If you want another library, you can search on the library page here, or use Google.
If you get recommendations here, it might be from the library authors, so take them as non-objective in that case.
With this library, you can use milliseconds. From the example code:
// Print current time every 1s on serial port by calling method refreshClock().
timer.setInterval(refreshClock, 1000);
So you can change the 1000 to any number of ms that you like.
That is a big part of it.
Then change:
_currentCountTime = ((hours * 3600L) + (minutes * 60L) + seconds) * 1000L;
to this completely untested code:
_currentCountTime = ((hours * 3600L) + (minutes * 60L) + seconds) * 1000L + milliseconds;
it is interval value for print current time over serial not for set point
That is how it is used in the simple test example. It is not limited in use to only that. If you set it to run the callback every 100 ms., your need can be met. You can do anything reasonable that you like in the callback routine.
You haven't provided any code, or explained at all, what you need the timing for.
It looks to me like the other methods use the interval that is provided, so they might still work, but in deci-seconds (1/10s).
void Countimer::run()
{
// timer is running only if is not completed or not stopped.
if (_isCounterCompleted || _isStopped)
return;
if (millis() - _previousMillis >= _interval) {
if (_countType == COUNT_DOWN)
{
countDown();
}
else if (_countType == COUNT_UP)
{
countUp();
}
else
{
callback();
}
_previousMillis = millis();
}
}
You should try changing the interval, I can't test it here due to lack of time.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.