Skip to content
Johan Vandegriff edited this page Oct 27, 2016 · 1 revision

StateTimer is a simple timer that can be used in a simple state machine. It is not used in the current state machine framework, but it is here in case anyone needs it for something. For a timer that is used in the framework, see EndConditions.

ftc/electronvolts/util/StateTimer.java

package ftc.electronvolts.util;

/**
 * This file was made by the electronVolts, FTC team 7393
 *
 * A timer that can be used in a simplistic state machine
 */
public class StateTimer {
    private long endTime;

    /**
     * Start the timer
     *
     * @param durationMillis how long the timer will run in milliseconds
     */
    public void init(long durationMillis) {
        this.endTime = durationMillis + System.currentTimeMillis();
    }

    /**
     * @return whether or not the time has elapsed yet
     */
    public boolean isDone() {
        return System.currentTimeMillis() >= endTime;
    }
}

Home | Features

This guide will walk you through the basics of creating state machines using the state-machine-framework.

  1. Importing Into Your Project
  2. The State Interface
  3. Simple State Machine
  4. Custom States
  5. Custom StateMachineBuilder
  6. Custom EndConditions

Clone this wiki locally