RadioSvegliaGBE
Buzzer.cpp
Go to the documentation of this file.
1 
11 // Inclusione <automatica> dell'header che si sta implementando
12 #include "Buzzer.h"
13 
14 // Implementazione del metodo 'Init' della categoria 'Init'
15 bool Buzzer::Init(const int& t_BuzzerPin)
16 {
17  // Controllo che la classe non sia già stata inizializzata
18  if (!m_hasBeenCalled)
19  {
20  // Imposto il PIN del buzzer
21  m_BuzzerPin = t_BuzzerPin;
22 
23  // Avviso che la chiamata al metodo 'Init' è già stata effettuata
24  m_hasBeenCalled = true;
25 
26  return true;
27  }
28  else
29  return false;
30 }
31 
32 // Implementazione del metodo 'Bip' della categoria 'Metodi'
33 bool Buzzer::Bip(const unsigned int& t_Frequency, const unsigned int& t_Duration)
34 {
35  if (m_hasBeenCalled)
36  {
37  // Genero l'onda quadra con la funzione "tone" di Arduino
38  tone(m_BuzzerPin, t_Frequency, t_Duration);
39 
40  return true;
41  }
42  else
43  return false;
44 }
45 
46 // Implementazione del metodo 'BipAutomated' della categoria 'Metodi di Automazione'
47 bool Buzzer::BipAutomated(const unsigned int& t_Frequency, const unsigned int& t_Duration)
48 {
49  if (m_hasBeenCalled)
50  {
51  // Genero l'onda quadra con la funzione "tone" di Arduino
52  tone(m_BuzzerPin, t_Frequency, t_Duration);
53 
54  // Genero un delay con durata: 't_Duration + "500"'
55  delay(t_Duration + Buzzer__file::_DelayOffset);
56 
57  return true;
58  }
59  else
60  return false;
61 }
Buzzer::BipAutomated
static bool BipAutomated(const unsigned int &t_Frequency, const unsigned int &t_Duration)
AUTOMATIZZATO: Genera un'onda quadra della frequenza e durata specificati come parametri.
Definition: Buzzer.cpp:47
Buzzer::Bip
static bool Bip(const unsigned int &t_Frequency, const unsigned int &t_Duration)
Genera un'onda quadra della frequenza e durata specificati come parametri.
Definition: Buzzer.cpp:33
Buzzer::Init
static bool Init(const int &t_BuzzerPin)
Metodo di inizializzazione dei componenti della classe.
Definition: Buzzer.cpp:15
Buzzer::m_hasBeenCalled
static bool m_hasBeenCalled
Definition: Buzzer.h:97
Buzzer.h
Buzzer::m_BuzzerPin
static int m_BuzzerPin
Definition: Buzzer.h:94
Buzzer__file::_DelayOffset
static constexpr auto _DelayOffset
Definition: Buzzer.h:50