Skip to content

Commit 6bb1205

Browse files
Token-Thinkerjessebraham
authored andcommitted
update esp-hal to 0.22.0
1 parent f78ff85 commit 6bb1205

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

esp-hal-smartled/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ targets = ["riscv32imac-unknown-none-elf"]
1414
[dependencies]
1515
defmt = { version = "0.3.8", optional = true }
1616
document-features = "0.2.10"
17-
esp-hal = "0.20.0"
17+
esp-hal = "0.22.0"
1818
fugit = "0.3.7"
1919
smart-leds-trait = "0.3.0"
2020

@@ -25,7 +25,7 @@ esp-backtrace = { version = "0.14.1", features = [
2525
"panic-handler",
2626
"println",
2727
] }
28-
esp-println = "0.11.0"
28+
esp-println = "0.12.0"
2929
smart-leds = "0.4.0"
3030

3131
[features]
@@ -45,9 +45,3 @@ esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"]
4545
esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"]
4646
## Target the ESP32-S3.
4747
esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"]
48-
49-
# TODO: Remove patches prior to next release
50-
[patch.crates-io]
51-
esp-backtrace = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }
52-
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }
53-
esp-println = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" }

esp-hal-smartled/examples/hello_rgb.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![no_main]
2424

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

38-
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
39-
4038
// Each devkit uses a unique GPIO for the RGB LED, so in order to support
4139
// all chips we must unfortunately use `#[cfg]`s:
4240
cfg_if::cfg_if! {
4341
if #[cfg(feature = "esp32")] {
44-
let led_pin = io.pins.gpio33;
42+
let led_pin = peripherals.GPIO33;
4543
} else if #[cfg(feature = "esp32c3")] {
46-
let led_pin = io.pins.gpio8;
44+
let led_pin = peripherals.GPIO8;
4745
} else if #[cfg(any(feature = "esp32c6", feature = "esp32h2"))] {
48-
let led_pin = io.pins.gpio8;
46+
let led_pin = peripherals.GPIO8;
4947
} else if #[cfg(feature = "esp32s2")] {
50-
let led_pin = io.pins.gpio18;
48+
let led_pin = peripherals.GPIO18;
5149
} else if #[cfg(feature = "esp32s3")] {
52-
let led_pin = io.pins.gpio48;
50+
let led_pin = peripherals.GPIO48;
5351
}
5452
}
5553

esp-hal-smartled/src/lib.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
//! ## Example
1212
//!
1313
//! ```rust,ignore
14-
//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
1514
//! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), None).unwrap();
1615
//!
1716
//! let rmt_buffer = smartLedBuffer!(1);
18-
//! let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer);
17+
//! let mut led = SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO2, rmt_buffer);
1918
//! ```
2019
//!
2120
//! ## Feature Flags
@@ -51,6 +50,12 @@ pub enum LedAdapterError {
5150
TransmissionError(RmtError),
5251
}
5352

53+
impl From<RmtError> for LedAdapterError {
54+
fn from(e: RmtError) -> Self {
55+
LedAdapterError::TransmissionError(e)
56+
}
57+
}
58+
5459
/// Macro to allocate a buffer sized for a specific number of LEDs to be
5560
/// addressed.
5661
///
@@ -113,18 +118,18 @@ where
113118
channel: Some(channel),
114119
rmt_buffer,
115120
pulses: (
116-
u32::from(PulseCode {
117-
level1: true,
118-
length1: ((SK68XX_T0H_NS * src_clock) / 1000) as u16,
119-
level2: false,
120-
length2: ((SK68XX_T0L_NS * src_clock) / 1000) as u16,
121-
}),
122-
u32::from(PulseCode {
123-
level1: true,
124-
length1: ((SK68XX_T1H_NS * src_clock) / 1000) as u16,
125-
level2: false,
126-
length2: ((SK68XX_T1L_NS * src_clock) / 1000) as u16,
127-
}),
121+
PulseCode::new (
122+
true,
123+
((SK68XX_T0H_NS * src_clock) / 1000) as u16,
124+
false,
125+
((SK68XX_T0L_NS * src_clock) / 1000) as u16,
126+
),
127+
PulseCode::new (
128+
true,
129+
((SK68XX_T1H_NS * src_clock) / 1000) as u16,
130+
false,
131+
((SK68XX_T1L_NS * src_clock) / 1000) as u16,
132+
),
128133
),
129134
}
130135
}
@@ -188,7 +193,7 @@ where
188193

189194
// Perform the actual RMT operation. We use the u32 values here right away.
190195
let channel = self.channel.take().unwrap();
191-
match channel.transmit(&self.rmt_buffer).wait() {
196+
match channel.transmit(&self.rmt_buffer)?.wait() {
192197
Ok(chan) => {
193198
self.channel = Some(chan);
194199
Ok(())

0 commit comments

Comments
 (0)