yocto_servo.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_servo.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindServo(), the high-level API for Servo 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_SERVO_H
42 #define YOCTO_SERVO_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YServo return codes)
50 //--- (end of YServo return codes)
51 //--- (YServo definitions)
52 class YServo; // forward declaration
53 
54 typedef void (*YServoValueCallback)(YServo *func, const string& functionValue);
55 #ifndef _Y_ENABLED_ENUM
56 #define _Y_ENABLED_ENUM
57 typedef enum {
62 #endif
63 #ifndef _CLASS_YMOVE
64 #define _CLASS_YMOVE
66 public:
67  int target;
68  int ms;
69  int moving;
70 
73  {}
74 
75  bool operator==(const YMove& o) const {
76  return (target == o.target) && (ms == o.ms) && (moving == o.moving);
77  }
78 };
79 #endif
80 #ifndef _Y_ENABLEDATPOWERON_ENUM
81 #define _Y_ENABLEDATPOWERON_ENUM
82 typedef enum {
87 #endif
88 #define Y_POSITION_INVALID (YAPI_INVALID_INT)
89 #define Y_RANGE_INVALID (YAPI_INVALID_UINT)
90 #define Y_NEUTRAL_INVALID (YAPI_INVALID_UINT)
91 #define Y_POSITIONATPOWERON_INVALID (YAPI_INVALID_INT)
92 //--- (end of YServo definitions)
93 
94 //--- (YServo declaration)
104 #ifdef __BORLANDC__
105 #pragma option push -w-8022
106 #endif
107 //--- (end of YServo declaration)
108 protected:
109  //--- (YServo attributes)
110  // Attributes (function value cache)
113  int _range;
114  int _neutral;
119 
120  friend YServo *yFindServo(const string& func);
121  friend YServo *yFirstServo(void);
122 
123  // Function-specific method for parsing of JSON output and caching result
124  virtual int _parseAttr(YJSONObject* json_val);
125 
126  // Constructor is protected, use yFindServo factory function to instantiate
127  YServo(const string& func);
128  //--- (end of YServo attributes)
129 
130 public:
131  ~YServo();
132  //--- (YServo accessors declaration)
133 
134  static const int POSITION_INVALID = YAPI_INVALID_INT;
135  static const Y_ENABLED_enum ENABLED_FALSE = Y_ENABLED_FALSE;
136  static const Y_ENABLED_enum ENABLED_TRUE = Y_ENABLED_TRUE;
137  static const Y_ENABLED_enum ENABLED_INVALID = Y_ENABLED_INVALID;
138  static const int RANGE_INVALID = YAPI_INVALID_UINT;
139  static const int NEUTRAL_INVALID = YAPI_INVALID_UINT;
140  static const YMove MOVE_INVALID;
141  static const int POSITIONATPOWERON_INVALID = YAPI_INVALID_INT;
142  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_FALSE = Y_ENABLEDATPOWERON_FALSE;
143  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_TRUE = Y_ENABLEDATPOWERON_TRUE;
144  static const Y_ENABLEDATPOWERON_enum ENABLEDATPOWERON_INVALID = Y_ENABLEDATPOWERON_INVALID;
145 
153  int get_position(void);
154 
155  inline int position(void)
156  { return this->get_position(); }
157 
167  int set_position(int newval);
168  inline int setPosition(int newval)
169  { return this->set_position(newval); }
170 
178  Y_ENABLED_enum get_enabled(void);
179 
180  inline Y_ENABLED_enum enabled(void)
181  { return this->get_enabled(); }
182 
192  int set_enabled(Y_ENABLED_enum newval);
193  inline int setEnabled(Y_ENABLED_enum newval)
194  { return this->set_enabled(newval); }
195 
203  int get_range(void);
204 
205  inline int range(void)
206  { return this->get_range(); }
207 
223  int set_range(int newval);
224  inline int setRange(int newval)
225  { return this->set_range(newval); }
226 
234  int get_neutral(void);
235 
236  inline int neutral(void)
237  { return this->get_neutral(); }
238 
254  int set_neutral(int newval);
255  inline int setNeutral(int newval)
256  { return this->set_neutral(newval); }
257 
258  YMove get_move(void);
259 
260  inline YMove move(void)
261  { return this->get_move(); }
262 
263  int set_move(YMove newval);
264  inline int setMove(YMove newval)
265  { return this->set_move(newval); }
266 
277  int move(int target,int ms_duration);
278 
286  int get_positionAtPowerOn(void);
287 
288  inline int positionAtPowerOn(void)
289  { return this->get_positionAtPowerOn(); }
290 
301  int set_positionAtPowerOn(int newval);
302  inline int setPositionAtPowerOn(int newval)
303  { return this->set_positionAtPowerOn(newval); }
304 
313  Y_ENABLEDATPOWERON_enum get_enabledAtPowerOn(void);
314 
316  { return this->get_enabledAtPowerOn(); }
317 
328  int set_enabledAtPowerOn(Y_ENABLEDATPOWERON_enum newval);
330  { return this->set_enabledAtPowerOn(newval); }
331 
359  static YServo* FindServo(string func);
360 
372  virtual int registerValueCallback(YServoValueCallback callback);
374 
375  virtual int _invokeValueCallback(string value);
376 
377 
378  inline static YServo* Find(string func)
379  { return YServo::FindServo(func); }
380 
388  YServo *nextServo(void);
389  inline YServo *next(void)
390  { return this->nextServo();}
391 
401  static YServo* FirstServo(void);
402  inline static YServo* First(void)
403  { return YServo::FirstServo();}
404 #ifdef __BORLANDC__
405 #pragma option pop
406 #endif
407  //--- (end of YServo accessors declaration)
408 };
409 
410 //--- (YServo functions declaration)
411 
439 inline YServo* yFindServo(const string& func)
440 { return YServo::FindServo(func);}
450 inline YServo* yFirstServo(void)
451 { return YServo::FirstServo();}
452 
453 //--- (end of YServo functions declaration)
454 
455 #endif
int neutral(void)
Definition: yocto_servo.h:236
Y_ENABLEDATPOWERON_enum
YServo * next(void)
Definition: yocto_servo.h:389
Y_ENABLED_enum
Definition: yocto_current.h:59
static const YMove MOVE_INVALID
Definition: yocto_servo.h:140
int range(void)
Definition: yocto_servo.h:205
YMove()
Definition: yocto_servo.h:71
int setNeutral(int newval)
Definition: yocto_servo.h:255
int _neutral
Definition: yocto_servo.h:114
int setMove(YMove newval)
Definition: yocto_servo.h:264
int _positionAtPowerOn
Definition: yocto_servo.h:116
YMove _move
Definition: yocto_servo.h:115
static YServo * FindServo(string func)
YServo * yFindServo(const string &func)
Definition: yocto_servo.h:439
Y_ENABLED_enum _enabled
Definition: yocto_servo.h:112
int target
int position(void)
Definition: yocto_servo.h:155
static YServo * First(void)
Definition: yocto_servo.h:402
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
Y_ENABLEDATPOWERON_enum enabledAtPowerOn(void)
Definition: yocto_servo.h:315
Y_ENABLEDATPOWERON_enum _enabledAtPowerOn
Definition: yocto_servo.h:117
int moving
int setPositionAtPowerOn(int newval)
Definition: yocto_servo.h:302
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
static YServo * FirstServo(void)
Y_ENABLED_enum enabled(void)
Definition: yocto_servo.h:180
YMove move(void)
Definition: yocto_servo.h:260
YServo * yFirstServo(void)
Definition: yocto_servo.h:450
int positionAtPowerOn(void)
Definition: yocto_servo.h:288
void(* YServoValueCallback)(YServo *func, const string &functionValue)
Definition: yocto_servo.h:54
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setEnabledAtPowerOn(Y_ENABLEDATPOWERON_enum newval)
Definition: yocto_servo.h:329
Y_ENABLEDATPOWERON_enum
Definition: yocto_servo.h:82
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
int setEnabled(Y_ENABLED_enum newval)
Definition: yocto_servo.h:193
Y_ENABLED_enum
Definition: yocto_servo.h:57
int _position
Definition: yocto_servo.h:111
int setRange(int newval)
Definition: yocto_servo.h:224
static YServo * Find(string func)
Definition: yocto_servo.h:378
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
bool operator==(const YMove &o) const
Definition: yocto_servo.h:75
YServoValueCallback _valueCallbackServo
Definition: yocto_servo.h:118
int setPosition(int newval)
Definition: yocto_servo.h:168
int _range
Definition: yocto_servo.h:113
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