View Single Post
  #6   Spotlight this post!  
Unread 16-02-2015, 21:21
importsjc importsjc is offline
Registered User
FRC #1405
 
Join Date: Jan 2015
Location: Rochester
Posts: 5
importsjc is an unknown quantity at this point
Re: Timer resets when resumed

Ok, after doing testing I have narrowed down the timer reset to the line
Code:
timer.start();
here is some test code that is resetting when you start and then stop.

Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Custom;
import edu.wpi.first.wpilibj.Timer;

/**
 *
 * @author Robotics
 */
public class TimerTest {
	Timer autoTimer;
    public void robotInit(){
        
    }
       
    public void autonomousInit(){
    	autoTimer = new Timer();
        autoTimer.start();
    }
    public void autonomousPeriodic() {
    	System.out.println("AutoTimer First: " + autoTimer.get());
    	Timer.delay(2);
    	System.out.println("AutoTimer Second: " + autoTimer.get()+"\n\n");
    	autoTimer.stop();
    	Timer.delay(2);
    	System.out.println("AutoTimer Third: " + autoTimer.get()+"\n\n");
    	Timer.delay(2);
    	autoTimer.start();
    	System.out.println("AutoTimer Fourth: " + autoTimer.get()+"\n\n");
    }
    
    public void teleopInit(){
    }
    
    public void teleopPeriodic() {
    }
    
    public void testInit(){
    }
    
    public void testPeriodic() {
    }
    
    
    public void disabledInit(){
    }
    
}
you should notice that after the timer is re-started the autoTimer.get(); printout becomes 0.

I have actually solved my problem using an offshoot of what @legts suggested.

Thanks for the help!