Skip to content

Commit

Permalink
Buzzer: removed frequency generation as buzzer is active type 3V
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrunot committed May 20, 2024
1 parent f992c52 commit c148284
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 0 additions & 2 deletions conf/conf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ namespace fabomatic

namespace conf::buzzer
{
static constexpr unsigned short LEDC_PWM_CHANNEL{2}; /* Esp32 pwm channel for beep generation */
static constexpr auto STANDARD_BEEP_DURATION{250ms}; /* Single beep duration, typical value 200ms. Set to 0 to disable beeps. */
static constexpr auto NB_BEEPS{3}; /* Number of beeps every time the function is callsed */
static constexpr unsigned int BEEP_HZ{660}; /* Beep frequency in Hz */

} // namespace conf::buzzer

Expand Down
12 changes: 4 additions & 8 deletions src/BoardLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ namespace fabomatic
{
pinMode(pins.buzzer.pin, OUTPUT);
gpio_set_drive_capability(static_cast<gpio_num_t>(pins.buzzer.pin), GPIO_DRIVE_CAP_2);
auto freq = ledcSetup(conf::buzzer::LEDC_PWM_CHANNEL, conf::buzzer::BEEP_HZ, 8U);
ESP_LOGD(TAG, "PWM frequency for buzzer set to %d Hz", freq);
success &= (freq != 0);
ledcAttachPin(pins.buzzer.pin, conf::buzzer::LEDC_PWM_CHANNEL);
}

ESP_LOGI(TAG, "Board initialization complete, success = %d", success);
Expand Down Expand Up @@ -448,9 +444,9 @@ namespace fabomatic
{
if constexpr (conf::buzzer::STANDARD_BEEP_DURATION > 0ms && pins.buzzer.pin != NO_PIN)
{
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 127UL);
digitalWrite(pins.buzzer.pin, 1);
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION);
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
digitalWrite(pins.buzzer.pin, 0);
}
}

Expand All @@ -460,9 +456,9 @@ namespace fabomatic
{
for (auto i = 0; i < conf::buzzer::NB_BEEPS; i++)
{
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 127UL);
digitalWrite(pins.buzzer.pin, 1);
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION);
ledcWrite(conf::buzzer::LEDC_PWM_CHANNEL, 0UL);
digitalWrite(pins.buzzer.pin, 0);
Tasks::delay(conf::buzzer::STANDARD_BEEP_DURATION);
}
}
Expand Down

0 comments on commit c148284

Please sign in to comment.