FotoBox
buzzer.h
Go to the documentation of this file.
1 /* buzzer.h
2  *
3  * Copyright (c) 2017 Thomas Kais
4  *
5  * This file is subject to the terms and conditions defined in
6  * file 'COPYING', which is part of this source code package.
7  */
8 #ifndef BUZZER_H
9 #define BUZZER_H
10 
11 //detect pigpio library
12 #if defined (__arm__) && __has_include(<pigpiod_if2.h>)
13 #define BUZZER_AVAILABLE
14 #endif
15 
16 #include <QObject>
17 
18 #include <atomic>
19 
20 namespace FotoBox {
21 
26 class Buzzer : public QObject
27 {
28  Q_OBJECT
29 
30 public:
35  explicit Buzzer(QObject *parent = nullptr);
36 
40  ~Buzzer() override;
41 
45  Buzzer(const Buzzer &) = delete;
46 
50  Buzzer &operator=(const Buzzer &) = delete;
51 
55  Buzzer(Buzzer &&other) = delete;
56 
60  Buzzer &operator=(Buzzer &&other) = delete;
61 
66  auto initialise() -> bool;
67 
72  auto static checkDeamon() -> bool;
73 
77  void stop();
78 
79 public Q_SLOTS:
83  void queryPin();
84 
85 Q_SIGNALS:
89  void triggered();
90 
91 private:
93  int m_pi{-1};
95  std::atomic<bool> m_stop{false};
96 };
97 
98 } // end namespace FotoBox
99 
100 #endif // BUZZER_H
This class handles the buzzer.
Definition: buzzer.h:27
Buzzer & operator=(Buzzer &&other)=delete
Buzzer default move assignment.
void stop()
Stop executing.
Definition: buzzer.cpp:86
Buzzer & operator=(const Buzzer &)=delete
Buzzer delete copy assignment.
static auto checkDeamon() -> bool
Check if pigpio daemon is reachable.
Definition: buzzer.cpp:78
~Buzzer() override
Buzzer destructor.
Definition: buzzer.cpp:76
Buzzer(Buzzer &&other)=delete
Buzzer default move constructor.
Buzzer(const Buzzer &)=delete
Buzzer copy constructor.
std::atomic< bool > m_stop
Definition: buzzer.h:95
void queryPin()
Query the Raspberry Pi pin.
Definition: buzzer.cpp:79
auto initialise() -> bool
Initialises the library and sets the GPIO mode.
Definition: buzzer.cpp:77
Buzzer(QObject *parent=nullptr)
Buzzer constructor.
Definition: buzzer.cpp:84
void triggered()
Buzzer was pressed.