MCU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
BuzzerController Class Reference

#include <Buzzer.h>

Collaboration diagram for BuzzerController:
Collaboration graph

Public Member Functions

 BuzzerController (int duration_of_activation_ms)
 
void deactivate ()
 
void activate_buzzer (unsigned long act_time)
 
bool done (unsigned long curr_time, bool buzzer_on)
 
bool buzzer_is_on ()
 

Private Attributes

unsigned long buzzer_period_
 
unsigned long last_activation_time_
 
bool buzzer_on_
 
bool dash_buzzer_was_on = false
 

Detailed Description

Definition at line 5 of file Buzzer.h.

Constructor & Destructor Documentation

◆ BuzzerController()

BuzzerController::BuzzerController ( int  duration_of_activation_ms)
inline

Definition at line 9 of file Buzzer.h.

9 {
10 buzzer_period_ = duration_of_activation_ms;
11 }
unsigned long buzzer_period_
Definition: Buzzer.h:24

Member Function Documentation

◆ activate_buzzer()

void BuzzerController::activate_buzzer ( unsigned long  act_time)

Definition at line 8 of file Buzzer.cpp.

9{
10 last_activation_time_ = act_time;
11 buzzer_on_ = true;
12}
bool buzzer_on_
Definition: Buzzer.h:26
unsigned long last_activation_time_
Definition: Buzzer.h:25

◆ buzzer_is_on()

bool BuzzerController::buzzer_is_on ( )
inline

Definition at line 16 of file Buzzer.h.

16 {
17 if(buzzer_on_){
18 // Serial.println("buzzer should be on now");
19 }
20 return buzzer_on_;
21 }

◆ deactivate()

void BuzzerController::deactivate ( )

Definition at line 3 of file Buzzer.cpp.

4{
5 buzzer_on_ = false;
6 dash_buzzer_was_on = false;
7}
bool dash_buzzer_was_on
Definition: Buzzer.h:28

◆ done()

bool BuzzerController::done ( unsigned long  curr_time,
bool  buzzer_on 
)

Definition at line 16 of file Buzzer.cpp.

16 {
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}

Member Data Documentation

◆ buzzer_on_

bool BuzzerController::buzzer_on_
private

Definition at line 26 of file Buzzer.h.

◆ buzzer_period_

unsigned long BuzzerController::buzzer_period_
private

Definition at line 24 of file Buzzer.h.

◆ dash_buzzer_was_on

bool BuzzerController::dash_buzzer_was_on = false
private

Definition at line 28 of file Buzzer.h.

◆ last_activation_time_

unsigned long BuzzerController::last_activation_time_
private

Definition at line 25 of file Buzzer.h.


The documentation for this class was generated from the following files: