Skip to content

Commit

Permalink
smartled: updates for changes in the RMT driver
Browse files Browse the repository at this point in the history
  • Loading branch information
liebman committed Nov 14, 2024
1 parent f78ff85 commit 46713b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion 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.21.0"
fugit = "0.3.7"
smart-leds-trait = "0.3.0"

Expand Down
32 changes: 19 additions & 13 deletions esp-hal-smartled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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 +119,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 +194,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

0 comments on commit 46713b1

Please sign in to comment.