Crate esp_hal_buzzer

Crate esp_hal_buzzer 

Source
Expand description

§Buzzer

§Overview

This driver provides an abstraction over LEDC to drive a piezo-electric buzzer through a user-friendly API.

The buzzer example contains pre-programmed songs to play through the buzzer.

§Example

let peripherals = esp_hal::init(esp_hal::Config::default());

let mut ledc = Ledc::new(peripherals.LEDC);
ledc.set_global_slow_clock(LSGlobalClkSource::APBClk);

let mut buzzer = Buzzer::new(
    &ledc,
    timer::Number::Timer0,
    channel::Number::Channel1,
    peripherals.GPIO4,
);

// Play a 1000Hz frequency
buzzer.play(1000).unwrap()

§Feature Flags

  • defmt — Implement defmt::Format on certain types.

§Chip Support Feature Flags

  • esp32 — Target the ESP32.
  • esp32c2 — Target the ESP32-C2.
  • esp32c3 — Target the ESP32-C3.
  • esp32c6 — Target the ESP32-C6.
  • esp32h2 — Target the ESP32-H2.
  • esp32s2 — Target the ESP32-S2.
  • esp32s3 — Target the ESP32-S3.

Modules§

notes
Helper module to help create songs that can be played on the buzzer.

Macros§

song
Generate a ToneValue slice from Song beats and tempo

Structs§

Buzzer
A buzzer instance driven by Ledc
ToneValue
Represents a tone value to play through the buzzer

Enums§

Error
Errors from Buzzer
VolumeType
Represents different volume strategies for the buzzer.