public class ServoImpl extends java.lang.Object implements Servo
Servo.DirectionHardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
protected ServoController |
controller |
protected Servo.Direction |
direction |
protected double |
limitPositionMax |
protected double |
limitPositionMin |
protected int |
portNumber |
MAX_POSITION, MIN_POSITION| Constructor and Description |
|---|
ServoImpl(ServoController controller,
int portNumber)
Constructor
|
ServoImpl(ServoController controller,
int portNumber,
Servo.Direction direction)
COnstructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this device
|
java.lang.String |
getConnectionInfo()
Get connection information about this device in a human readable format
|
ServoController |
getController()
Get Servo Controller
|
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
Servo.Direction |
getDirection()
Get the direction
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
int |
getPortNumber()
Get Channel
|
double |
getPosition()
Returns the position to which the servo was last commanded, or Double.NaN if that is
unavailable.
|
int |
getVersion()
Version
|
protected void |
internalSetPosition(double position) |
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
scaleRange(double min,
double max)
Automatically scales the position of the servo.
|
void |
setDirection(Servo.Direction direction)
Set the direction
|
void |
setPosition(double position)
Commands the servo to move to a designated position.
|
protected ServoController controller
protected int portNumber
protected Servo.Direction direction
protected double limitPositionMin
protected double limitPositionMax
public ServoImpl(ServoController controller, int portNumber)
controller - Servo controller that this servo is attached toportNumber - physical port number on the servo controllerpublic ServoImpl(ServoController controller, int portNumber, Servo.Direction direction)
controller - Servo controller that this servo is attached toportNumber - physical port number on the servo controllerdirection - FORWARD for normal operation, REVERSE to reverse operationpublic HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic java.lang.String getConnectionInfo()
HardwareDevicegetConnectionInfo in interface HardwareDevicepublic int getVersion()
HardwareDevicegetVersion in interface HardwareDevicepublic void resetDeviceConfigurationForOpMode()
HardwareDeviceresetDeviceConfigurationForOpMode in interface HardwareDevicepublic void close()
HardwareDeviceclose in interface HardwareDevicepublic ServoController getController()
getController in interface ServoServo.getPortNumber()public void setDirection(Servo.Direction direction)
setDirection in interface Servodirection - directionServo.getDirection(),
Servo.Directionpublic Servo.Direction getDirection()
getDirection in interface ServoServo.setDirection(Direction)public int getPortNumber()
getPortNumber in interface ServoServo.getController()public void setPosition(double position)
setPosition in interface Servoposition - the commanded servo position. Should be in the range [0.0, 1.0].getPosition()protected void internalSetPosition(double position)
public double getPosition()
getPosition in interface ServosetPosition(double),
Double.isNaN(double)public void scaleRange(double min,
double max)
scaleRange in interface Servomin - the lower limit of the servo movement range, a value in the interval [0.0, 1.0]max - the upper limit of the servo movement range, a value in the interval [0.0, 1.0]Servo.setPosition(double)