Package lejos.hardware.device
Class LMotor
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.LMotor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class LMotor extends I2CSensor
Generic abstraction to manage RC Servos and DC Motor. LServo and LDCMotor uses inherits from this class- Author:
- Juan Antonio Brenha Moral
-
-
Field Summary
Fields Modifier and Type Field Description static int[]arrMotorLoadstatic int[]arrMotorUnloadprotected intLSC_positionprotected byteSPI_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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()Get name from a RC Servo or a DC Motorprotected intgetPulse()This method return current pulse over a RC Servo or a DC Motor.booleanisMoving()Method to know if Servo is moving to a determinated anglevoidload()Load Servo located in a position XvoidsetDelay(int delay)Set a delay in a Motorprotected voidsetPulse(int pulse)This class set the Pulse over a RC Servo or a DC Motorvoidunload()-
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
-
LMotor
public LMotor(I2CPort port, int location, java.lang.String name, byte SPI_PORT)
Constructor- Parameters:
port- the portlocation- the locationname- the name of the servoSPI_PORT- the SPI port
-
LMotor
public LMotor(Port port, int location, java.lang.String name, byte SPI_PORT)
Constructor- Parameters:
port- the portlocation- the locationname- the name of the servoSPI_PORT- the SPI port
-
-
Method Detail
-
isMoving
public boolean isMoving()
Method to know if Servo is moving to a determinated angle- Returns:
- true iff the servo is moving
-
setDelay
public void setDelay(int delay)
Set a delay in a Motor- Parameters:
delay- the delay
-
unload
public void unload()
-
load
public void load()
Load Servo located in a position X
-
getName
public java.lang.String getName()
Get name from a RC Servo or a DC Motor- Specified by:
getNamein interfaceSensorMode- Overrides:
getNamein classBaseSensor- Returns:
- The description/name of this mode
-
setPulse
protected void setPulse(int pulse)
This class set the Pulse over a RC Servo or a DC Motor- Parameters:
pulse-
-
getPulse
protected int getPulse()
This method return current pulse over a RC Servo or a DC Motor. This method is used internally by LDCMotor Objects or LServo Objects to get the speed or angle.- Returns:
- the pulse
-
-