Package lejos.hardware.device
Class MServo
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.MServo
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class MServo extends I2CSensor
MServo, is a abstraction to model any RC Servo (continuous and non continuous) plugged to- Author:
- Juan Antonio Brenha Moral
-
-
Field Summary
-
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 MServo(I2CPort port, int location)The initial Constructor.MServo(I2CPort port, int location, java.lang.String servoName)The initial Constructor.MServo(I2CPort port, int location, java.lang.String servoName, int min_angle, int max_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 intgetAngle()Return the angle used in last operationintgetPulse()Return the pulse used in last operationvoidsetAngle(int angle)Method to set an Angle in a RC Servo.voidsetPulse(int pulse)This method set the pulse in a RC Servo.voidsetSpeed(int speed)Method to set the Speed in a RC Servo.-
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, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Constructor Detail
-
MServo
public MServo(I2CPort port, int location)
The initial Constructor. This constructor establish where is plugged NXTServo on NXT Brick, where the RC Servo is plugged into NXTServo- Parameters:
port-location-
-
MServo
public MServo(I2CPort port, int location, java.lang.String servoName)
The initial Constructor. This constructor establish where is plugged NXTServo on NXT Brick, where the RC Servo is plugged into NXTServo- Parameters:
port-location-servoName-
-
MServo
public MServo(I2CPort port, int location, java.lang.String servoName, int min_angle, int max_angle)
Constructor with the feature to set min, max and init angle- Parameters:
port-location-servoName-min_angle-max_angle-
-
-
Method Detail
-
setPulse
public void setPulse(int pulse)
This method set the pulse in a RC Servo. Note:Pulse range is: 500-2500, but internally it is necessary to divide into 2- Parameters:
pulse- the pulse width
-
getPulse
public int getPulse()
Return the pulse used in last operation- Returns:
- the pulse
-
setAngle
public void setAngle(int angle)
Method to set an Angle in a RC Servo.- Parameters:
angle- the angle
-
getAngle
public int getAngle()
Return the angle used in last operation- Returns:
- the angle
-
setSpeed
public void setSpeed(int speed)
Method to set the Speed in a RC Servo.- Parameters:
speed- the speed
-
-