yocto_pwminput.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_pwminput.h 28807 2017-10-12 09:46:33Z seb $
4  *
5  * Declares yFindPwmInput(), the high-level API for PwmInput 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_PWMINPUT_H
42 #define YOCTO_PWMINPUT_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YPwmInput return codes)
50 //--- (end of YPwmInput return codes)
51 //--- (YPwmInput definitions)
52 class YPwmInput; // forward declaration
53 
54 typedef void (*YPwmInputValueCallback)(YPwmInput *func, const string& functionValue);
55 class YMeasure; // forward declaration
56 typedef void (*YPwmInputTimedReportCallback)(YPwmInput *func, YMeasure measure);
57 #ifndef _Y_PWMREPORTMODE_ENUM
58 #define _Y_PWMREPORTMODE_ENUM
59 typedef enum {
70 #endif
71 #define Y_DUTYCYCLE_INVALID (YAPI_INVALID_DOUBLE)
72 #define Y_PULSEDURATION_INVALID (YAPI_INVALID_DOUBLE)
73 #define Y_FREQUENCY_INVALID (YAPI_INVALID_DOUBLE)
74 #define Y_PERIOD_INVALID (YAPI_INVALID_DOUBLE)
75 #define Y_PULSECOUNTER_INVALID (YAPI_INVALID_LONG)
76 #define Y_PULSETIMER_INVALID (YAPI_INVALID_LONG)
77 #define Y_DEBOUNCEPERIOD_INVALID (YAPI_INVALID_UINT)
78 //--- (end of YPwmInput definitions)
79 
80 //--- (YPwmInput declaration)
91 #ifdef __BORLANDC__
92 #pragma option push -w-8022
93 #endif
94 //--- (end of YPwmInput declaration)
95 protected:
96  //--- (YPwmInput attributes)
97  // Attributes (function value cache)
98  double _dutyCycle;
100  double _frequency;
101  double _period;
108 
109  friend YPwmInput *yFindPwmInput(const string& func);
110  friend YPwmInput *yFirstPwmInput(void);
111 
112  // Function-specific method for parsing of JSON output and caching result
113  virtual int _parseAttr(YJSONObject* json_val);
114 
115  // Constructor is protected, use yFindPwmInput factory function to instantiate
116  YPwmInput(const string& func);
117  //--- (end of YPwmInput attributes)
118 
119 public:
120  ~YPwmInput();
121  //--- (YPwmInput accessors declaration)
122 
123  static const double DUTYCYCLE_INVALID;
124  static const double PULSEDURATION_INVALID;
125  static const double FREQUENCY_INVALID;
126  static const double PERIOD_INVALID;
127  static const s64 PULSECOUNTER_INVALID = YAPI_INVALID_LONG;
128  static const s64 PULSETIMER_INVALID = YAPI_INVALID_LONG;
129  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_DUTYCYCLE = Y_PWMREPORTMODE_PWM_DUTYCYCLE;
130  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_FREQUENCY = Y_PWMREPORTMODE_PWM_FREQUENCY;
131  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_PULSEDURATION = Y_PWMREPORTMODE_PWM_PULSEDURATION;
132  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_EDGECOUNT = Y_PWMREPORTMODE_PWM_EDGECOUNT;
133  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_PULSECOUNT = Y_PWMREPORTMODE_PWM_PULSECOUNT;
134  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_CPS = Y_PWMREPORTMODE_PWM_CPS;
135  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_CPM = Y_PWMREPORTMODE_PWM_CPM;
136  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_PWM_STATE = Y_PWMREPORTMODE_PWM_STATE;
137  static const Y_PWMREPORTMODE_enum PWMREPORTMODE_INVALID = Y_PWMREPORTMODE_INVALID;
138  static const int DEBOUNCEPERIOD_INVALID = YAPI_INVALID_UINT;
139 
147  double get_dutyCycle(void);
148 
149  inline double dutyCycle(void)
150  { return this->get_dutyCycle(); }
151 
160  double get_pulseDuration(void);
161 
162  inline double pulseDuration(void)
163  { return this->get_pulseDuration(); }
164 
172  double get_frequency(void);
173 
174  inline double frequency(void)
175  { return this->get_frequency(); }
176 
184  double get_period(void);
185 
186  inline double period(void)
187  { return this->get_period(); }
188 
198  s64 get_pulseCounter(void);
199 
200  inline s64 pulseCounter(void)
201  { return this->get_pulseCounter(); }
202 
203  int set_pulseCounter(s64 newval);
204  inline int setPulseCounter(s64 newval)
205  { return this->set_pulseCounter(newval); }
206 
214  s64 get_pulseTimer(void);
215 
216  inline s64 pulseTimer(void)
217  { return this->get_pulseTimer(); }
218 
231  Y_PWMREPORTMODE_enum get_pwmReportMode(void);
232 
234  { return this->get_pwmReportMode(); }
235 
252  int set_pwmReportMode(Y_PWMREPORTMODE_enum newval);
254  { return this->set_pwmReportMode(newval); }
255 
263  int get_debouncePeriod(void);
264 
265  inline int debouncePeriod(void)
266  { return this->get_debouncePeriod(); }
267 
277  int set_debouncePeriod(int newval);
278  inline int setDebouncePeriod(int newval)
279  { return this->set_debouncePeriod(newval); }
280 
308  static YPwmInput* FindPwmInput(string func);
309 
321  virtual int registerValueCallback(YPwmInputValueCallback callback);
323 
324  virtual int _invokeValueCallback(string value);
325 
339 
340  virtual int _invokeTimedReportCallback(YMeasure value);
341 
349  virtual int resetCounter(void);
350 
351 
352  inline static YPwmInput* Find(string func)
353  { return YPwmInput::FindPwmInput(func); }
354 
362  YPwmInput *nextPwmInput(void);
363  inline YPwmInput *next(void)
364  { return this->nextPwmInput();}
365 
375  static YPwmInput* FirstPwmInput(void);
376  inline static YPwmInput* First(void)
377  { return YPwmInput::FirstPwmInput();}
378 #ifdef __BORLANDC__
379 #pragma option pop
380 #endif
381  //--- (end of YPwmInput accessors declaration)
382 };
383 
384 //--- (YPwmInput functions declaration)
385 
413 inline YPwmInput* yFindPwmInput(const string& func)
414 { return YPwmInput::FindPwmInput(func);}
425 { return YPwmInput::FirstPwmInput();}
426 
427 //--- (end of YPwmInput functions declaration)
428 
429 #endif
void(* YPwmInputValueCallback)(YPwmInput *func, const string &functionValue)
Y_PWMREPORTMODE_enum pwmReportMode(void)
int setPulseCounter(s64 newval)
Y_PWMREPORTMODE_enum
double _frequency
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
double _period
YPwmInputTimedReportCallback _timedReportCallbackPwmInput
void(* YPwmInputTimedReportCallback)(YPwmInput *func, YMeasure measure)
int _debouncePeriod
static const double PERIOD_INVALID
static YPwmInput * FindPwmInput(string func)
static const double FREQUENCY_INVALID
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
static const double PULSEDURATION_INVALID
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
YPwmInputValueCallback _valueCallbackPwmInput
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
int debouncePeriod(void)
s64 pulseCounter(void)
YPwmInput * yFindPwmInput(const string &func)
double _dutyCycle
static YPwmInput * FirstPwmInput(void)
double dutyCycle(void)
double _pulseDuration
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
int setDebouncePeriod(int newval)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
s64 pulseTimer(void)
double pulseDuration(void)
YPwmInput * yFirstPwmInput(void)
int setPwmReportMode(Y_PWMREPORTMODE_enum newval)
double frequency(void)
Y_PWMREPORTMODE_enum _pwmReportMode
double period(void)
YPwmInput * next(void)
static const double DUTYCYCLE_INVALID
static YPwmInput * First(void)
static YPwmInput * Find(string func)


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