Skip to content

Commit a613668

Browse files
authored
feat(esp-hal-smartled): Update to esp-hal 1.0.0-beta.0 (#20)
* fix(smartled): Update to esp-hal 1.0.0-beta.0 * chore(smartled): Prepare for 0.15.0 - remove dependency `fugit` - correct doc in `lib.rs` * chore: format document
1 parent ad75112 commit a613668

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/esp-hal-buzzer/ @AnthonyGrondin
2+
/esp-hal-smartled/ @taorye

esp-hal-smartled/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ targets = ["riscv32imac-unknown-none-elf"]
1414
[dependencies]
1515
defmt = { version = "0.3.10", optional = true }
1616
document-features = "0.2.10"
17-
esp-hal = "0.23.1"
18-
fugit = "0.3.7"
17+
esp-hal = { version = "1.0.0-beta.0", features = ["unstable"] }
1918
smart-leds-trait = "0.3.0"
2019

2120
[dev-dependencies]

esp-hal-smartled/examples/hello_rgb.rs

Lines changed: 3 additions & 3 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, main, rmt::Rmt, time::RateExtU32};
26+
use esp_hal::{delay::Delay, main, rmt::Rmt, time::Rate};
2727
use esp_hal_smartled::{smartLedBuffer, SmartLedsAdapter};
2828
use smart_leds::{
2929
brightness, gamma,
@@ -54,9 +54,9 @@ fn main() -> ! {
5454
// Configure RMT peripheral globally
5555
cfg_if::cfg_if! {
5656
if #[cfg(feature = "esp32h2")] {
57-
let freq = 32.MHz();
57+
let freq = Rate::from_mhz(32);
5858
} else {
59-
let freq = 80.MHz();
59+
let freq = Rate::from_mhz(80);
6060
}
6161
}
6262

esp-hal-smartled/src/lib.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//! ## Example
1212
//!
1313
//! ```rust,ignore
14-
//! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), None).unwrap();
14+
//! let rmt = Rmt::new(peripherals.RMT, Rate::from_mhz(80)).unwrap();
1515
//!
1616
//! let rmt_buffer = smartLedBuffer!(1);
17-
//! let mut led = SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO2, rmt_buffer);
17+
//! let mut led = SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO8, rmt_buffer);
1818
//! ```
1919
//!
2020
//! ## Feature Flags
@@ -27,7 +27,7 @@ use core::{fmt::Debug, slice::IterMut};
2727

2828
use esp_hal::{
2929
clock::Clocks,
30-
gpio::OutputPin,
30+
gpio::{Level, OutputPin},
3131
peripheral::Peripheral,
3232
rmt::{Error as RmtError, PulseCode, TxChannel, TxChannelConfig, TxChannelCreator},
3333
};
@@ -99,35 +99,32 @@ where
9999
O: OutputPin + 'd,
100100
C: TxChannelCreator<'d, TX, O>,
101101
{
102-
let config = TxChannelConfig {
103-
clk_divider: 1,
104-
idle_output_level: false,
105-
carrier_modulation: false,
106-
idle_output: true,
107-
108-
..TxChannelConfig::default()
109-
};
102+
let config = TxChannelConfig::default()
103+
.with_clk_divider(1)
104+
.with_idle_output_level(Level::Low)
105+
.with_carrier_modulation(false)
106+
.with_idle_output(true);
110107

111108
let channel = channel.configure(pin, config).unwrap();
112109

113110
// Assume the RMT peripheral is set up to use the APB clock
114111
let clocks = Clocks::get();
115-
let src_clock = clocks.apb_clock.to_MHz();
112+
let src_clock = clocks.apb_clock.as_mhz();
116113

117114
Self {
118115
channel: Some(channel),
119116
rmt_buffer,
120117
pulses: (
121-
PulseCode::new (
122-
true,
118+
PulseCode::new(
119+
Level::High,
123120
((SK68XX_T0H_NS * src_clock) / 1000) as u16,
124-
false,
121+
Level::Low,
125122
((SK68XX_T0L_NS * src_clock) / 1000) as u16,
126123
),
127-
PulseCode::new (
128-
true,
124+
PulseCode::new(
125+
Level::High,
129126
((SK68XX_T1H_NS * src_clock) / 1000) as u16,
130-
false,
127+
Level::Low,
131128
((SK68XX_T1L_NS * src_clock) / 1000) as u16,
132129
),
133130
),

0 commit comments

Comments
 (0)