MCU
Loading...
Searching...
No Matches
lib
systems
src
Buzzer.cpp
Go to the documentation of this file.
1
#include "
Buzzer.h
"
2
#include "Logger.h"
3
void
BuzzerController::deactivate
()
4
{
5
buzzer_on_
=
false
;
6
dash_buzzer_was_on
=
false
;
7
}
8
void
BuzzerController::activate_buzzer
(
unsigned
long
act_time)
9
{
10
last_activation_time_
= act_time;
11
buzzer_on_
=
true
;
12
}
13
14
// will return true when it is sure that the buzzer is off and has been
15
// sounded on the dashboard
16
bool
BuzzerController::done
(
unsigned
long
curr_time,
bool
dash_buzzer_on){
17
18
if
(dash_buzzer_on) {
19
dash_buzzer_was_on
=
true
;
20
}
21
22
bool
buzzer_time_up = (curr_time -
last_activation_time_
) >=
buzzer_period_
;
23
24
//buzzer only turns off if the buzzer time is up and dash buzzer did turn on
25
buzzer_on_
= !(buzzer_time_up &&
dash_buzzer_was_on
);
26
27
// only returns true (done) when the buzzer is finished buzzing
28
return
(!
buzzer_on_
&& !dash_buzzer_on);
29
30
}
Buzzer.h
BuzzerController::buzzer_period_
unsigned long buzzer_period_
Definition:
Buzzer.h:24
BuzzerController::done
bool done(unsigned long curr_time, bool buzzer_on)
Definition:
Buzzer.cpp:16
BuzzerController::buzzer_on_
bool buzzer_on_
Definition:
Buzzer.h:26
BuzzerController::activate_buzzer
void activate_buzzer(unsigned long act_time)
Definition:
Buzzer.cpp:8
BuzzerController::dash_buzzer_was_on
bool dash_buzzer_was_on
Definition:
Buzzer.h:28
BuzzerController::deactivate
void deactivate()
Definition:
Buzzer.cpp:3
BuzzerController::last_activation_time_
unsigned long last_activation_time_
Definition:
Buzzer.h:25
Generated by
1.9.5