yocto_pwmoutput.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_pwmoutput.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindPwmOutput(), the high-level API for PwmOutput 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_PWMOUTPUT_H
42 #define YOCTO_PWMOUTPUT_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YPwmOutput return codes)
50 //--- (end of YPwmOutput return codes)
51 //--- (YPwmOutput definitions)
52 class YPwmOutput; // forward declaration
53 
54 typedef void (*YPwmOutputValueCallback)(YPwmOutput *func, const string& functionValue);
55 #ifndef _Y_ENABLED_ENUM
56 #define _Y_ENABLED_ENUM
57 typedef enum {
62 #endif
63 #ifndef _Y_ENABLEDATPOWERON_ENUM
64 #define _Y_ENABLEDATPOWERON_ENUM
65 typedef enum {
70 #endif
71 #define Y_FREQUENCY_INVALID (YAPI_INVALID_DOUBLE)
72 #define Y_PERIOD_INVALID (YAPI_INVALID_DOUBLE)
73 #define Y_DUTYCYCLE_INVALID (YAPI_INVALID_DOUBLE)
74 #define Y_PULSEDURATION_INVALID (YAPI_INVALID_DOUBLE)
75 #define Y_PWMTRANSITION_INVALID (YAPI_INVALID_STRING)
76 #define Y_DUTYCYCLEATPOWERON_INVALID (YAPI_INVALID_DOUBLE)
77 //--- (end of YPwmOutput definitions)
78 
79 //--- (YPwmOutput declaration)
86 #ifdef __BORLANDC__
87 #pragma option push -w-8022
88 #endif
89 //--- (end of YPwmOutput declaration)
90 protected:
91  //--- (YPwmOutput attributes)
92  // Attributes (function value cache)
94  double _frequency;
95  double _period;
96  double _dutyCycle;
102 
103  friend YPwmOutput *yFindPwmOutput(const string& func);
104  friend YPwmOutput *yFirstPwmOutput(void);
105 
106  // Function-specific method for parsing of JSON output and caching result
107  virtual int _parseAttr(YJSONObject* json_val);
108 
109  // Constructor is protected, use yFindPwmOutput factory function to instantiate
110  YPwmOutput(const string& func);
111  //--- (end of YPwmOutput attributes)
112 
113 public:
114  ~YPwmOutput();
115  //--- (YPwmOutput accessors declaration)
116 
117  static const Y_ENABLED_enum ENABLED_FALSE = Y_ENABLED_FALSE;
118  static const Y_ENABLED_enum ENABLED_TRUE = Y_ENABLED_TRUE;
119  static const Y_ENABLED_enum ENABLED_INVALID = Y_ENABLED_INVALID;
120  static const double FREQUENCY_INVALID;
121  static const double PERIOD_INVALID;
122  static const double DUTYCYCLE_INVALID;
123  static const double PULSEDURATION_INVALID;
124  static const string PWMTRANSITION_INVALID;
125  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_FALSE = Y_ENABLEDATPOWERON_FALSE;
126  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_TRUE = Y_ENABLEDATPOWERON_TRUE;
127  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_INVALID = Y_ENABLEDATPOWERON_INVALID;
128  static const double DUTYCYCLEATPOWERON_INVALID;
129 
137  Y_ENABLED_enum get_enabled(void);
138 
139  inline Y_ENABLED_enum enabled(void)
140  { return this->get_enabled(); }
141 
151  int set_enabled(Y_ENABLED_enum newval);
152  inline int setEnabled(Y_ENABLED_enum newval)
153  { return this->set_enabled(newval); }
154 
165  int set_frequency(double newval);
166  inline int setFrequency(double newval)
167  { return this->set_frequency(newval); }
168 
176  double get_frequency(void);
177 
178  inline double frequency(void)
179  { return this->get_frequency(); }
180 
190  int set_period(double newval);
191  inline int setPeriod(double newval)
192  { return this->set_period(newval); }
193 
201  double get_period(void);
202 
203  inline double period(void)
204  { return this->get_period(); }
205 
215  int set_dutyCycle(double newval);
216  inline int setDutyCycle(double newval)
217  { return this->set_dutyCycle(newval); }
218 
226  double get_dutyCycle(void);
227 
228  inline double dutyCycle(void)
229  { return this->get_dutyCycle(); }
230 
241  int set_pulseDuration(double newval);
242  inline int setPulseDuration(double newval)
243  { return this->set_pulseDuration(newval); }
244 
253  double get_pulseDuration(void);
254 
255  inline double pulseDuration(void)
256  { return this->get_pulseDuration(); }
257 
258  string get_pwmTransition(void);
259 
260  inline string pwmTransition(void)
261  { return this->get_pwmTransition(); }
262 
263  int set_pwmTransition(const string& newval);
264  inline int setPwmTransition(const string& newval)
265  { return this->set_pwmTransition(newval); }
266 
275  Y_ENABLEDATPOWERON_enum get_enabledAtPowerOn(void);
276 
278  { return this->get_enabledAtPowerOn(); }
279 
291  int set_enabledAtPowerOn(Y_ENABLEDATPOWERON_enum newval);
293  { return this->set_enabledAtPowerOn(newval); }
294 
305  int set_dutyCycleAtPowerOn(double newval);
306  inline int setDutyCycleAtPowerOn(double newval)
307  { return this->set_dutyCycleAtPowerOn(newval); }
308 
317  double get_dutyCycleAtPowerOn(void);
318 
319  inline double dutyCycleAtPowerOn(void)
320  { return this->get_dutyCycleAtPowerOn(); }
321 
349  static YPwmOutput* FindPwmOutput(string func);
350 
362  virtual int registerValueCallback(YPwmOutputValueCallback callback);
364 
365  virtual int _invokeValueCallback(string value);
366 
379  virtual int pulseDurationMove(double ms_target,int ms_duration);
380 
392  virtual int dutyCycleMove(double target,int ms_duration);
393 
394 
395  inline static YPwmOutput* Find(string func)
396  { return YPwmOutput::FindPwmOutput(func); }
397 
405  YPwmOutput *nextPwmOutput(void);
406  inline YPwmOutput *next(void)
407  { return this->nextPwmOutput();}
408 
418  static YPwmOutput* FirstPwmOutput(void);
419  inline static YPwmOutput* First(void)
420  { return YPwmOutput::FirstPwmOutput();}
421 #ifdef __BORLANDC__
422 #pragma option pop
423 #endif
424  //--- (end of YPwmOutput accessors declaration)
425 };
426 
427 //--- (YPwmOutput functions declaration)
428 
456 inline YPwmOutput* yFindPwmOutput(const string& func)
457 { return YPwmOutput::FindPwmOutput(func);}
468 { return YPwmOutput::FirstPwmOutput();}
469 
470 //--- (end of YPwmOutput functions declaration)
471 
472 #endif
Y_ENABLEDATPOWERON_enum
Y_ENABLEDATPOWERON_enum enabledAtPowerOn(void)
Y_ENABLED_enum
Definition: yocto_current.h:59
static const double PULSEDURATION_INVALID
Y_ENABLED_enum
double period(void)
double dutyCycle(void)
double _dutyCycle
double frequency(void)
YPwmOutput * yFindPwmOutput(const string &func)
int setPeriod(double newval)
Y_ENABLED_enum enabled(void)
static YPwmOutput * Find(string func)
static const string PWMTRANSITION_INVALID
static const double PERIOD_INVALID
Y_ENABLED_enum _enabled
string pwmTransition(void)
static YPwmOutput * FirstPwmOutput(void)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
YPwmOutput * next(void)
int setEnabled(Y_ENABLED_enum newval)
double dutyCycleAtPowerOn(void)
void(* YPwmOutputValueCallback)(YPwmOutput *func, const string &functionValue)
string _pwmTransition
int setPwmTransition(const string &newval)
int setDutyCycleAtPowerOn(double newval)
static YPwmOutput * First(void)
double _period
static const double DUTYCYCLEATPOWERON_INVALID
YPwmOutputValueCallback _valueCallbackPwmOutput
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setFrequency(double newval)
int setDutyCycle(double newval)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
double _dutyCycleAtPowerOn
YPwmOutput * yFirstPwmOutput(void)
static const double DUTYCYCLE_INVALID
double _pulseDuration
double _frequency
static const double FREQUENCY_INVALID
static YPwmOutput * FindPwmOutput(string func)
int setPulseDuration(double newval)
Y_ENABLEDATPOWERON_enum _enabledAtPowerOn
double pulseDuration(void)
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
int setEnabledAtPowerOn(Y_ENABLEDATPOWERON_enum newval)


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