ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
buzzer.h
Go to the documentation of this file.
1
/*
2
buzzer.h - ESP3D buzzer class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
#ifndef _BUZZER_H
21
#define _BUZZER_H
22
#define BEEP_FREQUENCY 3000
23
24
struct
tone_data
{
25
int
frequency
;
26
int
duration
;
27
bool
processing
;
28
tone_data
*
_next
;
29
};
30
31
class
BuzzerDevice
32
{
33
public
:
34
BuzzerDevice
();
35
~BuzzerDevice
();
36
void
playsound
(
int
frequency,
int
duration);
37
bool
started
()
38
{
39
return
_started;
40
}
41
bool
begin
();
42
void
end
();
43
void
handle
();
44
tone_data
*
getNextTone
();
45
bool
isPlaying
();
46
void
waitWhilePlaying
();
47
void
beep
(
int
count=1,
int
delay = 0,
int
frequency =
BEEP_FREQUENCY
);
48
private
:
49
tone_data
* _head;
50
tone_data
* _tail;
51
bool
_started;
52
void
purgeData();
53
bool
addToneToList(
int
frequency,
int
duration);
54
void
no_tone();
55
56
};
57
extern
BuzzerDevice
esp3d_buzzer
;
58
#endif //_BUZZER_H
tone_data
Definition:
buzzer.h:24
BuzzerDevice::started
bool started()
Definition:
buzzer.h:37
tone_data::processing
bool processing
Definition:
buzzer.h:27
BuzzerDevice::handle
void handle()
BuzzerDevice::playsound
void playsound(int frequency, int duration)
BuzzerDevice::waitWhilePlaying
void waitWhilePlaying()
tone_data::frequency
int frequency
Definition:
buzzer.h:25
BuzzerDevice
Definition:
buzzer.h:31
BuzzerDevice::beep
void beep(int count=1, int delay=0, int frequency=BEEP_FREQUENCY)
BuzzerDevice::end
void end()
BEEP_FREQUENCY
#define BEEP_FREQUENCY
Definition:
buzzer.h:22
BuzzerDevice::~BuzzerDevice
~BuzzerDevice()
tone_data::duration
int duration
Definition:
buzzer.h:26
BuzzerDevice::begin
bool begin()
BuzzerDevice::BuzzerDevice
BuzzerDevice()
BuzzerDevice::isPlaying
bool isPlaying()
BuzzerDevice::getNextTone
tone_data * getNextTone()
esp3d_buzzer
BuzzerDevice esp3d_buzzer
tone_data::_next
tone_data * _next
Definition:
buzzer.h:28
esp3d
src
modules
buzzer
buzzer.h
Generated by
1.8.17