MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / buzzerLedcInit

Method buzzerLedcInit

Devices/m5stack-papers3/Source/devices/Power.cpp:43–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43void PaperS3Power::buzzerLedcInit() {
44 if (buzzerInitialized) {
45 LOG_I(TAG, "Buzzer already initialized");
46 return;
47 }
48
49 ledc_timer_config_t timer_cfg = {
50 .speed_mode = LEDC_LOW_SPEED_MODE,
51 .duty_resolution = LEDC_TIMER_13_BIT,
52 .timer_num = LEDC_TIMER_0,
53 .freq_hz = 1000,
54 .clk_cfg = LEDC_AUTO_CLK,
55 .deconfigure = false
56 };
57 esp_err_t err = ledc_timer_config(&timer_cfg);
58 if (err != ESP_OK) {
59 LOG_E(TAG, "LEDC timer config failed: %s", esp_err_to_name(err));
60 return;
61 }
62
63 ledc_channel_config_t channel_cfg = {
64 .gpio_num = BUZZER_PIN,
65 .speed_mode = LEDC_LOW_SPEED_MODE,
66 .channel = LEDC_CHANNEL_0,
67 .intr_type = LEDC_INTR_DISABLE,
68 .timer_sel = LEDC_TIMER_0,
69 .duty = 0,
70 .hpoint = 0,
71 .sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD,
72 .flags = {
73 .output_invert = 0
74 }
75 };
76 err = ledc_channel_config(&channel_cfg);
77 if (err != ESP_OK) {
78 LOG_E(TAG, "LEDC channel config failed: %s", esp_err_to_name(err));
79 return;
80 }
81
82 buzzerInitialized = true;
83}
84
85void PaperS3Power::initializePowerOff() {
86 if (powerOffInitialized) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected