Package com.diozero.api.motor
Class MotorBase
java.lang.Object
com.diozero.api.motor.MotorBase
- All Implemented Interfaces:
MotorInterface
,Closeable
,AutoCloseable
- Direct Known Subclasses:
PiconZeroMotor
,PwmMotor
,TB6612FNGMotor
public abstract class MotorBase extends Object implements MotorInterface
-
Constructor Summary
Constructors Constructor Description MotorBase()
-
Method Summary
Modifier and Type Method Description void
addListener(MotorListener listener)
void
removeListener(MotorListener listener)
void
reverse()
Reverse direction of the motorsvoid
setValue(float value)
Set the speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)protected void
valueChanged(float value)
void
whenBackward(Action action)
void
whenForward(Action action)
void
whenStop(Action action)
-
Constructor Details
-
MotorBase
public MotorBase()
-
-
Method Details
-
reverse
Reverse direction of the motors- Specified by:
reverse
in interfaceMotorInterface
- Throws:
RuntimeIOException
- if an I/O error occurs
-
setValue
Set the speed of the motor as a floating point value between -1 (full speed backward) and 1 (full speed forward)- Specified by:
setValue
in interfaceMotorInterface
- Parameters:
value
- Range -1 .. 1. Positive numbers for forward, Negative numbers for backward- Throws:
RuntimeIOException
- if an I/O error occurs
-
whenForward
- Specified by:
whenForward
in interfaceMotorInterface
-
whenBackward
- Specified by:
whenBackward
in interfaceMotorInterface
-
whenStop
- Specified by:
whenStop
in interfaceMotorInterface
-
addListener
- Specified by:
addListener
in interfaceMotorInterface
-
removeListener
- Specified by:
removeListener
in interfaceMotorInterface
-
valueChanged
protected void valueChanged(float value)
-