#include <yocto_colorled.h>
Public Member Functions | |
virtual int | _invokeValueCallback (string value) |
virtual int | addHslMoveToBlinkSeq (int HSLcolor, int msDelay) |
virtual int | addRgbMoveToBlinkSeq (int RGBcolor, int msDelay) |
int | blinkSeqMaxSize (void) |
int | blinkSeqSignature (void) |
int | blinkSeqSize (void) |
string | command (void) |
int | get_blinkSeqMaxSize (void) |
int | get_blinkSeqSignature (void) |
int | get_blinkSeqSize (void) |
string | get_command (void) |
int | get_hslColor (void) |
YMove | get_hslMove (void) |
int | get_rgbColor (void) |
int | get_rgbColorAtPowerOn (void) |
YMove | get_rgbMove (void) |
int | hslColor (void) |
YMove | hslMove (void) |
int | hslMove (int hsl_target, int ms_duration) |
YColorLed * | next (void) |
YColorLed * | nextColorLed (void) |
virtual int | registerValueCallback (YColorLedValueCallback callback) |
virtual int | resetBlinkSeq (void) |
int | rgbColor (void) |
int | rgbColorAtPowerOn (void) |
YMove | rgbMove (void) |
int | rgbMove (int rgb_target, int ms_duration) |
virtual int | sendCommand (string command) |
int | set_command (const string &newval) |
int | set_hslColor (int newval) |
int | set_hslMove (YMove newval) |
int | set_rgbColor (int newval) |
int | set_rgbColorAtPowerOn (int newval) |
int | set_rgbMove (YMove newval) |
int | setCommand (const string &newval) |
int | setHslColor (int newval) |
int | setHslMove (YMove newval) |
int | setRgbColor (int newval) |
int | setRgbColorAtPowerOn (int newval) |
int | setRgbMove (YMove newval) |
virtual int | startBlinkSeq (void) |
virtual int | stopBlinkSeq (void) |
~YColorLed () | |
Public Member Functions inherited from YFunction | |
void | _clearDataStreamCache () |
string | _decode_json_string (const string &json) |
string | _download (const string &url) |
YDataStream * | _findDataStream (YDataSet &dataset, const string &def) |
string | _get_json_path (const string &json, const string &path) |
vector< string > | _json_get_array (const string &json) |
string | _json_get_key (const string &json, const string &data) |
string | _json_get_string (const string &json) |
int | _parseEx (yJsonStateMachine &j) |
virtual int | _parserHelper (void) |
string | _parseString (yJsonStateMachine &j) |
string | _request (const string &request) |
string | _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context) |
void | _throw (YRETCODE errType, string errMsg) |
YRETCODE | _upload (const string &path, const string &content) |
YRETCODE | _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context) |
string | advertisedValue (void) |
void | clearCache () |
string | describe (void) |
string | errMessage (void) |
string | errorMessage (void) |
YRETCODE | errorType (void) |
YRETCODE | errType (void) |
YFUN_DESCR | functionDescriptor (void) |
string | get_advertisedValue (void) |
string | get_errorMessage (void) |
YRETCODE | get_errorType (void) |
virtual string | get_friendlyName (void) |
YFUN_DESCR | get_functionDescriptor (void) |
string | get_functionId (void) |
string | get_hardwareId (void) |
string | get_hubSerial () |
string | get_logicalName (void) |
YModule * | get_module (void) |
void * | get_userData (void) |
bool | isOnline (void) |
YRETCODE | load (int msValidity) |
virtual string | loadAttribute (string attrName) |
string | logicalName (void) |
YModule * | module (void) |
virtual int | muteValueCallbacks (void) |
YFunction * | next (void) |
YFunction * | nextFunction (void) |
virtual int | registerValueCallback (YFunctionValueCallback callback) |
int | set_advertisedValue (const string &newval) |
int | set_logicalName (const string &newval) |
void | set_userData (void *data) |
int | setAdvertisedValue (const string &newval) |
int | setLogicalName (const string &newval) |
void | setUserData (void *data) |
virtual int | unmuteValueCallbacks (void) |
void * | userData (void) |
virtual | ~YFunction () |
Static Public Member Functions | |
static YColorLed * | Find (string func) |
static YColorLed * | FindColorLed (string func) |
static YColorLed * | First (void) |
static YColorLed * | FirstColorLed (void) |
Static Public Member Functions inherited from YFunction | |
static void | _ClearCache (void) |
static YFunction * | Find (string func) |
static YFunction * | FindFunction (string func) |
static YFunction * | First (void) |
static YFunction * | FirstFunction (void) |
Static Public Attributes | |
static const int | BLINKSEQMAXSIZE_INVALID = YAPI_INVALID_UINT |
static const int | BLINKSEQSIGNATURE_INVALID = YAPI_INVALID_UINT |
static const int | BLINKSEQSIZE_INVALID = YAPI_INVALID_UINT |
static const string | COMMAND_INVALID = YAPI_INVALID_STRING |
static const int | HSLCOLOR_INVALID = YAPI_INVALID_UINT |
static const YMove | HSLMOVE_INVALID = YMove() |
static const int | RGBCOLOR_INVALID = YAPI_INVALID_UINT |
static const int | RGBCOLORATPOWERON_INVALID = YAPI_INVALID_UINT |
static const YMove | RGBMOVE_INVALID = YMove() |
Static Public Attributes inherited from YFunction | |
static const string | ADVERTISEDVALUE_INVALID = YAPI_INVALID_STRING |
static const string | FRIENDLYNAME_INVALID = YAPI_INVALID_STRING |
static const YFUN_DESCR | FUNCTIONDESCRIPTOR_INVALID = Y_FUNCTIONDESCRIPTOR_INVALID |
static const string | FUNCTIONID_INVALID = YAPI_INVALID_STRING |
static const string | HARDWAREID_INVALID = YAPI_INVALID_STRING |
static const string | LOGICALNAME_INVALID = YAPI_INVALID_STRING |
Protected Member Functions | |
virtual int | _parseAttr (YJSONObject *json_val) |
YColorLed (const string &func) | |
Protected Member Functions inherited from YFunction | |
YRETCODE | _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg) |
string | _escapeAttr (const string &changeval) |
YRETCODE | _getDescriptor (YFUN_DESCR &fundescr, string &errMsg) |
YRETCODE | _getDevice (YDevice *&dev, string &errMsg) |
YRETCODE | _load_unsafe (int msValidity) |
YRETCODE | _nextFunction (string &hwId) |
int | _parse (YJSONObject *j) |
YRETCODE | _setAttr (string attrname, string newvalue) |
YFunction (const string &func) | |
Protected Attributes | |
int | _blinkSeqMaxSize |
int | _blinkSeqSignature |
int | _blinkSeqSize |
string | _command |
int | _hslColor |
YMove | _hslMove |
int | _rgbColor |
int | _rgbColorAtPowerOn |
YMove | _rgbMove |
YColorLedValueCallback | _valueCallbackColorLed |
Protected Attributes inherited from YFunction | |
string | _advertisedValue |
u64 | _cacheExpiration |
string | _className |
std::map< string, YDataStream * > | _dataStreams |
string | _func |
YFUN_DESCR | _fundescr |
string | _funId |
string | _hwId |
string | _lastErrorMsg |
YRETCODE | _lastErrorType |
string | _logicalName |
string | _serial |
yCRITICAL_SECTION | _this_cs |
void * | _userData |
YFunctionValueCallback | _valueCallbackFunction |
Friends | |
YColorLed * | yFindColorLed (const string &func) |
YColorLed * | yFirstColorLed (void) |
Additional Inherited Members | |
Static Protected Member Functions inherited from YFunction | |
static void | _AddToCache (const string &classname, const string &func, YFunction *obj) |
static YFunction * | _FindFromCache (const string &classname, const string &func) |
static void | _UpdateTimedReportCallbackList (YFunction *func, bool add) |
static void | _UpdateValueCallbackList (YFunction *func, bool add) |
Static Protected Attributes inherited from YFunction | |
static std::map< string, YFunction * > | _cache |
YColorLed Class: ColorLed function interface
The Yoctopuce application programming interface allows you to drive a color LED using RGB coordinates as well as HSL coordinates. The module performs all conversions form RGB to HSL automatically. It is then self-evident to turn on a LED with a given hue and to progressively vary its saturation or lightness. If needed, you can find more information on the difference between RGB and HSL in the section following this one.
Definition at line 92 of file yocto_colorled.h.
|
protected |
Definition at line 51 of file yocto_colorled.cpp.
YColorLed::~YColorLed | ( | ) |
Definition at line 68 of file yocto_colorled.cpp.
|
virtual |
Reimplemented from YFunction.
Definition at line 609 of file yocto_colorled.cpp.
|
protectedvirtual |
Reimplemented from YFunction.
Definition at line 79 of file yocto_colorled.cpp.
|
virtual |
Add a new transition to the blinking sequence, the move will be performed in the HSL space.
HSLcolor | : desired HSL color when the traisntion is completed |
msDelay | : duration of the color transition, in milliseconds. |
Definition at line 634 of file yocto_colorled.cpp.
|
virtual |
Adds a new transition to the blinking sequence, the move is performed in the RGB space.
RGBcolor | : desired RGB color when the transition is completed |
msDelay | : duration of the color transition, in milliseconds. |
Definition at line 649 of file yocto_colorled.cpp.
|
inline |
Definition at line 274 of file yocto_colorled.h.
|
inline |
Definition at line 289 of file yocto_colorled.h.
|
inline |
Definition at line 262 of file yocto_colorled.h.
|
inline |
Definition at line 294 of file yocto_colorled.h.
|
inlinestatic |
Definition at line 399 of file yocto_colorled.h.
|
static |
Retrieves an RGB LED for a given identifier. The identifier can be specified using several formats:
This function does not require that the RGB LED is online at the time it is invoked. The returned object is nevertheless valid. Use the method YColorLed.isOnline() to test if the RGB LED is indeed online at a given time. In case of ambiguity when looking for an RGB LED by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
func | : a string that uniquely characterizes the RGB LED |
Definition at line 558 of file yocto_colorled.cpp.
|
inlinestatic |
Definition at line 423 of file yocto_colorled.h.
|
static |
Starts the enumeration of RGB LEDs currently accessible. Use the method YColorLed.nextColorLed() to iterate on next RGB LEDs.
Definition at line 699 of file yocto_colorled.cpp.
int YColorLed::get_blinkSeqMaxSize | ( | void | ) |
Returns the maximum length of the blinking sequence.
On failure, throws an exception or returns Y_BLINKSEQMAXSIZE_INVALID.
Definition at line 439 of file yocto_colorled.cpp.
int YColorLed::get_blinkSeqSignature | ( | void | ) |
Return the blinking sequence signature. Since blinking sequences cannot be read from the device, this can be used to detect if a specific blinking sequence is already programmed.
On failure, throws an exception or returns Y_BLINKSEQSIGNATURE_INVALID.
Definition at line 471 of file yocto_colorled.cpp.
int YColorLed::get_blinkSeqSize | ( | void | ) |
Returns the current length of the blinking sequence.
On failure, throws an exception or returns Y_BLINKSEQSIZE_INVALID.
Definition at line 410 of file yocto_colorled.cpp.
string YColorLed::get_command | ( | void | ) |
Definition at line 493 of file yocto_colorled.cpp.
int YColorLed::get_hslColor | ( | void | ) |
Returns the current HSL color of the LED.
On failure, throws an exception or returns Y_HSLCOLOR_INVALID.
Definition at line 191 of file yocto_colorled.cpp.
YMove YColorLed::get_hslMove | ( | void | ) |
Definition at line 293 of file yocto_colorled.cpp.
int YColorLed::get_rgbColor | ( | void | ) |
Returns the current RGB color of the LED.
On failure, throws an exception or returns Y_RGBCOLOR_INVALID.
Definition at line 137 of file yocto_colorled.cpp.
int YColorLed::get_rgbColorAtPowerOn | ( | void | ) |
Returns the configured color to be displayed when the module is turned on.
On failure, throws an exception or returns Y_RGBCOLORATPOWERON_INVALID.
Definition at line 355 of file yocto_colorled.cpp.
YMove YColorLed::get_rgbMove | ( | void | ) |
Definition at line 238 of file yocto_colorled.cpp.
|
inline |
Definition at line 169 of file yocto_colorled.h.
|
inline |
Definition at line 208 of file yocto_colorled.h.
int YColorLed::hslMove | ( | int | hsl_target, |
int | ms_duration | ||
) |
Performs a smooth transition in the HSL color space between the current color and a target color.
hsl_target | : desired HSL color at the end of the transition |
ms_duration | : duration of the transition, in millisecond |
On failure, throws an exception or returns a negative error code.
Definition at line 341 of file yocto_colorled.cpp.
|
inline |
Definition at line 410 of file yocto_colorled.h.
YColorLed * YColorLed::nextColorLed | ( | void | ) |
Continues the enumeration of RGB LEDs started using yFirstColorLed().
Definition at line 689 of file yocto_colorled.cpp.
|
virtual |
Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.
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. |
Definition at line 590 of file yocto_colorled.cpp.
|
virtual |
Resets the preprogrammed blinking sequence.
Definition at line 684 of file yocto_colorled.cpp.
|
inline |
Definition at line 144 of file yocto_colorled.h.
|
inline |
Definition at line 236 of file yocto_colorled.h.
|
inline |
Definition at line 187 of file yocto_colorled.h.
int YColorLed::rgbMove | ( | int | rgb_target, |
int | ms_duration | ||
) |
Performs a smooth transition in the RGB color space between the current color and a target color.
rgb_target | : desired RGB color at the end of the transition |
ms_duration | : duration of the transition, in millisecond |
On failure, throws an exception or returns a negative error code.
Definition at line 286 of file yocto_colorled.cpp.
|
virtual |
Definition at line 619 of file yocto_colorled.cpp.
int YColorLed::set_command | ( | const string & | newval | ) |
Definition at line 515 of file yocto_colorled.cpp.
int YColorLed::set_hslColor | ( | int | newval | ) |
Changes the current color of the LED, using a color HSL. Encoding is done as follows: 0xHHSSLL.
newval | : an integer corresponding to the current color of the LED, using a color HSL |
On failure, throws an exception or returns a negative error code.
Definition at line 222 of file yocto_colorled.cpp.
int YColorLed::set_hslMove | ( | YMove | newval | ) |
Definition at line 315 of file yocto_colorled.cpp.
int YColorLed::set_rgbColor | ( | int | newval | ) |
Changes the current color of the LED, using an RGB color. Encoding is done as follows: 0xRRGGBB.
newval | : an integer corresponding to the current color of the LED, using an RGB color |
On failure, throws an exception or returns a negative error code.
Definition at line 168 of file yocto_colorled.cpp.
int YColorLed::set_rgbColorAtPowerOn | ( | int | newval | ) |
Changes the color that the LED will display by default when the module is turned on.
newval | : an integer corresponding to the color that the LED will display by default when the module is turned on |
On failure, throws an exception or returns a negative error code.
Definition at line 387 of file yocto_colorled.cpp.
int YColorLed::set_rgbMove | ( | YMove | newval | ) |
Definition at line 260 of file yocto_colorled.cpp.
|
inline |
Definition at line 298 of file yocto_colorled.h.
|
inline |
Definition at line 182 of file yocto_colorled.h.
|
inline |
Definition at line 212 of file yocto_colorled.h.
|
inline |
Definition at line 157 of file yocto_colorled.h.
|
inline |
Definition at line 250 of file yocto_colorled.h.
|
inline |
Definition at line 191 of file yocto_colorled.h.
|
virtual |
Starts the preprogrammed blinking sequence. The sequence is run in a loop until it is stopped by stopBlinkSeq or an explicit change.
Definition at line 662 of file yocto_colorled.cpp.
|
virtual |
Stops the preprogrammed blinking sequence.
Definition at line 673 of file yocto_colorled.cpp.
|
friend |
Retrieves an RGB LED for a given identifier. The identifier can be specified using several formats:
This function does not require that the RGB LED is online at the time it is invoked. The returned object is nevertheless valid. Use the method YColorLed.isOnline() to test if the RGB LED is indeed online at a given time. In case of ambiguity when looking for an RGB LED by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
func | : a string that uniquely characterizes the RGB LED |
Definition at line 460 of file yocto_colorled.h.
|
friend |
Starts the enumeration of RGB LEDs currently accessible. Use the method YColorLed.nextColorLed() to iterate on next RGB LEDs.
Definition at line 471 of file yocto_colorled.h.
|
protected |
Definition at line 106 of file yocto_colorled.h.
|
protected |
Definition at line 107 of file yocto_colorled.h.
|
protected |
Definition at line 105 of file yocto_colorled.h.
|
protected |
Definition at line 108 of file yocto_colorled.h.
|
protected |
Definition at line 101 of file yocto_colorled.h.
|
protected |
Definition at line 103 of file yocto_colorled.h.
|
protected |
Definition at line 100 of file yocto_colorled.h.
|
protected |
Definition at line 104 of file yocto_colorled.h.
|
protected |
Definition at line 102 of file yocto_colorled.h.
|
protected |
Definition at line 109 of file yocto_colorled.h.
|
static |
Definition at line 131 of file yocto_colorled.h.
|
static |
Definition at line 132 of file yocto_colorled.h.
|
static |
Definition at line 130 of file yocto_colorled.h.
|
static |
Definition at line 133 of file yocto_colorled.h.
|
static |
Definition at line 126 of file yocto_colorled.h.
Definition at line 128 of file yocto_colorled.h.
|
static |
Definition at line 125 of file yocto_colorled.h.
|
static |
Definition at line 129 of file yocto_colorled.h.
Definition at line 127 of file yocto_colorled.h.