public class ServoImpl extends java.lang.Object implements Servo
Servo.Direction
HardwareDevice.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()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public java.lang.String getConnectionInfo()
HardwareDevice
getConnectionInfo
in interface HardwareDevice
public int getVersion()
HardwareDevice
getVersion
in interface HardwareDevice
public void resetDeviceConfigurationForOpMode()
HardwareDevice
resetDeviceConfigurationForOpMode
in interface HardwareDevice
public void close()
HardwareDevice
close
in interface HardwareDevice
public ServoController getController()
getController
in interface Servo
Servo.getPortNumber()
public void setDirection(Servo.Direction direction)
setDirection
in interface Servo
direction
- directionServo.getDirection()
,
Servo.Direction
public Servo.Direction getDirection()
getDirection
in interface Servo
Servo.setDirection(Direction)
public int getPortNumber()
getPortNumber
in interface Servo
Servo.getController()
public void setPosition(double position)
setPosition
in interface Servo
position
- 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 Servo
setPosition(double)
,
Double.isNaN(double)
public void scaleRange(double min, double max)
scaleRange
in interface Servo
min
- 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)