com.qualcomm.robotcore.eventloop.opmode

## Class LinearOpMode

- java.lang.Object
- - com.qualcomm.robotcore.eventloop.opmode.OpMode
  - - com.qualcomm.robotcore.eventloop.opmode.LinearOpMode

-     public abstract class LinearOpMode
      extends OpMode

  Base class for user defined linear operation modes (op modes).

  This class derives from OpMode, but you should not override the methods from OpMode.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `LinearOpMode.LinearOpModeHelper`

  - ### Field Summary

    - ### Fields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

      `gamepad1, gamepad2, hardwareMap, internalOpModeServices, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, msStuckDetectStop, telemetry, time`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LinearOpMode()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `handleLoop()`
    `void` | `idle()` Puts the current thread to sleep for a bit as it has nothing better to do.
    `void` | `init_loop()` From the non-linear OpMode; do not override
    `void` | `init()` From the non-linear OpMode; do not override
    `void` | `internalPostInitLoop()` automatically update telemetry in a non-linear opmode
    `void` | `internalPostLoop()` automatically update telemetry in a non-linear opmode
    `boolean` | `isStarted()` Has the opMode been started?
    `boolean` | `isStopRequested()` Has the the stopping of the opMode been requested?
    `void` | `loop()` From the non-linear OpMode; do not override
    `boolean` | `opModeIsActive()` Answer as to whether this opMode is active and the robot should continue onwards.
    `abstract void` | `runOpMode()` Override this method and place your code here.
    `void` | `sleep(long milliseconds)` Sleeps for the given amount of milliseconds, or until the thread is interrupted.
    `void` | `start()` From the non-linear OpMode; do not override
    `void` | `stop()` From the non-linear OpMode; do not override
    `void` | `waitForNextHardwareCycle()` Deprecated. The need for user code to synchronize with the loop() thread has been obviated by improvements in the modern motor and servo controller implementations. Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero delay is required, the `sleep()` method is a better choice. If one simply wants to allow other threads to run, `idle()` is a good choice.
    `void` | `waitForStart()` Pauses the Linear Op Mode until start has been pressed or until the current thread is interrupted.
    `void` | `waitOneFullHardwareCycle()` Deprecated. The need for user code to synchronize with the loop() thread has been obviated by improvements in the modern motor and servo controller implementations. Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero delay is required, the `sleep()` method is a better choice. If one simply wants to allow other threads to run, `idle()` is a good choice.

    - ### Methods inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

      `getRuntime, internalPreInit, internalUpdateTelemetryNow, requestOpModeStop, resetStartTime, updateTelemetry`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LinearOpMode

          public LinearOpMode()

  - ### Method Detail

    - #### runOpMode

          public abstract void runOpMode()
                                  throws java.lang.InterruptedException

      Override this method and place your code here.

      Please do not swallow the InterruptedException, as it is used in cases where the op mode needs to be terminated early.

      Throws:
        `java.lang.InterruptedException`

    - #### waitForStart

          public void waitForStart()

      Pauses the Linear Op Mode until start has been pressed or until the current thread is interrupted.

    - #### waitOneFullHardwareCycle

          @Deprecated
          public void waitOneFullHardwareCycle()
                                                    throws java.lang.InterruptedException

      Deprecated. The need for user code to synchronize with the loop() thread has been obviated by improvements in the modern motor and servo controller implementations. Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero delay is required, the `sleep()` method is a better choice. If one simply wants to allow other threads to run, `idle()` is a good choice.
      Wait for one full cycle of the hardware

      Each cycle of the hardware your commands are sent out to the hardware; and the latest data is read back in.

      This method has a strong guarantee to wait for at least one full hardware hardware cycle.

      Throws:
        `java.lang.InterruptedException`
      See Also:
        `Thread.sleep(long)`, `idle()`, `waitForNextHardwareCycle()`

    - #### waitForNextHardwareCycle

          @Deprecated
          public void waitForNextHardwareCycle()
                                                    throws java.lang.InterruptedException

      Deprecated. The need for user code to synchronize with the loop() thread has been obviated by improvements in the modern motor and servo controller implementations. Remaining uses of this API are likely unncessarily wasting cycles. If a simple non-zero delay is required, the `sleep()` method is a better choice. If one simply wants to allow other threads to run, `idle()` is a good choice.
      Wait for the start of the next hardware cycle

      Each cycle of the hardware your commands are sent out to the hardware; and the latest data is read back in.

      This method will wait for the current hardware cycle to finish, which is also the start of the next hardware cycle.

      Throws:
        `java.lang.InterruptedException`
      See Also:
        `Thread.sleep(long)`, `idle()`, `waitOneFullHardwareCycle()`

    - #### idle

          public final void idle()

      Puts the current thread to sleep for a bit as it has nothing better to do. This allows other threads in the system to run.

      One can use this method when you have nothing better to do in your code as you await state managed by other threads to change. Calling idle() is entirely optional: it just helps make the system a little more responsive and a little more efficient.

      `idle()` is conceptually related to waitOneFullHardwareCycle(), but makes no guarantees as to completing any particular number of hardware cycles, if any.

      See Also:
        `opModeIsActive()`, `waitOneFullHardwareCycle()`

    - #### sleep

          public final void sleep(long milliseconds)

      Sleeps for the given amount of milliseconds, or until the thread is interrupted. This is simple shorthand for the operating-system-provided `sleep()` method.
      Parameters:
        `milliseconds` - amount of time to sleep, in milliseconds
      See Also:
        `Thread.sleep(long)`

    - #### opModeIsActive

          public final boolean opModeIsActive()

      Answer as to whether this opMode is active and the robot should continue onwards. If the opMode is not active, the OpMode should terminate at its earliest convenience.

      Note that internally this method calls `idle()`

      Returns:
        whether the OpMode is currently active. If this returns false, you should break out of the loop in your `runOpMode()` method and return to its caller.
      See Also:
        `runOpMode()`, `isStarted()`, `isStopRequested()`

    - #### isStarted

          public final boolean isStarted()

      Has the opMode been started?
      Returns:
        whether this opMode has been started or not
      See Also:
        `opModeIsActive()`, `isStopRequested()`

    - #### isStopRequested

          public final boolean isStopRequested()

      Has the the stopping of the opMode been requested?
      Returns:
        whether stopping opMode has been requested or not
      See Also:
        `opModeIsActive()`, `isStarted()`

    - #### init

          public final void init()

      From the non-linear OpMode; do not override
      Specified by:
        `init` in class `OpMode`

    - #### init_loop

          public final void init_loop()

      From the non-linear OpMode; do not override
      Overrides:
        `init_loop` in class `OpMode`

    - #### start

          public final void start()

      From the non-linear OpMode; do not override
      Overrides:
        `start` in class `OpMode`

    - #### loop

          public final void loop()

      From the non-linear OpMode; do not override
      Specified by:
        `loop` in class `OpMode`

    - #### stop

          public final void stop()

      From the non-linear OpMode; do not override
      Overrides:
        `stop` in class `OpMode`

    - #### handleLoop

          protected void handleLoop()

    - #### internalPostInitLoop

          public void internalPostInitLoop()

      Description copied from class: `OpMode`
      automatically update telemetry in a non-linear opmode
      Overrides:
        `internalPostInitLoop` in class `OpMode`

    - #### internalPostLoop

          public void internalPostLoop()

      Description copied from class: `OpMode`
      automatically update telemetry in a non-linear opmode
      Overrides:
        `internalPostLoop` in class `OpMode`