lejos.nxt.addon
Class MServo

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.MServo
All Implemented Interfaces:
SensorConstants

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.nxt.I2CSensor
PRODUCT_ID, SENSOR_TYPE, VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, 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
 
Constructor Summary
MServo(SensorPort port, int location)
          The initial Constructor.
MServo(SensorPort port, int location, String servoName)
          The initial Constructor.
MServo(SensorPort port, int location, String servoName, int min_angle, int max_angle)
          Constructor with the feature to set min, max and init angle
 
Method Summary
 int getAngle()
          Return the angle used in last operation
 int getPulse()
          Return the pulse used in last operation
 void setAngle(int angle)
          Method to set an Angle in a RC Servo.
 void setPulse(int pulse)
          This method set the pulse in a RC Servo.
 void setSpeed(int speed)
          Method to set the Speed in a RC Servo.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getData, getPort, getProductID, getSensorType, getVersion, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MServo

public MServo(SensorPort 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(SensorPort port,
              int location,
              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(SensorPort port,
              int location,
              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