View Single Post
  #4   Spotlight this post!  
Unread 16-02-2015, 08:02
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Timer resets when resumed

Quote:
Originally Posted by importsjc View Post
Hi everyone!

I have recently run into an interesting issue, it appears that the timer (edu.wpi.first.wpilibj.Timer) resets, when you .stop() and then .start().
Looking at the source for the Timer class, it definitely should continue increasing if you stop() then start() again.

Code:
 
85             public synchronized double get() {
86                 if (m_running) {
87                     return ((double) ((getMsClock() - m_startTime) + m_accumulatedTime)) / 1000.0;
88                 } else {
89                     return m_accumulatedTime;
90                 }
91             }

107             public synchronized void start() {
108                 m_startTime = getMsClock();
109                 m_running = true;
110             }

118             public synchronized void stop() {
119                 final double temp = get();
120                 m_accumulatedTime = temp;
121                 m_running = false;
122             }
Can you post your code showing your usage so we can see if anything jumps out as to why you're seeing it reset?