Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 2 months ago.
What happens if I call timer.start() and then timer.start() again?
What happens if I call timer.start() and then timer.start() again before reading the time? Does start the timer again from 0 or does nothing happen?
Question relating to:
2 Answers
10 years, 2 months ago.
FYI in latest mbed update the behavior has been changed (fixed): Now the second time you call timer.start() while the timer is already running will not do anything. mbed-src now has this behavior, the regular mbed lib will get it at the next update.
Why? It seems not very usefull this new behaviour. Pressing two times the start button of a regular chronometer will produce a new time-lapse measurement.
posted by 02 Dec 2014One difference is that a regular chronometer actually exposes something like lap-times, the Timer only uses something which could be compared internally.
I could see that there could be situations where you want to reset the current 'lap', but if that is wanted that function needs to be added: Start() should start the timer, not reset it partially imo.
posted by 02 Dec 20149 years, 10 months ago.
how about an extension like start(bool reset=false); I use the same timer for runtime measurements and always have to call t.reset(); before t.start();
As I am not able to post an answer (error), I'll copy it here:
Hi,
the implementation of timer's start method:
It sets start variable to the current time and running to 1.
Regards,
posted by Martin Kojtal 10 Oct 20140xc0170