Package com.diozero.devices.motor
Class AnalogOutputMotor
- java.lang.Object
-
- com.diozero.devices.motor.MotorBase
-
- com.diozero.devices.motor.AnalogOutputMotor
-
- All Implemented Interfaces:
DeviceInterface
,MotorInterface
,AutoCloseable
public class AnalogOutputMotor extends MotorBase
-
-
Constructor Summary
Constructors Constructor Description AnalogOutputMotor(AnalogOutputDevice aout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backward(float speed)
Set the motor direction to backward at the given speed.void
close()
Close this devicevoid
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..1boolean
isActive()
Is this motor currently active?void
stop()
Stop the motor-
Methods inherited from class com.diozero.devices.motor.MotorBase
addListener, removeListener, valueChanged, whenBackward, whenForward, whenStop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.diozero.devices.motor.MotorInterface
backward, forward, reverseDirection, setValue
-
-
-
-
Constructor Detail
-
AnalogOutputMotor
public AnalogOutputMotor(AnalogOutputDevice aout)
-
-
Method Detail
-
forward
public 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
public 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
-
stop
public void stop() throws RuntimeIOException
Stop the motor- Throws:
RuntimeIOException
- if an I/O error occurs
-
getValue
public 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
-
isActive
public boolean isActive() throws RuntimeIOException
Is this motor currently active?- Returns:
- true if speed != 0
- Throws:
RuntimeIOException
- if an I/O error occurs
-
close
public void close()
Close this device
-
-