Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A collection of crates for use alongside [esp-hal], but which are maintained by

The following command can be used to run the smart LED example on a ESP32C6 target.
```bash
cargo +stable run --example hello_rgb --features "esp32c6,esp-hal/unstable" --target=riscv32imac-unknown-none-elf --release
cargo +stable run --example hello_rgb --features "esp32c6" --target=riscv32imac-unknown-none-elf --release
```

This repository also provides a [`justfile`](https://github.com/casey/just) which provides
Expand Down
9 changes: 9 additions & 0 deletions esp-hal-buzzer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.3.0

### Changed

- Updated `esp-hal` to `v1.0.0-rc.1` and updated related dependencies, including breaking changes for `esp_hal::gpio::DriveMode`. See the [esp-hal 1.0.0-rc.0 migration guide](https://github.com/esp-rs/esp-hal/blob/main/esp-hal/MIGRATING-1.0.0-rc.0.md) for details (#53)
- Changed the pin in the example to GPIO4 (#53)

## 0.2.0

### Added

- Added `Buzzer::play_tones_from_slice(&self, sequence: &[u32], timings: &[u32])` to allow tone playback using slices (#39)
Expand Down
30 changes: 15 additions & 15 deletions esp-hal-buzzer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp-hal-buzzer"
version = "0.2.0"
version = "0.3.0"
edition = "2024"
rust-version = "1.88"
description = "Buzzer driver for esp-hal"
Expand All @@ -12,37 +12,37 @@ features = ["esp32c3", "esp-hal/unstable"]
targets = ["riscv32imc-unknown-none-elf"]

[dependencies]
defmt = { version = "1.0.1", optional = true }
document-features = "0.2.11"
defmt = { version = "^1.0.1", optional = true }
document-features = "^0.2.12"
# Unstable required for:
# - ledc
# - delay
esp-hal = { version = "1.0.0-rc.0", features = ["requires-unstable"] }
esp-hal = { version = "1.0.0-rc.1", features = ["requires-unstable"] }

[dev-dependencies]
esp-backtrace = { version = "0.17.0", features = [
"exception-handler",
esp-backtrace = { version = "0.18", features = [
"panic-handler",
"println",
] }
esp-bootloader-esp-idf = "0.1.0"
esp-println = "0.15.0"
esp-bootloader-esp-idf = "0.3"
esp-hal = { version = "1.0.0-rc.1", features = ["unstable"] }
esp-println = "0.16"

[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"]
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-bootloader-esp-idf/esp32"]
## Target the ESP32-C2.
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2"]
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2", "esp-bootloader-esp-idf/esp32c2"]
## Target the ESP32-C3.
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3"]
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-bootloader-esp-idf/esp32c3"]
## Target the ESP32-C6.
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6"]
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
## Target the ESP32-H2.
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2"]
## Target the ESP32-S2.
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-bootloader-esp-idf/esp32s2"]
## Target the ESP32-S3.
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-bootloader-esp-idf/esp32s3"]
6 changes: 3 additions & 3 deletions esp-hal-buzzer/examples/buzzer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Play songs through a piezo-electric buzzer plugged on GPIO6.
//! Play songs through a piezo-electric buzzer plugged on GPIO4.
//!
//! This assumes that a piezo-electric buzzer is connected to the pin assigned
//! to `buzzer`. (GPIO6)
//! to `buzzer`. (GPIO4)

#![no_std]
#![no_main]
Expand All @@ -27,7 +27,7 @@ fn main() -> ! {
&ledc,
timer::Number::Timer0,
channel::Number::Channel1,
peripherals.GPIO6,
peripherals.GPIO4,
);

buzzer.play_song(&DOOM).unwrap();
Expand Down
10 changes: 5 additions & 5 deletions esp-hal-buzzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! &ledc,
//! timer::Number::Timer0,
//! channel::Number::Channel1,
//! peripherals.GPIO6,
//! peripherals.GPIO4,
//! );
//!
//! // Play a 1000Hz frequency
Expand All @@ -38,7 +38,7 @@ use core::fmt::Debug;
use esp_hal::{
clock::Clocks,
delay::Delay,
gpio::{AnyPin, Level, Output, OutputConfig, OutputPin},
gpio::{AnyPin, DriveMode, Level, Output, OutputConfig, OutputPin},
ledc::{
Ledc, LowSpeed,
channel::{self, Channel, ChannelIFace},
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<'a> Buzzer<'a> {
.configure(channel::config::Config {
timer: &self.timer,
duty_pct: level,
pin_config: channel::config::PinConfig::PushPull,
drive_mode: DriveMode::PushPull,
})
.map_err(|e| e.into())
}
Expand Down Expand Up @@ -244,7 +244,7 @@ impl<'a> Buzzer<'a> {
.configure(channel::config::Config {
timer: &self.timer,
duty_pct: 0,
pin_config: channel::config::PinConfig::PushPull,
drive_mode: DriveMode::PushPull,
})
.unwrap()
}
Expand Down Expand Up @@ -282,7 +282,7 @@ impl<'a> Buzzer<'a> {
timer: &self.timer,
// Use volume as duty if set since we use the same channel.
duty_pct: self.volume.as_ref().map_or(50, |v| v.level),
pin_config: channel::config::PinConfig::PushPull,
drive_mode: DriveMode::PushPull,
})?;

Ok(())
Expand Down
6 changes: 6 additions & 0 deletions esp-hal-smartled/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.17.0

### Changed

- Updated `esp-hal` to `v1.0.0-rc.1` and updated related dependencies, including backwards-incompatible changes for updates to the `esp-hal::rmt` api ([rc0](https://docs.rs/esp-hal/1.0.0-rc.0/esp_hal/rmt/index.html), [rc1](https://docs.rs/esp-hal/1.0.0-rc.1/esp_hal/rmt/index.html)) like the new `PulseCode` type. See [esp-hal 1.0.0-rc.0 migration guide](https://github.com/esp-rs/esp-hal/blob/main/esp-hal/MIGRATING-1.0.0-rc.0.md) for details (#53)

## 0.15.0

### Added
Expand Down
39 changes: 20 additions & 19 deletions esp-hal-smartled/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp-hal-smartled"
version = "0.16.0"
version = "0.17.0"
edition = "2024"
rust-version = "1.88"
description = "RMT peripheral adapter for smart LEDs"
Expand All @@ -12,39 +12,40 @@ features = ["esp32c6", "esp-hal/unstable"]
targets = ["riscv32imac-unknown-none-elf"]

[dependencies]
defmt = { version = "1.0.1", optional = true }
document-features = "0.2.10"
esp-hal = { version = "1.0.0-rc.0", features = ["requires-unstable"] }
defmt = { version = "^1.0.1", optional = true }
document-features = "^0.2.12"
esp-hal = { version = "1.0.0-rc.1", features = ["requires-unstable"] }
rgb = "0.8.52"
smart-leds-trait = "0.3.1"
smart-leds-trait = "^0.3.2"

[dev-dependencies]
cfg-if = "1.0.0"
esp-backtrace = { version = "0.17.0", features = [
"exception-handler",
cfg-if = "1.0"
esp-backtrace = { version = "0.18", features = [
"panic-handler",
"println",
] }
esp-hal-embassy = "0.9.0"
esp-bootloader-esp-idf = "0.2"
embassy-executor = "0.7"
esp-hal = { version = "1.0.0-rc.1", features = ["unstable"] }
# Use esp-rtos for embassy support instead of esp-hal-embassy
esp-rtos = { version = "^0.1.1", features = ["embassy"] }
esp-bootloader-esp-idf = "0.3"
embassy-executor = "0.9"
embassy-time = "0.5"
esp-println = "0.15.0"
smart-leds = "0.4.0"
esp-println = "0.16"
smart-leds = "0.4"

[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", "esp-hal-embassy/esp32", "esp-bootloader-esp-idf/esp32"]
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-bootloader-esp-idf/esp32", "esp-rtos/esp32"]
## Target the ESP32-C3.
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-hal-embassy/esp32c3", "esp-bootloader-esp-idf/esp32c3"]
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-bootloader-esp-idf/esp32c3", "esp-rtos/esp32c3"]
## Target the ESP32-C6.
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-hal-embassy/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6", "esp-rtos/esp32c6"]
## Target the ESP32-H2.
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-hal-embassy/esp32h2", "esp-bootloader-esp-idf/esp32h2"]
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2", "esp-rtos/esp32h2"]
## Target the ESP32-S2.
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-hal-embassy/esp32s2", "esp-bootloader-esp-idf/esp32s2"]
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-bootloader-esp-idf/esp32s2", "esp-rtos/esp32s2"]
## Target the ESP32-S3.
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-hal-embassy/esp32s3", "esp-bootloader-esp-idf/esp32s3"]
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-bootloader-esp-idf/esp32s3", "esp-rtos/esp32s3"]
2 changes: 1 addition & 1 deletion esp-hal-smartled/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() -> ! {

// Each devkit uses a unique GPIO for the RGB LED, so in order to support
// all chips we must unfortunately use `#[cfg]`s:
let mut led: SmartLedsAdapter<_, 25> = {
let mut led = {
cfg_if::cfg_if! {
if #[cfg(feature = "esp32")] {
SmartLedsAdapter::new(rmt_channel, p.GPIO33, rmt_buffer)
Expand Down
20 changes: 15 additions & 5 deletions esp-hal-smartled/examples/hello_rgb_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@ use smart_leds::{

esp_bootloader_esp_idf::esp_app_desc!();

#[esp_hal_embassy::main]
#[esp_rtos::main]
async fn main(_spawner: Spawner) -> ! {
// Initialize the HAL Peripherals
let p = esp_hal::init(Config::default());
let timg0 = TimerGroup::new(p.TIMG0);
esp_hal_embassy::init(timg0.timer0);
#[cfg(target_arch = "riscv32")]
{
let timg0 = TimerGroup::new(p.TIMG0);
let sw_interrupt =
esp_hal::interrupt::software::SoftwareInterruptControl::new(p.SW_INTERRUPT);
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
}
#[cfg(target_arch = "xtensa")]
{
let timg0 = TimerGroup::new(p.TIMG0);
esp_rtos::start(timg0.timer0);
}

// Configure RMT (Remote Control Transceiver) peripheral globally
// <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/rmt.html>
Expand All @@ -61,11 +71,11 @@ async fn main(_spawner: Spawner) -> ! {
// We use one of the RMT channels to instantiate a `SmartLedsAdapterAsync` which can
// be used directly with all `smart_led` implementations
let rmt_channel = rmt.channel0;
let rmt_buffer = [0_u32; buffer_size_async(1)];
let rmt_buffer = [esp_hal::rmt::PulseCode::default(); buffer_size_async(1)];

// Each devkit uses a unique GPIO for the RGB LED, so in order to support
// all chips we must unfortunately use `#[cfg]`s:
let mut led: SmartLedsAdapterAsync<_, 25> = {
let mut led = {
cfg_if::cfg_if! {
if #[cfg(feature = "esp32")] {
SmartLedsAdapterAsync::new(rmt_channel, p.GPIO33, rmt_buffer)
Expand Down
2 changes: 1 addition & 1 deletion esp-hal-smartled/examples/hello_rgbw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn main() -> ! {

// Each devkit uses a unique GPIO for the RGB LED, so in order to support
// all chips we must unfortunately use `#[cfg]`s:
let mut led: SmartLedsAdapter<_, 33, rgb::Rgba<u8>> = {
let mut led: SmartLedsAdapter<'_, { esp_hal_smartled::buffer_size_rgbw(1) }, rgb::Rgba<u8>> = {
cfg_if::cfg_if! {
if #[cfg(feature = "esp32")] {
SmartLedsAdapter::new_with_color(rmt_channel, p.GPIO33, rmt_buffer)
Expand Down
Loading
Loading