-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
132 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef BUZZER_HPP_ | ||
#define BUZZER_HPP_ | ||
|
||
#include <inttypes.h> | ||
|
||
namespace fabomatic | ||
{ | ||
class Buzzer | ||
{ | ||
private: | ||
mutable uint16_t beepCount{0}; | ||
|
||
public: | ||
auto configure() -> void; | ||
auto beepOk() const -> void; | ||
auto beepFail() const -> void; | ||
// For testing purposes | ||
auto getBeepCount() const -> uint16_t; | ||
}; | ||
} // namespace fabomatic | ||
|
||
#endif // BUZZER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "Buzzer.hpp" | ||
#include "conf.hpp" | ||
#include "pins.hpp" | ||
#include "Arduino.h" | ||
#include "Tasks.hpp" | ||
|
||
namespace fabomatic | ||
{ | ||
auto Buzzer::configure() -> void | ||
{ | ||
if constexpr (pins.buzzer.pin != NO_PIN) | ||
{ | ||
pinMode(pins.buzzer.pin, OUTPUT); | ||
} | ||
} | ||
auto Buzzer::beepOk() const -> void | ||
{ | ||
if constexpr (conf::buzzer::STANDARD_BEEP_DURATION > 0ms && pins.buzzer.pin != NO_PIN) | ||
{ | ||
digitalWrite(pins.buzzer.pin, 1); | ||
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION); | ||
digitalWrite(pins.buzzer.pin, 0); | ||
} | ||
beepCount++; | ||
} | ||
|
||
auto Buzzer::beepFail() const -> void | ||
{ | ||
if constexpr (conf::buzzer::STANDARD_BEEP_DURATION > 0ms && pins.buzzer.pin != NO_PIN) | ||
{ | ||
for (auto i = 0; i < conf::buzzer::NB_BEEPS; i++) | ||
{ | ||
digitalWrite(pins.buzzer.pin, 1); | ||
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION); | ||
digitalWrite(pins.buzzer.pin, 0); | ||
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION); | ||
beepCount++; | ||
} | ||
} | ||
} | ||
|
||
auto Buzzer::getBeepCount() const -> uint16_t | ||
{ | ||
return beepCount; | ||
} | ||
|
||
} // namespace fabomatic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters