From 0ea849e7ff5989a9b8317c0b27665ea8c7eda5f3 Mon Sep 17 00:00:00 2001 From: Sissors Date: Fri, 10 Oct 2014 21:25:09 +0200 Subject: [PATCH] [API] Timer-start behavior (bug)fix Only start the timer when it is not running currently. In old behavior the current slice-time was discarded, now multiple starts have no effect. --- libraries/mbed/common/Timer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/mbed/common/Timer.cpp b/libraries/mbed/common/Timer.cpp index d4ed133125..e00eaaf543 100644 --- a/libraries/mbed/common/Timer.cpp +++ b/libraries/mbed/common/Timer.cpp @@ -23,8 +23,10 @@ Timer::Timer() : _running(), _start(), _time() { } void Timer::start() { - _start = us_ticker_read(); - _running = 1; + if (!_running) { + _start = us_ticker_read(); + _running = 1; + } } void Timer::stop() {