Package com.diozero.devices.motor
Class MotorBase
java.lang.Object
com.diozero.devices.motor.MotorBase
- All Implemented Interfaces:
FloatConsumer
,MotorInterface
,Closeable
,AutoCloseable
- Direct Known Subclasses:
PiconZeroMotor
,PwmMotor
,TB6612FNGMotor
public abstract class MotorBase extends Object implements MotorInterface, FloatConsumer
-
Constructor Summary
Constructors Constructor Description MotorBase()
-
Method Summary
Modifier and Type Method Description void
accept(float value)
Performs this operation on the given argument.void
addListener(MotorEventListener listener)
void
removeListener(MotorEventListener 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)void
whenBackward(Action action)
void
whenForward(Action action)
void
whenStop(Action action)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.diozero.api.function.FloatConsumer
andThen
-
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
-
accept
public void accept(float value)Description copied from interface:FloatConsumer
Performs this operation on the given argument.- Specified by:
accept
in interfaceFloatConsumer
- Parameters:
value
- the input argument
-