public class YColorSensor extends YFunction
| Modifier and Type | Class and Description |
|---|---|
static interface |
YColorSensor.TimedReportCallback
TimedReportCallback for ColorSensor
|
static interface |
YColorSensor.UpdateCallback
Deprecated UpdateCallback for ColorSensor
|
| Modifier and Type | Field and Description |
|---|---|
protected String |
_autoGain |
protected int |
_estimatedHSL |
protected String |
_estimatedOkLab |
protected int |
_estimatedRGB |
protected String |
_estimatedXYZ |
protected int |
_estimationModel |
protected int |
_gain |
protected int |
_integrationTime |
protected int |
_ledCalibration |
protected int |
_ledCurrent |
protected String |
_nearHTMLColor |
protected String |
_nearRAL1 |
protected String |
_nearRAL2 |
protected String |
_nearRAL3 |
protected String |
_nearSimpleColor |
protected int |
_nearSimpleColorIndex |
protected int |
_saturation |
protected YColorSensor.UpdateCallback |
_valueCallbackColorSensor |
protected int |
_workingMode |
static String |
AUTOGAIN_INVALID
invalid autoGain value
|
static int |
ESTIMATEDHSL_INVALID
invalid estimatedHSL value
|
static String |
ESTIMATEDOKLAB_INVALID
invalid estimatedOkLab value
|
static int |
ESTIMATEDRGB_INVALID
invalid estimatedRGB value
|
static String |
ESTIMATEDXYZ_INVALID
invalid estimatedXYZ value
|
static int |
ESTIMATIONMODEL_EMISSION |
static int |
ESTIMATIONMODEL_INVALID |
static int |
ESTIMATIONMODEL_REFLECTION
invalid estimationModel value
|
static int |
GAIN_INVALID
invalid gain value
|
static int |
INTEGRATIONTIME_INVALID
invalid integrationTime value
|
static int |
LEDCALIBRATION_INVALID
invalid ledCalibration value
|
static int |
LEDCURRENT_INVALID
invalid ledCurrent value
|
static String |
NEARHTMLCOLOR_INVALID
invalid nearHTMLColor value
|
static String |
NEARRAL1_INVALID
invalid nearRAL1 value
|
static String |
NEARRAL2_INVALID
invalid nearRAL2 value
|
static String |
NEARRAL3_INVALID
invalid nearRAL3 value
|
static String |
NEARSIMPLECOLOR_INVALID
invalid nearSimpleColor value
|
static int |
NEARSIMPLECOLORINDEX_BLACK |
static int |
NEARSIMPLECOLORINDEX_BLUE |
static int |
NEARSIMPLECOLORINDEX_BROWN
invalid nearSimpleColorIndex value
|
static int |
NEARSIMPLECOLORINDEX_GRAY |
static int |
NEARSIMPLECOLORINDEX_GREEN |
static int |
NEARSIMPLECOLORINDEX_INVALID |
static int |
NEARSIMPLECOLORINDEX_ORANGE |
static int |
NEARSIMPLECOLORINDEX_PINK |
static int |
NEARSIMPLECOLORINDEX_PURPLE |
static int |
NEARSIMPLECOLORINDEX_RED |
static int |
NEARSIMPLECOLORINDEX_WHITE |
static int |
NEARSIMPLECOLORINDEX_YELLOW |
static int |
SATURATION_INVALID
invalid saturation value
|
static int |
WORKINGMODE_AUTO
invalid workingMode value
|
static int |
WORKINGMODE_AUTOGAIN |
static int |
WORKINGMODE_EXPERT |
static int |
WORKINGMODE_INVALID |
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID| Modifier | Constructor and Description |
|---|---|
protected |
YColorSensor(String func) |
protected |
YColorSensor(YAPIContext ctx,
String func) |
| Modifier and Type | Method and Description |
|---|---|
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
int |
configureAutoGain(String channel,
int minRaw,
int maxRaw,
boolean noSatur)
Changes the sensor automatic gain control settings.
|
static YColorSensor |
FindColorSensor(String func)
Retrieves a color sensor for a given identifier.
|
static YColorSensor |
FindColorSensorInContext(YAPIContext yctx,
String func)
Retrieves a color sensor for a given identifier in a YAPI context.
|
static YColorSensor |
FirstColorSensor()
Starts the enumeration of color sensors currently accessible.
|
static YColorSensor |
FirstColorSensorInContext(YAPIContext yctx)
Starts the enumeration of color sensors currently accessible.
|
String |
get_autoGain()
Returns the current autogain parameters of the sensor as a character string.
|
int |
get_estimatedHSL()
Returns the estimated color in HSL color model (0xHHSSLL).
|
String |
get_estimatedOkLab()
Returns the estimated color according to the OkLab color model.
|
int |
get_estimatedRGB()
Returns the estimated color in RGB color model (0xRRGGBB).
|
String |
get_estimatedXYZ()
Returns the estimated color according to the CIE XYZ color model.
|
int |
get_estimationModel()
Returns the predictive model used for color estimation (reflective or emissive).
|
int |
get_gain()
Returns the current spectral channel detector gain exponent.
|
int |
get_integrationTime()
Returns the current integration time for spectral measure, in milliseconds.
|
int |
get_ledCalibration()
Returns the current sent to the illumination LEDs during the latest calibration.
|
int |
get_ledCurrent()
Returns the amount of current sent to the illumination LEDs, for reflection measures.
|
String |
get_nearHTMLColor()
Returns the name of the HTML color closest to the estimated color.
|
String |
get_nearRAL1()
Returns the RAL Classic color closest to the estimated color, with a similarity ratio.
|
String |
get_nearRAL2()
Returns the second closest RAL Classic color to the estimated color, with a similarity ratio.
|
String |
get_nearRAL3()
Returns the third closest RAL Classic color to the estimated color, with a similarity ratio.
|
String |
get_nearSimpleColor()
Returns the name of the basic color typically used to refer to the estimated color.
|
int |
get_nearSimpleColorIndex()
Returns the index of the basic color typically used to refer to the estimated color (enumerated value).
|
int |
get_saturation()
Returns the current saturation state of the sensor, as an integer.
|
int |
get_workingMode()
Returns the sensor working mode.
|
String |
getAutoGain()
Returns the current autogain parameters of the sensor as a character string.
|
int |
getEstimatedHSL()
Returns the estimated color in HSL color model (0xHHSSLL).
|
String |
getEstimatedOkLab()
Returns the estimated color according to the OkLab color model.
|
int |
getEstimatedRGB()
Returns the estimated color in RGB color model (0xRRGGBB).
|
String |
getEstimatedXYZ()
Returns the estimated color according to the CIE XYZ color model.
|
int |
getEstimationModel()
Returns the predictive model used for color estimation (reflective or emissive).
|
int |
getGain()
Returns the current spectral channel detector gain exponent.
|
int |
getIntegrationTime()
Returns the current integration time for spectral measure, in milliseconds.
|
int |
getLedCalibration()
Returns the current sent to the illumination LEDs during the latest calibration.
|
int |
getLedCurrent()
Returns the amount of current sent to the illumination LEDs, for reflection measures.
|
String |
getNearHTMLColor()
Returns the name of the HTML color closest to the estimated color.
|
String |
getNearRAL1()
Returns the RAL Classic color closest to the estimated color, with a similarity ratio.
|
String |
getNearRAL2()
Returns the second closest RAL Classic color to the estimated color, with a similarity ratio.
|
String |
getNearRAL3()
Returns the third closest RAL Classic color to the estimated color, with a similarity ratio.
|
String |
getNearSimpleColor()
Returns the name of the basic color typically used to refer to the estimated color.
|
int |
getNearSimpleColorIndex()
Returns the index of the basic color typically used to refer to the estimated color (enumerated value).
|
int |
getSaturation()
Returns the current saturation state of the sensor, as an integer.
|
int |
getWorkingMode()
Returns the sensor working mode.
|
YColorSensor |
nextColorSensor()
Continues the enumeration of color sensors started using yFirstColorSensor().
|
int |
registerValueCallback(YColorSensor.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
set_autoGain(String newval)
Remember to call the saveToFlash() method of the module if the modification must be kept.
|
int |
set_estimationModel(int newval)
Changes the predictive model to be used for color estimation (reflective or emissive).
|
int |
set_gain(int newval)
Changes the spectral channel detector gain exponent.
|
int |
set_integrationTime(int newval)
Changes the integration time for spectral measure, in milliseconds.
|
int |
set_ledCalibration(int newval)
Remember the LED current sent to the illumination LEDs during a calibration.
|
int |
set_ledCurrent(int newval)
Changes the amount of current sent to the illumination LEDs, for reflection measures.
|
int |
set_workingMode(int newval)
Changes the sensor working mode.
|
int |
setAutoGain(String newval)
Remember to call the saveToFlash() method of the module if the modification must be kept.
|
int |
setEstimationModel(int newval)
Changes the predictive model to be used for color estimation (reflective or emissive).
|
int |
setGain(int newval)
Changes the spectral channel detector gain exponent.
|
int |
setIntegrationTime(int newval)
Changes the integration time for spectral measure, in milliseconds.
|
int |
setLedCalibration(int newval)
Remember the LED current sent to the illumination LEDs during a calibration.
|
int |
setLedCurrent(int newval)
Changes the amount of current sent to the illumination LEDs, for reflection measures.
|
int |
setWorkingMode(int newval)
Changes the sensor working mode.
|
int |
turnLedOff()
Turns off the built-in illumination LEDs.
|
int |
turnLedOn()
Turns on the built-in illumination LEDs using the same current as used during the latest calibration.
|
_AddToCache, _clearDataStreamCache, _decode_json_int, _decode_json_string, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _is_valid_pass, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, _uploadEx, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_serialNumber, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, isReadOnly, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userDatapublic static final int ESTIMATIONMODEL_REFLECTION
public static final int ESTIMATIONMODEL_EMISSION
public static final int ESTIMATIONMODEL_INVALID
public static final int WORKINGMODE_AUTO
public static final int WORKINGMODE_EXPERT
public static final int WORKINGMODE_AUTOGAIN
public static final int WORKINGMODE_INVALID
public static final int LEDCURRENT_INVALID
public static final int LEDCALIBRATION_INVALID
public static final int INTEGRATIONTIME_INVALID
public static final int GAIN_INVALID
public static final String AUTOGAIN_INVALID
public static final int SATURATION_INVALID
public static final int ESTIMATEDRGB_INVALID
public static final int ESTIMATEDHSL_INVALID
public static final String ESTIMATEDXYZ_INVALID
public static final String ESTIMATEDOKLAB_INVALID
public static final String NEARRAL1_INVALID
public static final String NEARRAL2_INVALID
public static final String NEARRAL3_INVALID
public static final String NEARHTMLCOLOR_INVALID
public static final int NEARSIMPLECOLORINDEX_BROWN
public static final int NEARSIMPLECOLORINDEX_RED
public static final int NEARSIMPLECOLORINDEX_ORANGE
public static final int NEARSIMPLECOLORINDEX_YELLOW
public static final int NEARSIMPLECOLORINDEX_WHITE
public static final int NEARSIMPLECOLORINDEX_GRAY
public static final int NEARSIMPLECOLORINDEX_BLACK
public static final int NEARSIMPLECOLORINDEX_GREEN
public static final int NEARSIMPLECOLORINDEX_BLUE
public static final int NEARSIMPLECOLORINDEX_PURPLE
public static final int NEARSIMPLECOLORINDEX_PINK
public static final int NEARSIMPLECOLORINDEX_INVALID
public static final String NEARSIMPLECOLOR_INVALID
protected int _estimationModel
protected int _workingMode
protected int _ledCurrent
protected int _ledCalibration
protected int _integrationTime
protected int _gain
protected String _autoGain
protected int _saturation
protected int _estimatedRGB
protected int _estimatedHSL
protected String _estimatedXYZ
protected String _estimatedOkLab
protected String _nearRAL1
protected String _nearRAL2
protected String _nearRAL3
protected String _nearHTMLColor
protected int _nearSimpleColorIndex
protected String _nearSimpleColor
protected YColorSensor.UpdateCallback _valueCallbackColorSensor
protected YColorSensor(YAPIContext ctx, String func)
func - : functionidprotected YColorSensor(String func)
func - : functionidprotected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val)
throws Exception
_parseAttr in class YFunctionExceptionpublic int get_estimationModel()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getEstimationModel()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_estimationModel(int newval)
throws YAPI_Exception
newval - : either YColorSensor.ESTIMATIONMODEL_REFLECTION or
YColorSensor.ESTIMATIONMODEL_EMISSION, according to the predictive model to be used for color
estimation (reflective or emissive)YAPI_Exception - on errorpublic int setEstimationModel(int newval)
throws YAPI_Exception
newval - : either YColorSensor.ESTIMATIONMODEL_REFLECTION or
YColorSensor.ESTIMATIONMODEL_EMISSION, according to the predictive model to be used for color
estimation (reflective or emissive)YAPI_Exception - on errorpublic int get_workingMode()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getWorkingMode()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_workingMode(int newval)
throws YAPI_Exception
newval - : a value among YColorSensor.WORKINGMODE_AUTO, YColorSensor.WORKINGMODE_EXPERT and
YColorSensor.WORKINGMODE_AUTOGAIN corresponding to the sensor working modeYAPI_Exception - on errorpublic int setWorkingMode(int newval)
throws YAPI_Exception
newval - : a value among YColorSensor.WORKINGMODE_AUTO, YColorSensor.WORKINGMODE_EXPERT and
YColorSensor.WORKINGMODE_AUTOGAIN corresponding to the sensor working modeYAPI_Exception - on errorpublic int get_ledCurrent()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getLedCurrent()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_ledCurrent(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the amount of current sent to the illumination LEDs,
for reflection measuresYAPI_Exception - on errorpublic int setLedCurrent(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the amount of current sent to the illumination LEDs,
for reflection measuresYAPI_Exception - on errorpublic int get_ledCalibration()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getLedCalibration()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_ledCalibration(int newval)
throws YAPI_Exception
newval - : an integerYAPI_Exception - on errorpublic int setLedCalibration(int newval)
throws YAPI_Exception
newval - : an integerYAPI_Exception - on errorpublic int get_integrationTime()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getIntegrationTime()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_integrationTime(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the integration time for spectral measure, in millisecondsYAPI_Exception - on errorpublic int setIntegrationTime(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the integration time for spectral measure, in millisecondsYAPI_Exception - on errorpublic int get_gain()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getGain()
throws YAPI_Exception
YAPI_Exception - on errorpublic int set_gain(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the spectral channel detector gain exponentYAPI_Exception - on errorpublic int setGain(int newval)
throws YAPI_Exception
newval - : an integer corresponding to the spectral channel detector gain exponentYAPI_Exception - on errorpublic String get_autoGain() throws YAPI_Exception
YAPI_Exception - on errorpublic String getAutoGain() throws YAPI_Exception
YAPI_Exception - on errorpublic int set_autoGain(String newval) throws YAPI_Exception
newval - : a stringYAPI_Exception - on errorpublic int setAutoGain(String newval) throws YAPI_Exception
newval - : a stringYAPI_Exception - on errorpublic int get_saturation()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getSaturation()
throws YAPI_Exception
YAPI_Exception - on errorpublic int get_estimatedRGB()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getEstimatedRGB()
throws YAPI_Exception
YAPI_Exception - on errorpublic int get_estimatedHSL()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getEstimatedHSL()
throws YAPI_Exception
YAPI_Exception - on errorpublic String get_estimatedXYZ() throws YAPI_Exception
YAPI_Exception - on errorpublic String getEstimatedXYZ() throws YAPI_Exception
YAPI_Exception - on errorpublic String get_estimatedOkLab() throws YAPI_Exception
YAPI_Exception - on errorpublic String getEstimatedOkLab() throws YAPI_Exception
YAPI_Exception - on errorpublic String get_nearRAL1() throws YAPI_Exception
YAPI_Exception - on errorpublic String getNearRAL1() throws YAPI_Exception
YAPI_Exception - on errorpublic String get_nearRAL2() throws YAPI_Exception
YAPI_Exception - on errorpublic String getNearRAL2() throws YAPI_Exception
YAPI_Exception - on errorpublic String get_nearRAL3() throws YAPI_Exception
YAPI_Exception - on errorpublic String getNearRAL3() throws YAPI_Exception
YAPI_Exception - on errorpublic String get_nearHTMLColor() throws YAPI_Exception
YAPI_Exception - on errorpublic String getNearHTMLColor() throws YAPI_Exception
YAPI_Exception - on errorpublic int get_nearSimpleColorIndex()
throws YAPI_Exception
YAPI_Exception - on errorpublic int getNearSimpleColorIndex()
throws YAPI_Exception
YAPI_Exception - on errorpublic String get_nearSimpleColor() throws YAPI_Exception
YAPI_Exception - on errorpublic String getNearSimpleColor() throws YAPI_Exception
YAPI_Exception - on errorpublic static YColorSensor FindColorSensor(String func)
func - : a string that uniquely characterizes the color sensor, for instance
MyDevice.colorSensor.public static YColorSensor FindColorSensorInContext(YAPIContext yctx, String func)
yctx - : a YAPI contextfunc - : a string that uniquely characterizes the color sensor, for instance
MyDevice.colorSensor.public int registerValueCallback(YColorSensor.UpdateCallback callback)
callback - : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback in class YFunctionpublic int configureAutoGain(String channel, int minRaw, int maxRaw, boolean noSatur) throws YAPI_Exception
channel - : reference channel to use for automated gain control.minRaw - : lower threshold for the measured raw value, below which the gain is
automatically increased as long as possible.maxRaw - : high threshold for the measured raw value, over which the gain is
automatically decreased as long as possible.noSatur - : enables gain reduction in case of sensor saturation.YAPI_Exception - on errorpublic int turnLedOn()
throws YAPI_Exception
YAPI_Exception - on errorpublic int turnLedOff()
throws YAPI_Exception
YAPI_Exception - on errorpublic YColorSensor nextColorSensor()
public static YColorSensor FirstColorSensor()
public static YColorSensor FirstColorSensorInContext(YAPIContext yctx)
yctx - : a YAPI context.Copyright © 2026. All rights reserved.