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

update esp-hal to 0.22.0 #14

Merged
merged 1 commit into from
Jan 2, 2025
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
10 changes: 2 additions & 8 deletions esp-hal-smartled/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["riscv32imac-unknown-none-elf"]
[dependencies]
defmt = { version = "0.3.8", optional = true }
document-features = "0.2.10"
esp-hal = "0.20.0"
esp-hal = "0.22.0"
fugit = "0.3.7"
smart-leds-trait = "0.3.0"

Expand All @@ -25,7 +25,7 @@ esp-backtrace = { version = "0.14.1", features = [
"panic-handler",
"println",
] }
esp-println = "0.11.0"
esp-println = "0.12.0"
smart-leds = "0.4.0"

[features]
Expand All @@ -45,9 +45,3 @@ esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
## Target the ESP32-S3.
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]

# TODO: Remove patches prior to next release
[patch.crates-io]
esp-backtrace = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }
esp-println = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }
14 changes: 6 additions & 8 deletions esp-hal-smartled/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#![no_main]

use esp_backtrace as _;
use esp_hal::{delay::Delay, gpio::Io, prelude::*, rmt::Rmt};
use esp_hal::{delay::Delay, prelude::*, rmt::Rmt};
use esp_hal_smartled::{smartLedBuffer, SmartLedsAdapter};
use smart_leds::{
brightness, gamma,
Expand All @@ -35,21 +35,19 @@ use smart_leds::{
fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default());

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

// Each devkit uses a unique GPIO for the RGB LED, so in order to support
// all chips we must unfortunately use `#[cfg]`s:
cfg_if::cfg_if! {
if #[cfg(feature = "esp32")] {
let led_pin = io.pins.gpio33;
let led_pin = peripherals.GPIO33;
} else if #[cfg(feature = "esp32c3")] {
let led_pin = io.pins.gpio8;
let led_pin = peripherals.GPIO8;
} else if #[cfg(any(feature = "esp32c6", feature = "esp32h2"))] {
let led_pin = io.pins.gpio8;
let led_pin = peripherals.GPIO8;
} else if #[cfg(feature = "esp32s2")] {
let led_pin = io.pins.gpio18;
let led_pin = peripherals.GPIO18;
} else if #[cfg(feature = "esp32s3")] {
let led_pin = io.pins.gpio48;
let led_pin = peripherals.GPIO48;
}
}

Expand Down
35 changes: 20 additions & 15 deletions esp-hal-smartled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
//! ## Example
//!
//! ```rust,ignore
//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
//! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), None).unwrap();
//!
//! let rmt_buffer = smartLedBuffer!(1);
//! let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer);
//! let mut led = SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO2, rmt_buffer);
//! ```
//!
//! ## Feature Flags
Expand Down Expand Up @@ -51,6 +50,12 @@ pub enum LedAdapterError {
TransmissionError(RmtError),
}

impl From<RmtError> for LedAdapterError {
fn from(e: RmtError) -> Self {
LedAdapterError::TransmissionError(e)
}
}

/// Macro to allocate a buffer sized for a specific number of LEDs to be
/// addressed.
///
Expand Down Expand Up @@ -113,18 +118,18 @@ where
channel: Some(channel),
rmt_buffer,
pulses: (
u32::from(PulseCode {
level1: true,
length1: ((SK68XX_T0H_NS * src_clock) / 1000) as u16,
level2: false,
length2: ((SK68XX_T0L_NS * src_clock) / 1000) as u16,
}),
u32::from(PulseCode {
level1: true,
length1: ((SK68XX_T1H_NS * src_clock) / 1000) as u16,
level2: false,
length2: ((SK68XX_T1L_NS * src_clock) / 1000) as u16,
}),
PulseCode::new (
true,
((SK68XX_T0H_NS * src_clock) / 1000) as u16,
false,
((SK68XX_T0L_NS * src_clock) / 1000) as u16,
),
PulseCode::new (
true,
((SK68XX_T1H_NS * src_clock) / 1000) as u16,
false,
((SK68XX_T1L_NS * src_clock) / 1000) as u16,
),
),
}
}
Expand Down Expand Up @@ -188,7 +193,7 @@ where

// Perform the actual RMT operation. We use the u32 values here right away.
let channel = self.channel.take().unwrap();
match channel.transmit(&self.rmt_buffer).wait() {
match channel.transmit(&self.rmt_buffer)?.wait() {
Ok(chan) => {
self.channel = Some(chan);
Ok(())
Expand Down
Loading