Package lejos.hardware.sensor
Class HiTechnicColorSensor
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.sensor.HiTechnicColorSensor
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,ColorIdentifier,SampleProvider
public class HiTechnicColorSensor extends I2CSensor implements ColorIdentifier
HiTechnic color sensor
DescriptionThe code for this sensor has not been tested. Please report test results to the leJOS forum.
Supported modes Mode name Description unit(s) Getter Color ID Measures the color ID of a surface Color ID getColorIDMode()RGB Measures the RGB color of a surface N/A, Normalized to (0-1) getRGBMode()See Sensor Product page See The leJOS sensor framework See
leJOS conventions for SampleProviders- Author:
- Your name
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classHiTechnicColorSensor.RGBMode
-
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 HiTechnicColorSensor(I2CPort port)HiTechnicColorSensor(Port port)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColorID()Returns the color index detected by the sensor.SensorModegetColorIDMode()HiTechnic color sensor, Color ID mode
Measures the color ID of a surface.SensorModegetRGBMode()HiTechnic color sensor, Color ID mode
Measures the color of a surface.protected voidinit()-
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
-
-
-
-
Method Detail
-
init
protected void init()
-
getColorID
public int getColorID()
Returns the color index detected by the sensor.- Specified by:
getColorIDin interfaceColorIdentifier- Returns:
- Color index.
- 0 = red
- 1 = green
- 2 = blue
- 3 = yellow
- 4 = magenta
- 5 = orange
- 6 = white
- 7 = black
- 8 = pink
- 9 = gray
- 10 = light gray
- 11 = dark gray
- 12 = cyan
-
getColorIDMode
public SensorMode getColorIDMode()
HiTechnic color sensor, Color ID mode
Measures the color ID of a surface.Size and content of the sample
The sample contains one element containing a color ID.- 0 = red
- 1 = green
- 2 = blue
- 3 = yellow
- 4 = magenta
- 5 = orange
- 6 = white
- 7 = black
- 8 = pink
- 9 = gray
- 10 = light gray
- 11 = dark gray
- 12 = cyan
-
getRGBMode
public SensorMode getRGBMode()
HiTechnic color sensor, Color ID mode
Measures the color of a surface.Size and content of the sample
The sample contains three elements containing the color expressed in RGB values (0-255) of the measured surface.
-
-