Skip to content

Commit 5863f99

Browse files
Add esp-hal-buzzer to drive a piezo-electric buzzer. (#3)
* Add `esp-hal-buzzer` to drive a piezo-electric buzzer - Initially submitted in esp-rs/esp-hal#1984 * Add missing dependencies and `.cargo/config.toml` * Use patched `esp-hal` until new release * Add check CI check for `esp-hal-buzzer`
1 parent edb742a commit 5863f99

File tree

9 files changed

+4059
-0
lines changed

9 files changed

+4059
-0
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ jobs:
6464
package: esp-hal-smartled
6565
soc: ${{ matrix.device.soc }}
6666
target: ${{ matrix.device.target }}
67+
68+
- name: Check esp-hal-buzzer
69+
uses: ./.github/actions/check-package
70+
with:
71+
package: esp-hal-buzzer
72+
soc: ${{ matrix.device.soc }}
73+
target: ${{ matrix.device.target }}

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/esp-hal-smartled/ @jessebraham
2+
/esp-hal-buzzer/ @AnthonyGrondin

esp-hal-buzzer/.cargo/config.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[alias]
2+
esp32 = "run --release --features=esp32 --target=xtensa-esp32-none-elf"
3+
esp32c2 = "run --release --features=esp32c2 --target=riscv32imc-unknown-none-elf"
4+
esp32c3 = "run --release --features=esp32c3 --target=riscv32imc-unknown-none-elf"
5+
esp32c6 = "run --release --features=esp32c6 --target=riscv32imac-unknown-none-elf"
6+
esp32h2 = "run --release --features=esp32h2 --target=riscv32imac-unknown-none-elf"
7+
esp32s2 = "run --release --features=esp32s2 --target=xtensa-esp32s2-none-elf"
8+
esp32s3 = "run --release --features=esp32s3 --target=xtensa-esp32s3-none-elf"
9+
10+
[target.'cfg(target_arch = "riscv32")']
11+
runner = "espflash flash --monitor"
12+
rustflags = [
13+
"-C", "link-arg=-Tlinkall.x",
14+
"-C", "force-frame-pointers",
15+
]
16+
17+
[target.'cfg(target_arch = "xtensa")']
18+
runner = "espflash flash --monitor"
19+
rustflags = [
20+
# GNU LD
21+
"-C", "link-arg=-Wl,-Tlinkall.x",
22+
"-C", "link-arg=-nostartfiles",
23+
24+
# LLD
25+
# "-C", "link-arg=-Tlinkall.x",
26+
# "-C", "linker=rust-lld",
27+
]
28+
29+
[unstable]
30+
build-std = ["core"]

esp-hal-buzzer/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
### Added
11+
12+
### Changed
13+
14+
### Fixed
15+
16+
### Removed
17+
18+
## 0.1.0 - 2024-08-21 - Initial release

esp-hal-buzzer/Cargo.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[package]
2+
name = "esp-hal-buzzer"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.76.0"
6+
description = "Buzzer driver for esp-hal"
7+
repository = "https://github.com/esp-rs/esp-hal-community"
8+
license = "MIT OR Apache-2.0"
9+
10+
[package.metadata.docs.rs]
11+
features = ["esp32c3"]
12+
targets = ["riscv32imc-unknown-none-elf"]
13+
14+
[dependencies]
15+
defmt = { version = "0.3.8", optional = true }
16+
document-features = "0.2.10"
17+
esp-hal = "0.20.1"
18+
fugit = "0.3.7"
19+
20+
[dev-dependencies]
21+
esp-backtrace = { version = "0.14.1", features = [
22+
"exception-handler",
23+
"panic-handler",
24+
"println",
25+
] }
26+
esp-println = "0.11.0"
27+
28+
[features]
29+
## Implement `defmt::Format` on certain types.
30+
defmt = ["dep:defmt", "esp-hal/defmt"]
31+
32+
#! ### Chip Support Feature Flags
33+
## Target the ESP32.
34+
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32"]
35+
## Target the ESP32-C2.
36+
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2"]
37+
## Target the ESP32-C3.
38+
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3"]
39+
## Target the ESP32-C6.
40+
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6"]
41+
## Target the ESP32-H2.
42+
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
43+
## Target the ESP32-S2.
44+
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
45+
## Target the ESP32-S3.
46+
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]
47+
48+
# Patch until next esp-hal release
49+
[patch.crates-io]
50+
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "a787a13" }

esp-hal-buzzer/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# esp-hal-buzzer
2+
3+
[![Crates.io](https://img.shields.io/crates/v/esp-hal-buzzer?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-hal-buzzer)
4+
[![docs.rs](https://img.shields.io/docsrs/esp-hal-buzzer?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.rs/esp-hal-buzzer)
5+
![MSRV](https://img.shields.io/badge/MSRV-1.76-blue?labelColor=1C2C2E&style=flat-square)
6+
![Crates.io](https://img.shields.io/crates/l/esp-hal-buzzer?labelColor=1C2C2E&style=flat-square)
7+
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)
8+
9+
Provides a driver to easily interact with piezo-electric buzzers for `esp-hal`. The crate uses the underlying Ledc driver and provides a user-friendly API.
10+
11+
A few songs are included in the [songs](./src/songs.rs) module. Contributions are welcome.
12+
13+
## [Documentation]
14+
15+
[documentation]: https://docs.rs/esp-hal-buzzer/
16+
17+
## Minimum Supported Rust Version (MSRV)
18+
19+
This crate is guaranteed to compile on stable Rust 1.76 and up. It _might_
20+
compile with older versions but that may change in any new patch release.
21+
22+
## License
23+
24+
Licensed under either of:
25+
26+
- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
27+
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)
28+
29+
at your option.
30+
31+
### Contribution
32+
33+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
34+
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
35+
any additional terms or conditions.

0 commit comments

Comments
 (0)