Boboter
Loading...
Searching...
No Matches
buzzer.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <cstdint>
11#include <hal/ledc_types.h>
12#include <soc/gpio_num.h>
13
14class Robot;
15
16namespace Device {
17 class Buzzer {
18 private:
19 static constexpr const char* TAG = "Device::Buzzer";
20
21 static constexpr gpio_num_t BUZZER_PIN = GPIO_NUM_19;
22 static constexpr ledc_timer_t LEDC_TIMER = LEDC_TIMER_1;
23 static constexpr ledc_channel_t LEDC_CHANNEL = LEDC_CHANNEL_2;
24
25 static constexpr uint16_t INITIAL_FREQUENCY = 100;
26 static constexpr uint16_t DUTY_CYCLE = 256;
27
28 static constexpr uint16_t FREQUENCY_MIN = 20;
29 static constexpr uint16_t FREQUENCY_MAX = 15'000;
30
31 Robot& robot;
32 uint16_t current_frequency;
33 bool turned_off;
34
35 public:
36 explicit Buzzer(Robot& robot);
37 ~Buzzer();
38
42 void initialize();
43
49 void set_frequency(uint16_t frequency);
50
54 void turn_off();
55 };
56}
void initialize()
Sets up the necessary GPIO pins.
Definition buzzer.cpp:25
~Buzzer()
Definition buzzer.cpp:21
void set_frequency(uint16_t frequency)
Set buzzer to a given frequency.
Definition buzzer.cpp:46
void turn_off()
Stops buzzer output until it's set again.
Definition buzzer.cpp:64
Buzzer(Robot &robot)
Definition buzzer.cpp:13
Class containing all the components of the robot.
Definition robot.h:24
Definition battery.cpp:14