Interface MotorInterface

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void addListener​(MotorEventListener listener)  
      default void backward()
      Backward at full speed
      void backward​(float speed)
      Set the motor direction to backward at the given speed.
      default void forward()
      Forward at full speed
      void forward​(float speed)
      Set the motor direction to forward at the given speed.
      float getValue()
      Get the relative output speed of the motor in the range -1..1
      boolean isActive()
      Is this motor currently active?
      void removeListener​(MotorEventListener listener)  
      default void reverseDirection()
      Reverse direction of the motors
      default void setValue​(float value)
      Set the relative speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)
      void stop()
      Stop the motor
      void whenBackward​(Action action)
      Perform the given action when the direction of the motor is changed to backwards
      void whenForward​(Action action)
      Perform the given action when the direction of the motor is changed to forwards
      void whenStop​(Action action)
      Perform the given action when the motor is stopped
    • Method Detail

      • forward

        void forward​(float speed)
              throws RuntimeIOException
        Set the motor direction to forward at the given speed.
        Parameters:
        speed - normalised speed value, range 0..1
        Throws:
        RuntimeIOException - if an I/O error occurs
      • backward

        void backward​(float speed)
               throws RuntimeIOException
        Set the motor direction to backward at the given speed.
        Parameters:
        speed - normalised speed value, range 0..1
        Throws:
        RuntimeIOException - if an I/O error occurs
      • getValue

        float getValue()
                throws RuntimeIOException
        Get the relative output speed of the motor in the range -1..1
        Returns:
        -1 for full reverse, 1 for full forward, 0 for stop
        Throws:
        RuntimeIOException - if an I/O error occurs
      • setValue

        default void setValue​(float value)
                       throws RuntimeIOException
        Set the relative speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)
        Parameters:
        value - Range -1..1. Positive numbers = forward, negative numbers = backward
        Throws:
        RuntimeIOException - if an I/O error occurs
      • whenForward

        void whenForward​(Action action)
        Perform the given action when the direction of the motor is changed to forwards
        Parameters:
        action - action to perform
      • whenBackward

        void whenBackward​(Action action)
        Perform the given action when the direction of the motor is changed to backwards
        Parameters:
        action - action to perform
      • whenStop

        void whenStop​(Action action)
        Perform the given action when the motor is stopped
        Parameters:
        action - action to perform