ch.aplu.nxt
Class ColorHTSensor
java.lang.Object
ch.aplu.nxt.Part
ch.aplu.nxt.Sensor
ch.aplu.nxt.ColorHTSensor
- All Implemented Interfaces:
- SharedConstants
public class ColorHTSensor
- extends Sensor
- implements SharedConstants
Class that represents a color light sensor (HiTechnic Color Sensor)
Fields inherited from interface ch.aplu.nxt.SharedConstants |
ABOUT, ACCELEROMETERPOLLDELAY, ANGLE, ANGLESTEPSMODE, AXELENGTH, BOOLEANMODE, BOOT, BRAKE, BRAKEDELAY, CELSIUSMODE, CLOSE, COLORPOLLDELAY, COMPASSPOLLDELAY, CRAWLERROTATIONFACTOR, CRAWLERROTATIONSPEED, CRAWLERSPEED, CRAWLERSTEPFACTOR, CUSTOM, DEBUG_LEVEL_HIGH, DEBUG_LEVEL_LOW, DEBUG_LEVEL_MEDIUM, DEBUG_LEVEL_OFF, DEBUGLEVEL, DELETE, DELETE_USER_FLASH, DIRECT_COMMAND_NOREPLY, DIRECT_COMMAND_REPLY, FAHRENHEITMODE, FIND_FIRST, FIND_NEXT, GEARSPEED, GET_BATTERY_LEVEL, GET_CURRENT_PROGRAM_NAME, GET_DEVICE_INFO, GET_FIRMWARE_VERSION, GET_INPUT_VALUES, GET_OUTPUT_STATE, GYROPOLLDELAY, HIGH_SPEED_BUFFER, INFRAREDSEEKERPOLLDELAY, KEEP_ALIVE, LIGHT_ACTIVE, LIGHT_INACTIVE, LIGHTPOLLDELAY, LOWSPEED, LOWSPEED_9V, LS_GET_STATUS, LS_READ, LS_WRITE, MESSAGE_READ, MESSAGE_WRITE, MODEMASK, MOTIONDETECTORPOLLDELAY, MOTOR_RUN_STATE_IDLE, MOTOR_RUN_STATE_RAMPDOWN, MOTOR_RUN_STATE_RAMPUP, MOTOR_RUN_STATE_RUNNING, MOTORON, MOTORSPEED, MOTORSPEEDFACTOR, MOTORSPEEDMULTIPLIER, NO_OF_SENSOR_TYPES, NO_SENSOR, OPEN_APPEND_DATA, OPEN_READ, OPEN_READ_LINEAR, OPEN_WRITE, OPEN_WRITE_DATA, OPEN_WRITE_LINEAR, PCTFULLSCALEMODE, PERIODCOUNTERMODE, PLAY_SOUND_FILE, PLAY_TONE, POLL, POLL_BUFFER, POLL_LENGTH, PROTOTYPEPOLLDELAY, RAWMODE, READ, REFLECTION, REGULATED, REGULATION_MODE_IDLE, REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_MOTOR_SYNC, REPLY_COMMAND, RESET_MOTOR_POSITION, RESET_SCALED_INPUT_VALUE, RFIDPOLLDELAY, SENSOREVENTDELAY, SET_BRICK_NAME, SET_INPUT_MODE, SET_OUTPUT_STATE, SLOPEMASK, SOUND_DB, SOUND_DBA, SOUNDPOLLDELAY, START_PROGRAM, STOP_PROGRAM, STOP_SOUND_PLAYBACK, SWITCH, SYSTEM_COMMAND_NOREPLY, SYSTEM_COMMAND_REPLY, TEMPERATURE, TITLE, TITLEMP, TOUCHPOLLDELAY, TRANSITIONCNTMODE, TURTLEROTATIONFACTOR, TURTLEROTATIONSPEED, TURTLESPEED, TURTLESTEPFACTOR, ULTRASONICPOLLDELAY, VERSION, WRITE |
Method Summary |
lejos.robotics.Color |
getColor()
Returns a Color reference to the the calibrated color reading. |
int |
getColorID()
Returns the HiTechnic color index:
0: black
1: blue
2: blue
3: blue
4: green
5: yellow
6: yellow
7: red
8: red
9: red
10: pink
11: pink
12: light green
13: light yellow
14: light red
15: light red
16: light red
17: white
|
lejos.nxt.SensorPort |
getLejosPort()
Returns the reference of the the underlying lejos.nxt.SensorPort. |
lejos.nxt.addon.ColorHTSensor |
getLejosSensor()
Returns the reference of the the underlying lejos.nxt.addon.ColorHTSensor. |
boolean |
inColorCube(int[] rgb,
int[] colorCube)
Checks if given rgb values lies within given color cube. |
int |
initBlackLevel()
Puts the sensor into black/ambient level calibration mode. |
int |
initWhiteBalance()
Puts the sensor into white balance calibration mode. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ColorHTSensor
public ColorHTSensor(SensorPort port)
- Creates a sensor instance connected to the given port.
Uses the lejos.nxt.addon.ColorHTSensor
- Parameters:
port
- the port where the sensor is plugged-in
ColorHTSensor
public ColorHTSensor()
- Creates a sensor instance connected to port S1.
Uses the lejos.nxt.addon.ColorHTSensor
getLejosSensor
public lejos.nxt.addon.ColorHTSensor getLejosSensor()
- Returns the reference of the the underlying lejos.nxt.addon.ColorHTSensor.
- Returns:
- the reference of the ColorHTSensor
getLejosPort
public lejos.nxt.SensorPort getLejosPort()
- Returns the reference of the the underlying lejos.nxt.SensorPort.
- Returns:
- the reference of the SensorPort
getColor
public lejos.robotics.Color getColor()
- Returns a Color reference to the the calibrated color reading.
The minimal poll period is about 500 ms.
- Returns:
- the calibrated color reading
inColorCube
public boolean inColorCube(int[] rgb,
int[] colorCube)
- Checks if given rgb values lies within given color cube.
- Parameters:
rgb
- an integer array of 3 color valuecolorCube
- an integer array of 6 boundary values in the order:
red_min, red_max, green_min, green_max, blue_min, blue_max
- Returns:
- true, if the rgb values are within the color cube; otherwise false
getColorID
public int getColorID()
- Returns the HiTechnic color index:
0: black
1: blue
2: blue
3: blue
4: green
5: yellow
6: yellow
7: red
8: red
9: red
10: pink
11: pink
12: light green
13: light yellow
14: light red
15: light red
16: light red
17: white
- Returns:
- HiTechnic color number
initWhiteBalance
public int initWhiteBalance()
- Puts the sensor into white balance calibration mode.
For best results the sensor should be pointed at a diffuse white
surface at a distance of approximately 15mm before calling this method.
After a fraction of a second the sensor lights will flash and the
calibration is done. When calibrated, the sensor keeps this information
in non-volatile memory (from lejos.nxt.addon.ColorSensor).
- Returns:
- 0 if successful; otherwise -1
initBlackLevel
public int initBlackLevel()
- Puts the sensor into black/ambient level calibration mode.
For best results the sensor should be pointed in a direction with no
obstacles for 50cm or so. This reading the sensor will use as a base
level for other readings. After a fraction of a second the sensor
lights will flash and the calibration is done. When calibrated,
the sensor keeps this information in non-volatile memory
(from lejos.nxt.addon.ColorSensor).
- Returns:
- 0 if successful; otherwise -1