Package lejos.hardware.device
Class LServo
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.LMotor
-
- lejos.hardware.device.LServo
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class LServo extends LMotor
LServo, Lattebox Servo, is a abstraction to model any RC Servo (continous and non continous) plugged to LSC, Lattebox Servo Controller.- Author:
- Juan Antonio Brenha Moral
-
-
Field Summary
-
Fields inherited from class lejos.hardware.device.LMotor
arrMotorLoad, arrMotorUnload, LSC_position, SPI_PORT
-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
-
-
Constructor Summary
Constructors Constructor Description LServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT)ConstructorLServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT, int min_angle, int max_angle)Constructor with the feature to set min and max angleLServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT, int min_angle, int max_angle, int init_angle)Constructor with the feature to set min, max and init angle
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbackward()Classic backward method for continous RC Servosvoidforward()Classic forward method for continous RC ServosintgetAngle()Method to know the anglevoidgoToInitAngle()Method to set medium anglevoidgoToMaxAngle()Method to set maximum anglevoidgoToMiddleAngle()Method to set medium anglevoidgoToMinAngle()Method to set minimal anglevoidsetAngle(int angle)Method to set an Angle in a RC Servo.voidsetMaxAngle(int maxAngle)Set Maximum angle.voidsetMinAngle(int minAngle)Set Minimal angle.-
Methods inherited from class lejos.hardware.device.LMotor
getName, getPulse, isMoving, load, setDelay, setPulse, unload
-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Constructor Detail
-
LServo
public LServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT)
Constructor- Parameters:
port-location-servoName-SPI_PORT-
-
LServo
public LServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT, int min_angle, int max_angle)
Constructor with the feature to set min and max angle- Parameters:
port-location-servoName-SPI_PORT-min_angle-max_angle-
-
LServo
public LServo(I2CPort port, int location, java.lang.String servoName, byte SPI_PORT, int min_angle, int max_angle, int init_angle)
Constructor with the feature to set min, max and init angle- Parameters:
port-location-servoName-SPI_PORT-min_angle-max_angle-init_angle-
-
-
Method Detail
-
setAngle
public void setAngle(int angle)
Method to set an Angle in a RC Servo.- Parameters:
angle-
-
getAngle
public int getAngle()
Method to know the angle- Returns:
- the angle
-
setMinAngle
public void setMinAngle(int minAngle)
Set Minimal angle. Useful method to calibrate a Servo- Parameters:
minAngle- the minimum angle
-
setMaxAngle
public void setMaxAngle(int maxAngle)
Set Maximum angle. Useful method to calibrate a Servo- Parameters:
maxAngle-
-
goToMinAngle
public void goToMinAngle()
Method to set minimal angle
-
goToMaxAngle
public void goToMaxAngle()
Method to set maximum angle
-
goToMiddleAngle
public void goToMiddleAngle()
Method to set medium angle
-
goToInitAngle
public void goToInitAngle()
Method to set medium angle
-
forward
public void forward()
Classic forward method for continous RC Servos
-
backward
public void backward()
Classic backward method for continous RC Servos
-
-