-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
2563150
commit e98b06a
Showing
28 changed files
with
5,974 additions
and
5,425 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
--- | ||
# options: https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
BasedOnStyle: chromium | ||
IndentWidth: 4 | ||
IndentWidth: 2 | ||
# Must be 80 characters or less! | ||
# ColumnLimit: 80 | ||
# does (int) x instead of (int)x | ||
SpaceAfterCStyleCast: true | ||
# spaces, not tabs! | ||
UseTab: Never | ||
# | ||
AlignTrailingComments: true | ||
# #define SHORT_NAME 42 | ||
# #define LONGER_NAME 0x007f # does nice spacing for macros | ||
AlignConsecutiveMacros: Consecutive | ||
IndentPPDirectives: BeforeHash |
1,046 changes: 557 additions & 489 deletions
1,046
examples/ESP-IDF/minino/components/bluetooth_scanner/bluetooth_scanner.c
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,53 +1,51 @@ | ||
#include "buzzer.h" | ||
#include "driver/ledc.h" | ||
|
||
#define LEDC_TIMER LEDC_TIMER_0 | ||
#define LEDC_MODE LEDC_LOW_SPEED_MODE | ||
#define LEDC_TIMER LEDC_TIMER_0 | ||
#define LEDC_MODE LEDC_LOW_SPEED_MODE | ||
#define LEDC_OUTPUT_IO (GPIO_NUM_2) // Define the output GPIO | ||
#define LEDC_CHANNEL LEDC_CHANNEL_0 | ||
#define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits | ||
#define LEDC_DUTY (4096) // Set duty to 50%. (2 ** 13) * 50% = 4096 | ||
#define LEDC_FREQUENCY (4000) // Frequency in Hertz. Set frequency at 4 kHz | ||
#define LEDC_CHANNEL LEDC_CHANNEL_0 | ||
#define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits | ||
#define LEDC_DUTY (4096) // Set duty to 50%. (2 ** 13) * 50% = 4096 | ||
#define LEDC_FREQUENCY (4000) // Frequency in Hertz. Set frequency at 4 kHz | ||
|
||
void buzzer_init() { | ||
// Prepare and then apply the LEDC PWM timer configuration | ||
ledc_timer_config_t ledc_timer = { | ||
.speed_mode = LEDC_MODE, | ||
.duty_resolution = LEDC_DUTY_RES, | ||
.timer_num = LEDC_TIMER, | ||
.freq_hz = LEDC_FREQUENCY, // Set output frequency at 4 kHz | ||
.clk_cfg = LEDC_AUTO_CLK}; | ||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer)); | ||
// Prepare and then apply the LEDC PWM timer configuration | ||
ledc_timer_config_t ledc_timer = { | ||
.speed_mode = LEDC_MODE, | ||
.duty_resolution = LEDC_DUTY_RES, | ||
.timer_num = LEDC_TIMER, | ||
.freq_hz = LEDC_FREQUENCY, // Set output frequency at 4 kHz | ||
.clk_cfg = LEDC_AUTO_CLK}; | ||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer)); | ||
|
||
// Prepare and then apply the LEDC PWM channel configuration | ||
ledc_channel_config_t ledc_channel = { | ||
.speed_mode = LEDC_MODE, | ||
.channel = LEDC_CHANNEL, | ||
.timer_sel = LEDC_TIMER, | ||
.intr_type = LEDC_INTR_DISABLE, | ||
.gpio_num = LEDC_OUTPUT_IO, | ||
.duty = 0, // Set duty to 0% | ||
.hpoint = 0}; | ||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel)); | ||
// Prepare and then apply the LEDC PWM channel configuration | ||
ledc_channel_config_t ledc_channel = {.speed_mode = LEDC_MODE, | ||
.channel = LEDC_CHANNEL, | ||
.timer_sel = LEDC_TIMER, | ||
.intr_type = LEDC_INTR_DISABLE, | ||
.gpio_num = LEDC_OUTPUT_IO, | ||
.duty = 0, // Set duty to 0% | ||
.hpoint = 0}; | ||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel)); | ||
} | ||
|
||
void buzzer_play() { | ||
buzzer_init(); | ||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY)); | ||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); | ||
buzzer_init(); | ||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY)); | ||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); | ||
} | ||
|
||
void buzzer_stop() { | ||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0)); | ||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); | ||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0)); | ||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); | ||
|
||
// Configure LEDC_OUTPUT_IO as input | ||
gpio_config_t io_conf = { | ||
.pin_bit_mask = (1ULL << LEDC_OUTPUT_IO), | ||
.mode = GPIO_MODE_INPUT, | ||
.pull_up_en = GPIO_PULLUP_DISABLE, | ||
.pull_down_en = GPIO_PULLDOWN_DISABLE, | ||
.intr_type = GPIO_INTR_DISABLE}; | ||
// Configure LEDC_OUTPUT_IO as input | ||
gpio_config_t io_conf = {.pin_bit_mask = (1ULL << LEDC_OUTPUT_IO), | ||
.mode = GPIO_MODE_INPUT, | ||
.pull_up_en = GPIO_PULLUP_DISABLE, | ||
.pull_down_en = GPIO_PULLDOWN_DISABLE, | ||
.intr_type = GPIO_INTR_DISABLE}; | ||
|
||
ESP_ERROR_CHECK(gpio_config(&io_conf)); | ||
ESP_ERROR_CHECK(gpio_config(&io_conf)); | ||
} |
Oops, something went wrong.