Skip to content

Commit 728f276

Browse files
badamsonbugadani
andauthored
update esp-hal-smartled (and esp-hal-buzzer) for esp-hal 1.0.0-rc.1 (#53)
* update esp-hal-buzzer for esp-hal 1.0.0-rc.1 * update esp-hal-smartled for esp-hal 1.0.0-rc.1 This replaces esp-hal-embassy with esp-rtos and updates deps. It makes backwards-incompatible changes for updates to the esp-hal rmt api: - https://docs.rs/esp-hal/1.0.0-rc.0/esp_hal/rmt/index.html - https://docs.rs/esp-hal/1.0.0-rc.1/esp_hal/rmt/index.html * move buzzer examples to gpio4 - see: #53 (comment) * use requires-unstable instead of unstable in libs, relax version reqs - addresses comment: #53 (comment) - docs: https://docs.espressif.com/projects/rust/esp-hal/1.0.0-rc.1/esp32c6/esp_hal/index.html#library-usage * use PulseCode::end_marker() instead of default() for `const` contexts - addresses #53 (comment) * with changelog entries, bump `esp-hal-buzzer` to `0.3.0` and `esp-hal-smartled` to `0.17.0` - `cargo-edit`, `cargo set-version --workspace --bump minor` * Fix running examples --------- Co-authored-by: Dániel Buga <[email protected]>
1 parent 5e0fed3 commit 728f276

File tree

12 files changed

+141
-134
lines changed

12 files changed

+141
-134
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A collection of crates for use alongside [esp-hal], but which are maintained by
1212

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

1818
This repository also provides a [`justfile`](https://github.com/casey/just) which provides

esp-hal-buzzer/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## 0.3.0
11+
12+
### Changed
13+
14+
- 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)
15+
- Changed the pin in the example to GPIO4 (#53)
16+
17+
## 0.2.0
18+
1019
### Added
1120

1221
- Added `Buzzer::play_tones_from_slice(&self, sequence: &[u32], timings: &[u32])` to allow tone playback using slices (#39)

esp-hal-buzzer/Cargo.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp-hal-buzzer"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2024"
55
rust-version = "1.88"
66
description = "Buzzer driver for esp-hal"
@@ -12,37 +12,37 @@ features = ["esp32c3", "esp-hal/unstable"]
1212
targets = ["riscv32imc-unknown-none-elf"]
1313

1414
[dependencies]
15-
defmt = { version = "1.0.1", optional = true }
16-
document-features = "0.2.11"
15+
defmt = { version = "^1.0.1", optional = true }
16+
document-features = "^0.2.12"
1717
# Unstable required for:
1818
# - ledc
1919
# - delay
20-
esp-hal = { version = "1.0.0-rc.0", features = ["requires-unstable"] }
20+
esp-hal = { version = "1.0.0-rc.1", features = ["requires-unstable"] }
2121

2222
[dev-dependencies]
23-
esp-backtrace = { version = "0.17.0", features = [
24-
"exception-handler",
23+
esp-backtrace = { version = "0.18", features = [
2524
"panic-handler",
2625
"println",
2726
] }
28-
esp-bootloader-esp-idf = "0.1.0"
29-
esp-println = "0.15.0"
27+
esp-bootloader-esp-idf = "0.3"
28+
esp-hal = { version = "1.0.0-rc.1", features = ["unstable"] }
29+
esp-println = "0.16"
3030

3131
[features]
3232
## Implement `defmt::Format` on certain types.
3333
defmt = ["dep:defmt", "esp-hal/defmt"]
3434
#! ### Chip Support Feature Flags
3535
## Target the ESP32.
36-
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32"]
36+
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-bootloader-esp-idf/esp32"]
3737
## Target the ESP32-C2.
38-
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2"]
38+
esp32c2 = ["esp-backtrace/esp32c2", "esp-hal/esp32c2", "esp-println/esp32c2", "esp-bootloader-esp-idf/esp32c2"]
3939
## Target the ESP32-C3.
40-
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3"]
40+
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-bootloader-esp-idf/esp32c3"]
4141
## Target the ESP32-C6.
42-
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6"]
42+
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
4343
## Target the ESP32-H2.
44-
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
44+
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2"]
4545
## Target the ESP32-S2.
46-
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
46+
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-bootloader-esp-idf/esp32s2"]
4747
## Target the ESP32-S3.
48-
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]
48+
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-bootloader-esp-idf/esp32s3"]

esp-hal-buzzer/examples/buzzer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! Play songs through a piezo-electric buzzer plugged on GPIO6.
1+
//! Play songs through a piezo-electric buzzer plugged on GPIO4.
22
//!
33
//! This assumes that a piezo-electric buzzer is connected to the pin assigned
4-
//! to `buzzer`. (GPIO6)
4+
//! to `buzzer`. (GPIO4)
55
66
#![no_std]
77
#![no_main]
@@ -27,7 +27,7 @@ fn main() -> ! {
2727
&ledc,
2828
timer::Number::Timer0,
2929
channel::Number::Channel1,
30-
peripherals.GPIO6,
30+
peripherals.GPIO4,
3131
);
3232

3333
buzzer.play_song(&DOOM).unwrap();

esp-hal-buzzer/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! &ledc,
2121
//! timer::Number::Timer0,
2222
//! channel::Number::Channel1,
23-
//! peripherals.GPIO6,
23+
//! peripherals.GPIO4,
2424
//! );
2525
//!
2626
//! // Play a 1000Hz frequency
@@ -38,7 +38,7 @@ use core::fmt::Debug;
3838
use esp_hal::{
3939
clock::Clocks,
4040
delay::Delay,
41-
gpio::{AnyPin, Level, Output, OutputConfig, OutputPin},
41+
gpio::{AnyPin, DriveMode, Level, Output, OutputConfig, OutputPin},
4242
ledc::{
4343
Ledc, LowSpeed,
4444
channel::{self, Channel, ChannelIFace},
@@ -203,7 +203,7 @@ impl<'a> Buzzer<'a> {
203203
.configure(channel::config::Config {
204204
timer: &self.timer,
205205
duty_pct: level,
206-
pin_config: channel::config::PinConfig::PushPull,
206+
drive_mode: DriveMode::PushPull,
207207
})
208208
.map_err(|e| e.into())
209209
}
@@ -244,7 +244,7 @@ impl<'a> Buzzer<'a> {
244244
.configure(channel::config::Config {
245245
timer: &self.timer,
246246
duty_pct: 0,
247-
pin_config: channel::config::PinConfig::PushPull,
247+
drive_mode: DriveMode::PushPull,
248248
})
249249
.unwrap()
250250
}
@@ -282,7 +282,7 @@ impl<'a> Buzzer<'a> {
282282
timer: &self.timer,
283283
// Use volume as duty if set since we use the same channel.
284284
duty_pct: self.volume.as_ref().map_or(50, |v| v.level),
285-
pin_config: channel::config::PinConfig::PushPull,
285+
drive_mode: DriveMode::PushPull,
286286
})?;
287287

288288
Ok(())

esp-hal-smartled/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## 0.17.0
11+
12+
### Changed
13+
14+
- 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)
15+
1016
## 0.15.0
1117

1218
### Added

esp-hal-smartled/Cargo.toml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp-hal-smartled"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
edition = "2024"
55
rust-version = "1.88"
66
description = "RMT peripheral adapter for smart LEDs"
@@ -12,39 +12,40 @@ features = ["esp32c6", "esp-hal/unstable"]
1212
targets = ["riscv32imac-unknown-none-elf"]
1313

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

2121
[dev-dependencies]
22-
cfg-if = "1.0.0"
23-
esp-backtrace = { version = "0.17.0", features = [
24-
"exception-handler",
22+
cfg-if = "1.0"
23+
esp-backtrace = { version = "0.18", features = [
2524
"panic-handler",
2625
"println",
2726
] }
28-
esp-hal-embassy = "0.9.0"
29-
esp-bootloader-esp-idf = "0.2"
30-
embassy-executor = "0.7"
27+
esp-hal = { version = "1.0.0-rc.1", features = ["unstable"] }
28+
# Use esp-rtos for embassy support instead of esp-hal-embassy
29+
esp-rtos = { version = "^0.1.1", features = ["embassy"] }
30+
esp-bootloader-esp-idf = "0.3"
31+
embassy-executor = "0.9"
3132
embassy-time = "0.5"
32-
esp-println = "0.15.0"
33-
smart-leds = "0.4.0"
33+
esp-println = "0.16"
34+
smart-leds = "0.4"
3435

3536
[features]
3637
## Implement `defmt::Format` on certain types.
3738
defmt = ["dep:defmt", "esp-hal/defmt"]
3839
#! ### Chip Support Feature Flags
3940
## Target the ESP32.
40-
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-hal-embassy/esp32", "esp-bootloader-esp-idf/esp32"]
41+
esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-bootloader-esp-idf/esp32", "esp-rtos/esp32"]
4142
## Target the ESP32-C3.
42-
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-hal-embassy/esp32c3", "esp-bootloader-esp-idf/esp32c3"]
43+
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-bootloader-esp-idf/esp32c3", "esp-rtos/esp32c3"]
4344
## Target the ESP32-C6.
44-
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-hal-embassy/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
45+
esp32c6 = ["esp-backtrace/esp32c6", "esp-hal/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6", "esp-rtos/esp32c6"]
4546
## Target the ESP32-H2.
46-
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-hal-embassy/esp32h2", "esp-bootloader-esp-idf/esp32h2"]
47+
esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2", "esp-rtos/esp32h2"]
4748
## Target the ESP32-S2.
48-
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-hal-embassy/esp32s2", "esp-bootloader-esp-idf/esp32s2"]
49+
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2", "esp-bootloader-esp-idf/esp32s2", "esp-rtos/esp32s2"]
4950
## Target the ESP32-S3.
50-
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-hal-embassy/esp32s3", "esp-bootloader-esp-idf/esp32s3"]
51+
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3", "esp-bootloader-esp-idf/esp32s3", "esp-rtos/esp32s3"]

esp-hal-smartled/examples/hello_rgb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn main() -> ! {
6565

6666
// Each devkit uses a unique GPIO for the RGB LED, so in order to support
6767
// all chips we must unfortunately use `#[cfg]`s:
68-
let mut led: SmartLedsAdapter<_, 25> = {
68+
let mut led = {
6969
cfg_if::cfg_if! {
7070
if #[cfg(feature = "esp32")] {
7171
SmartLedsAdapter::new(rmt_channel, p.GPIO33, rmt_buffer)

esp-hal-smartled/examples/hello_rgb_async.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@ use smart_leds::{
3434

3535
esp_bootloader_esp_idf::esp_app_desc!();
3636

37-
#[esp_hal_embassy::main]
37+
#[esp_rtos::main]
3838
async fn main(_spawner: Spawner) -> ! {
3939
// Initialize the HAL Peripherals
4040
let p = esp_hal::init(Config::default());
41-
let timg0 = TimerGroup::new(p.TIMG0);
42-
esp_hal_embassy::init(timg0.timer0);
41+
#[cfg(target_arch = "riscv32")]
42+
{
43+
let timg0 = TimerGroup::new(p.TIMG0);
44+
let sw_interrupt =
45+
esp_hal::interrupt::software::SoftwareInterruptControl::new(p.SW_INTERRUPT);
46+
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
47+
}
48+
#[cfg(target_arch = "xtensa")]
49+
{
50+
let timg0 = TimerGroup::new(p.TIMG0);
51+
esp_rtos::start(timg0.timer0);
52+
}
4353

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

6676
// Each devkit uses a unique GPIO for the RGB LED, so in order to support
6777
// all chips we must unfortunately use `#[cfg]`s:
68-
let mut led: SmartLedsAdapterAsync<_, 25> = {
78+
let mut led = {
6979
cfg_if::cfg_if! {
7080
if #[cfg(feature = "esp32")] {
7181
SmartLedsAdapterAsync::new(rmt_channel, p.GPIO33, rmt_buffer)

esp-hal-smartled/examples/hello_rgbw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn main() -> ! {
6363

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

0 commit comments

Comments
 (0)