From c1482842db1246eeb3b65a12b9d387ac33bbebf7 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Mon, 20 May 2024 22:29:14 +0200 Subject: [PATCH] Buzzer: removed frequency generation as buzzer is active type 3V --- conf/conf.hpp | 2 -- src/BoardLogic.cpp | 12 ++++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/conf/conf.hpp b/conf/conf.hpp index 47a3e694..36eef101 100644 --- a/conf/conf.hpp +++ b/conf/conf.hpp @@ -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 diff --git a/src/BoardLogic.cpp b/src/BoardLogic.cpp index 0c1182c1..5acb6970 100644 --- a/src/BoardLogic.cpp +++ b/src/BoardLogic.cpp @@ -262,10 +262,6 @@ namespace fabomatic { pinMode(pins.buzzer.pin, OUTPUT); gpio_set_drive_capability(static_cast(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); @@ -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); } } @@ -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); } }