Package com.diozero.devices.motor
Class MotorBase
- java.lang.Object
-
- com.diozero.devices.motor.MotorBase
-
- All Implemented Interfaces:
DeviceInterface
,MotorInterface
,AutoCloseable
- Direct Known Subclasses:
AnalogOutputMotor
,PiconZeroMotor
,PwmMotor
,TB6612FNGMotor
public abstract class MotorBase extends Object implements MotorInterface
-
-
Constructor Summary
Constructors Constructor Description MotorBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(MotorEventListener listener)
void
removeListener(MotorEventListener listener)
protected void
valueChanged(float value)
void
whenBackward(Action action)
Perform the given action when the direction of the motor is changed to backwardsvoid
whenForward(Action action)
Perform the given action when the direction of the motor is changed to forwardsvoid
whenStop(Action action)
Perform the given action when the motor is stopped-
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.DeviceInterface
close
-
Methods inherited from interface com.diozero.devices.motor.MotorInterface
backward, backward, forward, forward, getValue, isActive, reverseDirection, setValue, stop
-
-
-
-
Method Detail
-
whenForward
public void whenForward(Action action)
Perform the given action when the direction of the motor is changed to forwards- Specified by:
whenForward
in interfaceMotorInterface
- Parameters:
action
- action to perform
-
whenBackward
public void whenBackward(Action action)
Perform the given action when the direction of the motor is changed to backwards- Specified by:
whenBackward
in interfaceMotorInterface
- Parameters:
action
- action to perform
-
whenStop
public void whenStop(Action action)
Perform the given action when the motor is stopped- Specified by:
whenStop
in interfaceMotorInterface
- Parameters:
action
- action to perform
-
addListener
public void addListener(MotorEventListener listener)
- Specified by:
addListener
in interfaceMotorInterface
-
removeListener
public void removeListener(MotorEventListener listener)
- Specified by:
removeListener
in interfaceMotorInterface
-
valueChanged
protected void valueChanged(float value)
-
-