MCU
Loading...
Searching...
No Matches
Buzzer.cpp
Go to the documentation of this file.
1#include "Buzzer.h"
2#include "Logger.h"
4{
5 buzzer_on_ = false;
6 dash_buzzer_was_on = false;
7}
8void 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
16bool 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}
unsigned long buzzer_period_
Definition: Buzzer.h:24
bool done(unsigned long curr_time, bool buzzer_on)
Definition: Buzzer.cpp:16
bool buzzer_on_
Definition: Buzzer.h:26
void activate_buzzer(unsigned long act_time)
Definition: Buzzer.cpp:8
bool dash_buzzer_was_on
Definition: Buzzer.h:28
void deactivate()
Definition: Buzzer.cpp:3
unsigned long last_activation_time_
Definition: Buzzer.h:25