Skip to content

Commit

Permalink
refactor: use chromium code style
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Apr 3, 2024
1 parent 2563150 commit e98b06a
Show file tree
Hide file tree
Showing 28 changed files with 5,974 additions and 5,425 deletions.
16 changes: 15 additions & 1 deletion .clang-format
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 examples/ESP-IDF/minino/components/bluetooth_scanner/bluetooth_scanner.c

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <stdbool.h>

typedef struct {
uint8_t mac[6];
int rssi;
const char* name;
bool is_airtag;
uint16_t count;
bool has_finished;
uint8_t mac[6];
int rssi;
const char* name;
bool is_airtag;
uint16_t count;
bool has_finished;
} bluetooth_scanner_record_t;

typedef void (*bluetooth_scanner_cb_t)(bluetooth_scanner_record_t record);
Expand Down
72 changes: 35 additions & 37 deletions examples/ESP-IDF/minino/components/buzzer/buzzer.c
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));
}
Loading

0 comments on commit e98b06a

Please sign in to comment.