upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
buzzer.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * based on original C++ driver by
6  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
7  * Copyright (c) 2014 Intel Corporation.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 #pragma once
29 
30 #include <string>
31 #include <buzzer.h>
32 
33 namespace upm {
34 
62  class Buzzer {
63  public:
69  Buzzer(int pinNumber);
70 
74  ~Buzzer();
75 
86  int playSound(int note, int delay);
87 
92  void stopSound();
93 
100  void setVolume(float vol);
101 
107  float getVolume();
108 
114  std::string name()
115  {
116  return m_name;
117  }
118  protected:
119  std::string m_name;
120  buzzer_context m_buzzer;
121 
122  private:
123  /* Disable implicit copy and assignment operators */
124  Buzzer(const Buzzer&) = delete;
125  Buzzer &operator=(const Buzzer&) = delete;
126  };
127 }
Buzzer(int pinNumber)
Definition: buzzer.cxx:39
~Buzzer()
Definition: buzzer.cxx:46
Definition: buzzer.h:52
std::string name()
Definition: buzzer.hpp:114
C API for the buzzer driver.
void stopSound()
Definition: buzzer.cxx:69
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
int playSound(int note, int delay)
Definition: buzzer.cxx:61
API for the Buzzer component.
Definition: buzzer.hpp:62
void setVolume(float vol)
Definition: buzzer.cxx:51
float getVolume()
Definition: buzzer.cxx:56