yocto_buzzer.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_buzzer.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindBuzzer(), the high-level API for Buzzer 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_BUZZER_H
42 #define YOCTO_BUZZER_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YBuzzer return codes)
50 //--- (end of YBuzzer return codes)
51 //--- (YBuzzer definitions)
52 class YBuzzer; // forward declaration
53 
54 typedef void (*YBuzzerValueCallback)(YBuzzer *func, const string& functionValue);
55 #define Y_FREQUENCY_INVALID (YAPI_INVALID_DOUBLE)
56 #define Y_VOLUME_INVALID (YAPI_INVALID_UINT)
57 #define Y_PLAYSEQSIZE_INVALID (YAPI_INVALID_UINT)
58 #define Y_PLAYSEQMAXSIZE_INVALID (YAPI_INVALID_UINT)
59 #define Y_PLAYSEQSIGNATURE_INVALID (YAPI_INVALID_UINT)
60 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
61 //--- (end of YBuzzer definitions)
62 
63 //--- (YBuzzer declaration)
72 #ifdef __BORLANDC__
73 #pragma option push -w-8022
74 #endif
75 //--- (end of YBuzzer declaration)
76 protected:
77  //--- (YBuzzer attributes)
78  // Attributes (function value cache)
79  double _frequency;
80  int _volume;
84  string _command;
86 
87  friend YBuzzer *yFindBuzzer(const string& func);
88  friend YBuzzer *yFirstBuzzer(void);
89 
90  // Function-specific method for parsing of JSON output and caching result
91  virtual int _parseAttr(YJSONObject* json_val);
92 
93  // Constructor is protected, use yFindBuzzer factory function to instantiate
94  YBuzzer(const string& func);
95  //--- (end of YBuzzer attributes)
96 
97 public:
98  ~YBuzzer();
99  //--- (YBuzzer accessors declaration)
100 
101  static const double FREQUENCY_INVALID;
102  static const int VOLUME_INVALID = YAPI_INVALID_UINT;
103  static const int PLAYSEQSIZE_INVALID = YAPI_INVALID_UINT;
104  static const int PLAYSEQMAXSIZE_INVALID = YAPI_INVALID_UINT;
105  static const int PLAYSEQSIGNATURE_INVALID = YAPI_INVALID_UINT;
106  static const string COMMAND_INVALID;
107 
117  int set_frequency(double newval);
118  inline int setFrequency(double newval)
119  { return this->set_frequency(newval); }
120 
128  double get_frequency(void);
129 
130  inline double frequency(void)
131  { return this->get_frequency(); }
132 
140  int get_volume(void);
141 
142  inline int volume(void)
143  { return this->get_volume(); }
144 
154  int set_volume(int newval);
155  inline int setVolume(int newval)
156  { return this->set_volume(newval); }
157 
165  int get_playSeqSize(void);
166 
167  inline int playSeqSize(void)
168  { return this->get_playSeqSize(); }
169 
177  int get_playSeqMaxSize(void);
178 
179  inline int playSeqMaxSize(void)
180  { return this->get_playSeqMaxSize(); }
181 
192  int get_playSeqSignature(void);
193 
194  inline int playSeqSignature(void)
195  { return this->get_playSeqSignature(); }
196 
197  string get_command(void);
198 
199  inline string command(void)
200  { return this->get_command(); }
201 
202  int set_command(const string& newval);
203  inline int setCommand(const string& newval)
204  { return this->set_command(newval); }
205 
233  static YBuzzer* FindBuzzer(string func);
234 
246  virtual int registerValueCallback(YBuzzerValueCallback callback);
248 
249  virtual int _invokeValueCallback(string value);
250 
251  virtual int sendCommand(string command);
252 
262  virtual int addFreqMoveToPlaySeq(int freq,int msDelay);
263 
273  virtual int addPulseToPlaySeq(int freq,int msDuration);
274 
285  virtual int addVolMoveToPlaySeq(int volume,int msDuration);
286 
300  virtual int addNotesToPlaySeq(string notes);
301 
310  virtual int startPlaySeq(void);
311 
318  virtual int stopPlaySeq(void);
319 
326  virtual int resetPlaySeq(void);
327 
334  virtual int oncePlaySeq(void);
335 
346  virtual int pulse(int frequency,int duration);
347 
358  virtual int freqMove(int frequency,int duration);
359 
370  virtual int volumeMove(int volume,int duration);
371 
385  virtual int playNotes(string notes);
386 
387 
388  inline static YBuzzer* Find(string func)
389  { return YBuzzer::FindBuzzer(func); }
390 
398  YBuzzer *nextBuzzer(void);
399  inline YBuzzer *next(void)
400  { return this->nextBuzzer();}
401 
411  static YBuzzer* FirstBuzzer(void);
412  inline static YBuzzer* First(void)
413  { return YBuzzer::FirstBuzzer();}
414 #ifdef __BORLANDC__
415 #pragma option pop
416 #endif
417  //--- (end of YBuzzer accessors declaration)
418 };
419 
420 //--- (YBuzzer functions declaration)
421 
449 inline YBuzzer* yFindBuzzer(const string& func)
450 { return YBuzzer::FindBuzzer(func);}
460 inline YBuzzer* yFirstBuzzer(void)
461 { return YBuzzer::FirstBuzzer();}
462 
463 //--- (end of YBuzzer functions declaration)
464 
465 #endif
void(* YBuzzerValueCallback)(YBuzzer *func, const string &functionValue)
Definition: yocto_buzzer.h:54
static const string COMMAND_INVALID
Definition: yocto_buzzer.h:106
string _command
Definition: yocto_buzzer.h:84
YBuzzer * yFirstBuzzer(void)
Definition: yocto_buzzer.h:460
int volume(void)
Definition: yocto_buzzer.h:142
YBuzzer * yFindBuzzer(const string &func)
Definition: yocto_buzzer.h:449
YBuzzer * next(void)
Definition: yocto_buzzer.h:399
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
double frequency(void)
Definition: yocto_buzzer.h:130
int _playSeqMaxSize
Definition: yocto_buzzer.h:82
static YBuzzer * FindBuzzer(string func)
int _volume
Definition: yocto_buzzer.h:80
double _frequency
Definition: yocto_buzzer.h:79
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
YBuzzerValueCallback _valueCallbackBuzzer
Definition: yocto_buzzer.h:85
int _playSeqSize
Definition: yocto_buzzer.h:81
ROSLIB_DECL std::string command(const std::string &cmd)
int setFrequency(double newval)
Definition: yocto_buzzer.h:118
int playSeqSignature(void)
Definition: yocto_buzzer.h:194
static YBuzzer * FirstBuzzer(void)
string command(void)
Definition: yocto_buzzer.h:199
static YBuzzer * Find(string func)
Definition: yocto_buzzer.h:388
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
static const double FREQUENCY_INVALID
Definition: yocto_buzzer.h:101
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
int _playSeqSignature
Definition: yocto_buzzer.h:83
int setVolume(int newval)
Definition: yocto_buzzer.h:155
static YBuzzer * First(void)
Definition: yocto_buzzer.h:412
int playSeqMaxSize(void)
Definition: yocto_buzzer.h:179
int playSeqSize(void)
Definition: yocto_buzzer.h:167
int setCommand(const string &newval)
Definition: yocto_buzzer.h:203
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