yocto_compass.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_compass.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindCompass(), the high-level API for Compass 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_COMPASS_H
42 #define YOCTO_COMPASS_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YCompass return codes)
50 //--- (end of YCompass return codes)
51 //--- (YCompass definitions)
52 class YCompass; // forward declaration
53 
54 typedef void (*YCompassValueCallback)(YCompass *func, const string& functionValue);
55 class YMeasure; // forward declaration
56 typedef void (*YCompassTimedReportCallback)(YCompass *func, YMeasure measure);
57 #ifndef _Y_AXIS_ENUM
58 #define _Y_AXIS_ENUM
59 typedef enum {
60  Y_AXIS_X = 0,
61  Y_AXIS_Y = 1,
62  Y_AXIS_Z = 2,
64 } Y_AXIS_enum;
65 #endif
66 #define Y_BANDWIDTH_INVALID (YAPI_INVALID_INT)
67 #define Y_MAGNETICHEADING_INVALID (YAPI_INVALID_DOUBLE)
68 //--- (end of YCompass definitions)
69 
70 //--- (YCompass declaration)
85 #ifdef __BORLANDC__
86 #pragma option push -w-8022
87 #endif
88 //--- (end of YCompass declaration)
89 protected:
90  //--- (YCompass attributes)
91  // Attributes (function value cache)
97 
98  friend YCompass *yFindCompass(const string& func);
99  friend YCompass *yFirstCompass(void);
100 
101  // Function-specific method for parsing of JSON output and caching result
102  virtual int _parseAttr(YJSONObject* json_val);
103 
104  // Constructor is protected, use yFindCompass factory function to instantiate
105  YCompass(const string& func);
106  //--- (end of YCompass attributes)
107 
108 public:
109  ~YCompass();
110  //--- (YCompass accessors declaration)
111 
112  static const int BANDWIDTH_INVALID = YAPI_INVALID_INT;
113  static const Y_AXIS_enum AXIS_X = Y_AXIS_X;
114  static const Y_AXIS_enum AXIS_Y = Y_AXIS_Y;
115  static const Y_AXIS_enum AXIS_Z = Y_AXIS_Z;
116  static const Y_AXIS_enum AXIS_INVALID = Y_AXIS_INVALID;
117  static const double MAGNETICHEADING_INVALID;
118 
126  int get_bandwidth(void);
127 
128  inline int bandwidth(void)
129  { return this->get_bandwidth(); }
130 
141  int set_bandwidth(int newval);
142  inline int setBandwidth(int newval)
143  { return this->set_bandwidth(newval); }
144 
145  Y_AXIS_enum get_axis(void);
146 
147  inline Y_AXIS_enum axis(void)
148  { return this->get_axis(); }
149 
157  double get_magneticHeading(void);
158 
159  inline double magneticHeading(void)
160  { return this->get_magneticHeading(); }
161 
189  static YCompass* FindCompass(string func);
190 
202  virtual int registerValueCallback(YCompassValueCallback callback);
204 
205  virtual int _invokeValueCallback(string value);
206 
220 
221  virtual int _invokeTimedReportCallback(YMeasure value);
222 
223 
224  inline static YCompass* Find(string func)
225  { return YCompass::FindCompass(func); }
226 
234  YCompass *nextCompass(void);
235  inline YCompass *next(void)
236  { return this->nextCompass();}
237 
247  static YCompass* FirstCompass(void);
248  inline static YCompass* First(void)
249  { return YCompass::FirstCompass();}
250 #ifdef __BORLANDC__
251 #pragma option pop
252 #endif
253  //--- (end of YCompass accessors declaration)
254 };
255 
256 //--- (YCompass functions declaration)
257 
285 inline YCompass* yFindCompass(const string& func)
286 { return YCompass::FindCompass(func);}
296 inline YCompass* yFirstCompass(void)
297 { return YCompass::FirstCompass();}
298 
299 //--- (end of YCompass functions declaration)
300 
301 #endif
Y_AXIS_enum axis(void)
static YCompass * Find(string func)
static YCompass * FirstCompass(void)
int setBandwidth(int newval)
YCompassTimedReportCallback _timedReportCallbackCompass
Definition: yocto_compass.h:96
void(* YCompassValueCallback)(YCompass *func, const string &functionValue)
Definition: yocto_compass.h:54
int _bandwidth
Definition: yocto_compass.h:92
static YCompass * FindCompass(string func)
YCompassValueCallback _valueCallbackCompass
Definition: yocto_compass.h:95
double magneticHeading(void)
Y_AXIS_enum _axis
Definition: yocto_compass.h:93
static const double MAGNETICHEADING_INVALID
YCompass * next(void)
YCompass * yFindCompass(const string &func)
virtual int registerTimedReportCallback(YSensorTimedReportCallback callback)
Definition: yocto_api.cpp:7923
double _magneticHeading
Definition: yocto_compass.h:94
virtual int _invokeTimedReportCallback(YMeasure value)
Definition: yocto_api.cpp:7936
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:7645
int bandwidth(void)
YCompass * yFirstCompass(void)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:7015
virtual int registerValueCallback(YSensorValueCallback callback)
Definition: yocto_api.cpp:7626
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
void(* YCompassTimedReportCallback)(YCompass *func, YMeasure measure)
Definition: yocto_compass.h:56
Y_AXIS_enum
Definition: yocto_compass.h:59
static YCompass * First(void)


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