yocto_led.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_led.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindLed(), the high-level API for Led functions
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED 'AS IS' WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 
41 #ifndef YOCTO_LED_H
42 #define YOCTO_LED_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YLed return codes)
50 //--- (end of YLed return codes)
51 //--- (YLed definitions)
52 class YLed; // forward declaration
53 
54 typedef void (*YLedValueCallback)(YLed *func, const string& functionValue);
55 #ifndef _Y_POWER_ENUM
56 #define _Y_POWER_ENUM
57 typedef enum {
61 } Y_POWER_enum;
62 #endif
63 #ifndef _Y_BLINKING_ENUM
64 #define _Y_BLINKING_ENUM
65 typedef enum {
74 #endif
75 #define Y_LUMINOSITY_INVALID (YAPI_INVALID_UINT)
76 //--- (end of YLed definitions)
77 
78 //--- (YLed declaration)
87 #ifdef __BORLANDC__
88 #pragma option push -w-8022
89 #endif
90 //--- (end of YLed declaration)
91 protected:
92  //--- (YLed attributes)
93  // Attributes (function value cache)
98 
99  friend YLed *yFindLed(const string& func);
100  friend YLed *yFirstLed(void);
101 
102  // Function-specific method for parsing of JSON output and caching result
103  virtual int _parseAttr(YJSONObject* json_val);
104 
105  // Constructor is protected, use yFindLed factory function to instantiate
106  YLed(const string& func);
107  //--- (end of YLed attributes)
108 
109 public:
110  ~YLed();
111  //--- (YLed accessors declaration)
112 
113  static const Y_POWER_enum POWER_OFF = Y_POWER_OFF;
114  static const Y_POWER_enum POWER_ON = Y_POWER_ON;
115  static const Y_POWER_enum POWER_INVALID = Y_POWER_INVALID;
116  static const int LUMINOSITY_INVALID = YAPI_INVALID_UINT;
117  static const Y_BLINKING_enum BLINKING_STILL = Y_BLINKING_STILL;
118  static const Y_BLINKING_enum BLINKING_RELAX = Y_BLINKING_RELAX;
119  static const Y_BLINKING_enum BLINKING_AWARE = Y_BLINKING_AWARE;
120  static const Y_BLINKING_enum BLINKING_RUN = Y_BLINKING_RUN;
121  static const Y_BLINKING_enum BLINKING_CALL = Y_BLINKING_CALL;
122  static const Y_BLINKING_enum BLINKING_PANIC = Y_BLINKING_PANIC;
123  static const Y_BLINKING_enum BLINKING_INVALID = Y_BLINKING_INVALID;
124 
132  Y_POWER_enum get_power(void);
133 
134  inline Y_POWER_enum power(void)
135  { return this->get_power(); }
136 
146  int set_power(Y_POWER_enum newval);
147  inline int setPower(Y_POWER_enum newval)
148  { return this->set_power(newval); }
149 
157  int get_luminosity(void);
158 
159  inline int luminosity(void)
160  { return this->get_luminosity(); }
161 
171  int set_luminosity(int newval);
172  inline int setLuminosity(int newval)
173  { return this->set_luminosity(newval); }
174 
183  Y_BLINKING_enum get_blinking(void);
184 
186  { return this->get_blinking(); }
187 
198  int set_blinking(Y_BLINKING_enum newval);
199  inline int setBlinking(Y_BLINKING_enum newval)
200  { return this->set_blinking(newval); }
201 
229  static YLed* FindLed(string func);
230 
242  virtual int registerValueCallback(YLedValueCallback callback);
244 
245  virtual int _invokeValueCallback(string value);
246 
247 
248  inline static YLed* Find(string func)
249  { return YLed::FindLed(func); }
250 
258  YLed *nextLed(void);
259  inline YLed *next(void)
260  { return this->nextLed();}
261 
271  static YLed* FirstLed(void);
272  inline static YLed* First(void)
273  { return YLed::FirstLed();}
274 #ifdef __BORLANDC__
275 #pragma option pop
276 #endif
277  //--- (end of YLed accessors declaration)
278 };
279 
280 //--- (YLed functions declaration)
281 
309 inline YLed* yFindLed(const string& func)
310 { return YLed::FindLed(func);}
320 inline YLed* yFirstLed(void)
321 { return YLed::FirstLed();}
322 
323 //--- (end of YLed functions declaration)
324 
325 #endif
int setPower(Y_POWER_enum newval)
Definition: yocto_led.h:147
void(* YLedValueCallback)(YLed *func, const string &functionValue)
Definition: yocto_led.h:54
static YLed * Find(string func)
Definition: yocto_led.h:248
static YLed * First(void)
Definition: yocto_led.h:272
Y_POWER_enum
Definition: yocto_led.h:57
int luminosity(void)
Definition: yocto_led.h:159
Y_POWER_enum power(void)
Definition: yocto_led.h:134
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
static YLed * FindLed(string func)
Definition: yocto_led.cpp:276
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
YLed * next(void)
Definition: yocto_led.h:259
static YLed * FirstLed(void)
Definition: yocto_led.cpp:347
YLed * yFirstLed(void)
Definition: yocto_led.h:320
Y_BLINKING_enum blinking(void)
Definition: yocto_led.h:185
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
Y_BLINKING_enum
Definition: yocto_led.h:65
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
YLedValueCallback _valueCallbackLed
Definition: yocto_led.h:97
int _luminosity
Definition: yocto_led.h:95
Definition: yocto_led.h:86
YLed * yFindLed(const string &func)
Definition: yocto_led.h:309
int setLuminosity(int newval)
Definition: yocto_led.h:172
int setBlinking(Y_BLINKING_enum newval)
Definition: yocto_led.h:199
Y_POWER_enum _power
Definition: yocto_led.h:94
Y_BLINKING_enum _blinking
Definition: yocto_led.h:96
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563


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