Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
YColorLed Class Reference

#include <yocto_colorled.h>

Inheritance diagram for YColorLed:
Inheritance graph
[legend]

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)
 
YColorLednext (void)
 
YColorLednextColorLed (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)
 
YModuleget_module (void)
 
void * get_userData (void)
 
bool isOnline (void)
 
YRETCODE load (int msValidity)
 
virtual string loadAttribute (string attrName)
 
string logicalName (void)
 
YModulemodule (void)
 
virtual int muteValueCallbacks (void)
 
YFunctionnext (void)
 
YFunctionnextFunction (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 YColorLedFind (string func)
 
static YColorLedFindColorLed (string func)
 
static YColorLedFirst (void)
 
static YColorLedFirstColorLed (void)
 
- Static Public Member Functions inherited from YFunction
static void _ClearCache (void)
 
static YFunctionFind (string func)
 
static YFunctionFindFunction (string func)
 
static YFunctionFirst (void)
 
static YFunctionFirstFunction (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

YColorLedyFindColorLed (const string &func)
 
YColorLedyFirstColorLed (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
 

Detailed Description

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.

Constructor & Destructor Documentation

YColorLed::YColorLed ( const string &  func)
protected

Definition at line 51 of file yocto_colorled.cpp.

YColorLed::~YColorLed ( )

Definition at line 68 of file yocto_colorled.cpp.

Member Function Documentation

int YColorLed::_invokeValueCallback ( string  value)
virtual

Reimplemented from YFunction.

Definition at line 609 of file yocto_colorled.cpp.

int YColorLed::_parseAttr ( YJSONObject json_val)
protectedvirtual

Reimplemented from YFunction.

Definition at line 79 of file yocto_colorled.cpp.

int YColorLed::addHslMoveToBlinkSeq ( int  HSLcolor,
int  msDelay 
)
virtual

Add a new transition to the blinking sequence, the move will be performed in the HSL space.

Parameters
HSLcolor: desired HSL color when the traisntion is completed
msDelay: duration of the color transition, in milliseconds.
Returns
YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 634 of file yocto_colorled.cpp.

int YColorLed::addRgbMoveToBlinkSeq ( int  RGBcolor,
int  msDelay 
)
virtual

Adds a new transition to the blinking sequence, the move is performed in the RGB space.

Parameters
RGBcolor: desired RGB color when the transition is completed
msDelay: duration of the color transition, in milliseconds.
Returns
YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 649 of file yocto_colorled.cpp.

int YColorLed::blinkSeqMaxSize ( void  )
inline

Definition at line 274 of file yocto_colorled.h.

int YColorLed::blinkSeqSignature ( void  )
inline

Definition at line 289 of file yocto_colorled.h.

int YColorLed::blinkSeqSize ( void  )
inline

Definition at line 262 of file yocto_colorled.h.

string YColorLed::command ( void  )
inline

Definition at line 294 of file yocto_colorled.h.

static YColorLed* YColorLed::Find ( string  func)
inlinestatic

Definition at line 399 of file yocto_colorled.h.

YColorLed * YColorLed::FindColorLed ( string  func)
static

Retrieves an RGB LED for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

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.

Parameters
func: a string that uniquely characterizes the RGB LED
Returns
a YColorLed object allowing you to drive the RGB LED.

Definition at line 558 of file yocto_colorled.cpp.

static YColorLed* YColorLed::First ( void  )
inlinestatic

Definition at line 423 of file yocto_colorled.h.

YColorLed * YColorLed::FirstColorLed ( void  )
static

Starts the enumeration of RGB LEDs currently accessible. Use the method YColorLed.nextColorLed() to iterate on next RGB LEDs.

Returns
a pointer to a YColorLed object, corresponding to the first RGB LED currently online, or a NULL pointer if there are none.

Definition at line 699 of file yocto_colorled.cpp.

int YColorLed::get_blinkSeqMaxSize ( void  )

Returns the maximum length of the blinking sequence.

Returns
an integer corresponding to 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.

Returns
an integer

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.

Returns
an integer corresponding to 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.

Returns
an integer corresponding to 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.

Returns
an integer corresponding to 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.

Returns
an integer corresponding to 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.

int YColorLed::hslColor ( void  )
inline

Definition at line 169 of file yocto_colorled.h.

YMove YColorLed::hslMove ( void  )
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.

Parameters
hsl_target: desired HSL color at the end of the transition
ms_duration: duration of the transition, in millisecond
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 341 of file yocto_colorled.cpp.

YColorLed* YColorLed::next ( void  )
inline

Definition at line 410 of file yocto_colorled.h.

YColorLed * YColorLed::nextColorLed ( void  )

Continues the enumeration of RGB LEDs started using yFirstColorLed().

Returns
a pointer to a YColorLed object, corresponding to an RGB LED currently online, or a NULL pointer if there are no more RGB LEDs to enumerate.

Definition at line 689 of file yocto_colorled.cpp.

int YColorLed::registerValueCallback ( YColorLedValueCallback  callback)
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.

Parameters
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.

int YColorLed::resetBlinkSeq ( void  )
virtual

Resets the preprogrammed blinking sequence.

Returns
YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 684 of file yocto_colorled.cpp.

int YColorLed::rgbColor ( void  )
inline

Definition at line 144 of file yocto_colorled.h.

int YColorLed::rgbColorAtPowerOn ( void  )
inline

Definition at line 236 of file yocto_colorled.h.

YMove YColorLed::rgbMove ( void  )
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.

Parameters
rgb_target: desired RGB color at the end of the transition
ms_duration: duration of the transition, in millisecond
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 286 of file yocto_colorled.cpp.

int YColorLed::sendCommand ( string  command)
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.

Parameters
newval: an integer corresponding to the current color of the LED, using a color HSL
Returns
YAPI_SUCCESS if the call succeeds.

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.

Parameters
newval: an integer corresponding to the current color of the LED, using an RGB color
Returns
YAPI_SUCCESS if the call succeeds.

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.

Parameters
newval: an integer corresponding to the color that the LED will display by default when the module is turned on
Returns
YAPI_SUCCESS if the call succeeds.

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.

int YColorLed::setCommand ( const string &  newval)
inline

Definition at line 298 of file yocto_colorled.h.

int YColorLed::setHslColor ( int  newval)
inline

Definition at line 182 of file yocto_colorled.h.

int YColorLed::setHslMove ( YMove  newval)
inline

Definition at line 212 of file yocto_colorled.h.

int YColorLed::setRgbColor ( int  newval)
inline

Definition at line 157 of file yocto_colorled.h.

int YColorLed::setRgbColorAtPowerOn ( int  newval)
inline

Definition at line 250 of file yocto_colorled.h.

int YColorLed::setRgbMove ( YMove  newval)
inline

Definition at line 191 of file yocto_colorled.h.

int YColorLed::startBlinkSeq ( void  )
virtual

Starts the preprogrammed blinking sequence. The sequence is run in a loop until it is stopped by stopBlinkSeq or an explicit change.

Returns
YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 662 of file yocto_colorled.cpp.

int YColorLed::stopBlinkSeq ( void  )
virtual

Stops the preprogrammed blinking sequence.

Returns
YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 673 of file yocto_colorled.cpp.

Friends And Related Function Documentation

YColorLed* yFindColorLed ( const string &  func)
friend

Retrieves an RGB LED for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

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.

Parameters
func: a string that uniquely characterizes the RGB LED
Returns
a YColorLed object allowing you to drive the RGB LED.

Definition at line 460 of file yocto_colorled.h.

YColorLed* yFirstColorLed ( void  )
friend

Starts the enumeration of RGB LEDs currently accessible. Use the method YColorLed.nextColorLed() to iterate on next RGB LEDs.

Returns
a pointer to a YColorLed object, corresponding to the first RGB LED currently online, or a NULL pointer if there are none.

Definition at line 471 of file yocto_colorled.h.

Member Data Documentation

int YColorLed::_blinkSeqMaxSize
protected

Definition at line 106 of file yocto_colorled.h.

int YColorLed::_blinkSeqSignature
protected

Definition at line 107 of file yocto_colorled.h.

int YColorLed::_blinkSeqSize
protected

Definition at line 105 of file yocto_colorled.h.

string YColorLed::_command
protected

Definition at line 108 of file yocto_colorled.h.

int YColorLed::_hslColor
protected

Definition at line 101 of file yocto_colorled.h.

YMove YColorLed::_hslMove
protected

Definition at line 103 of file yocto_colorled.h.

int YColorLed::_rgbColor
protected

Definition at line 100 of file yocto_colorled.h.

int YColorLed::_rgbColorAtPowerOn
protected

Definition at line 104 of file yocto_colorled.h.

YMove YColorLed::_rgbMove
protected

Definition at line 102 of file yocto_colorled.h.

YColorLedValueCallback YColorLed::_valueCallbackColorLed
protected

Definition at line 109 of file yocto_colorled.h.

const int YColorLed::BLINKSEQMAXSIZE_INVALID = YAPI_INVALID_UINT
static

Definition at line 131 of file yocto_colorled.h.

const int YColorLed::BLINKSEQSIGNATURE_INVALID = YAPI_INVALID_UINT
static

Definition at line 132 of file yocto_colorled.h.

const int YColorLed::BLINKSEQSIZE_INVALID = YAPI_INVALID_UINT
static

Definition at line 130 of file yocto_colorled.h.

const string YColorLed::COMMAND_INVALID = YAPI_INVALID_STRING
static

Definition at line 133 of file yocto_colorled.h.

const int YColorLed::HSLCOLOR_INVALID = YAPI_INVALID_UINT
static

Definition at line 126 of file yocto_colorled.h.

const YMove YColorLed::HSLMOVE_INVALID = YMove()
static

Definition at line 128 of file yocto_colorled.h.

const int YColorLed::RGBCOLOR_INVALID = YAPI_INVALID_UINT
static

Definition at line 125 of file yocto_colorled.h.

const int YColorLed::RGBCOLORATPOWERON_INVALID = YAPI_INVALID_UINT
static

Definition at line 129 of file yocto_colorled.h.

const YMove YColorLed::RGBMOVE_INVALID = YMove()
static

Definition at line 127 of file yocto_colorled.h.


The documentation for this class was generated from the following files:


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13