Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add esp-hal-buzzer to drive a piezo-electric buzzer. #3

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ jobs:
package: esp-hal-smartled
soc: ${{ matrix.device.soc }}
target: ${{ matrix.device.target }}

- name: Check esp-hal-buzzer
uses: ./.github/actions/check-package
with:
package: esp-hal-buzzer
soc: ${{ matrix.device.soc }}
target: ${{ matrix.device.target }}
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/esp-hal-smartled/ @jessebraham
/esp-hal-buzzer/ @AnthonyGrondin
30 changes: 30 additions & 0 deletions esp-hal-buzzer/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[alias]
esp32 = "run --release --features=esp32 --target=xtensa-esp32-none-elf"
esp32c2 = "run --release --features=esp32c2 --target=riscv32imc-unknown-none-elf"
esp32c3 = "run --release --features=esp32c3 --target=riscv32imc-unknown-none-elf"
esp32c6 = "run --release --features=esp32c6 --target=riscv32imac-unknown-none-elf"
esp32h2 = "run --release --features=esp32h2 --target=riscv32imac-unknown-none-elf"
esp32s2 = "run --release --features=esp32s2 --target=xtensa-esp32s2-none-elf"
esp32s3 = "run --release --features=esp32s3 --target=xtensa-esp32s3-none-elf"

[target.'cfg(target_arch = "riscv32")']
runner = "espflash flash --monitor"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "force-frame-pointers",
]

[target.'cfg(target_arch = "xtensa")']
runner = "espflash flash --monitor"
rustflags = [
# GNU LD
"-C", "link-arg=-Wl,-Tlinkall.x",
"-C", "link-arg=-nostartfiles",

# LLD
# "-C", "link-arg=-Tlinkall.x",
# "-C", "linker=rust-lld",
]

[unstable]
build-std = ["core"]
18 changes: 18 additions & 0 deletions esp-hal-buzzer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

### Changed

### Fixed

### Removed

## 0.1.0 - 2024-08-21 - Initial release
50 changes: 50 additions & 0 deletions esp-hal-buzzer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "esp-hal-buzzer"
version = "0.1.0"
edition = "2021"
rust-version = "1.76.0"
description = "Buzzer driver for esp-hal"
repository = "https://github.com/esp-rs/esp-hal-community"
license = "MIT OR Apache-2.0"

[package.metadata.docs.rs]
features = ["esp32c3"]
targets = ["riscv32imc-unknown-none-elf"]

[dependencies]
defmt = { version = "0.3.8", optional = true }
document-features = "0.2.10"
esp-hal = "0.20.1"
fugit = "0.3.7"

[dev-dependencies]
esp-backtrace = { version = "0.14.1", features = [
"exception-handler",
"panic-handler",
"println",
] }
esp-println = "0.11.0"

[features]
## Implement `defmt::Format` on certain types.
defmt = ["dep:defmt", "esp-hal/defmt"]

#! ### Chip Support Feature Flags
## Target the ESP32.
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32"]
## Target the ESP32-C2.
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2"]
## Target the ESP32-C3.
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3"]
## Target the ESP32-C6.
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6"]
## Target the ESP32-H2.
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
## Target the ESP32-S2.
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
## Target the ESP32-S3.
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]

# Patch until next esp-hal release
[patch.crates-io]
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "a787a13" }
35 changes: 35 additions & 0 deletions esp-hal-buzzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# esp-hal-buzzer

[![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)
[![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)
![MSRV](https://img.shields.io/badge/MSRV-1.76-blue?labelColor=1C2C2E&style=flat-square)
![Crates.io](https://img.shields.io/crates/l/esp-hal-buzzer?labelColor=1C2C2E&style=flat-square)
[![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)

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.

A few songs are included in the [songs](./src/songs.rs) module. Contributions are welcome.

## [Documentation]

[documentation]: https://docs.rs/esp-hal-buzzer/

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.76 and up. It _might_
compile with older versions but that may change in any new patch release.

## License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
any additional terms or conditions.
Loading