Skip to content

Commit 5747dde

Browse files
authored
Extract the esp-hal-smartled package (#429)
* Extract the `esp-hal-smartled` package This (finally) eliminates the `esp_hal_common::utils` module! * Remove all references to the old `smartled` feature from CI
1 parent c1fa400 commit 5747dde

File tree

18 files changed

+98
-85
lines changed

18 files changed

+98
-85
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# Subsequent steps can just check the examples instead, as we're already
4242
# confident that they link.
4343
- name: check esp32-hal (common features)
44-
run: cd esp32-hal/ && cargo check --examples --features=eh1,smartled,ufmt
44+
run: cd esp32-hal/ && cargo check --examples --features=eh1,ufmt
4545
- name: check esp32-hal (async)
4646
run: cd esp32-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-timg0
4747
- name: check esp32-hal (async, gpio)
@@ -107,7 +107,7 @@ jobs:
107107
# Subsequent steps can just check the examples instead, as we're already
108108
# confident that they link.
109109
- name: check esp32c3-hal (common features)
110-
run: cd esp32c3-hal/ && cargo check --examples --features=eh1,smartled,ufmt
110+
run: cd esp32c3-hal/ && cargo check --examples --features=eh1,ufmt
111111
- name: check esp32c3-hal (async, systick)
112112
run: cd esp32c3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
113113
- name: check esp32c3-hal (async, timg0)
@@ -140,7 +140,7 @@ jobs:
140140
# Subsequent steps can just check the examples instead, as we're already
141141
# confident that they link.
142142
- name: check esp32c6-hal (common features)
143-
run: cd esp32c6-hal/ && cargo check --examples --features=eh1,smartled,ufmt
143+
run: cd esp32c6-hal/ && cargo check --examples --features=eh1,ufmt
144144
- name: check esp32c6-hal (async, systick)
145145
run: cd esp32c6-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
146146
- name: check esp32c6-hal (async, timg0)
@@ -169,7 +169,7 @@ jobs:
169169
# Subsequent steps can just check the examples instead, as we're already
170170
# confident that they link.
171171
- name: check esp32s2-hal (common features)
172-
run: cd esp32s2-hal/ && cargo check --examples --features=eh1,smartled,ufmt
172+
run: cd esp32s2-hal/ && cargo check --examples --features=eh1,ufmt
173173
# FIXME: `time-systick` feature disabled for now, see 'esp32s2-hal/Cargo.toml'.
174174
# - name: check esp32s2-hal (async, systick)
175175
# run: cd esp32s2-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
@@ -203,7 +203,7 @@ jobs:
203203
# Subsequent steps can just check the examples instead, as we're already
204204
# confident that they link.
205205
- name: check esp32s3-hal (common features)
206-
run: cd esp32s3-hal/ && cargo check --examples --features=eh1,smartled,ufmt
206+
run: cd esp32s3-hal/ && cargo check --examples --features=eh1,ufmt
207207
- name: check esp32s3-hal (async, systick)
208208
run: cd esp32s3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
209209
- name: check esp32s3-hal (async, timg0)
@@ -230,9 +230,9 @@ jobs:
230230
- name: msrv (esp32c2-hal)
231231
run: cd esp32c2-hal/ && cargo check --features=eh1,ufmt
232232
- name: msrv (esp32c3-hal)
233-
run: cd esp32c3-hal/ && cargo check --features=eh1,ufmt,smartled
233+
run: cd esp32c3-hal/ && cargo check --features=eh1,ufmt
234234
- name: msrv (esp32c6-hal)
235-
run: cd esp32c6-hal/ && cargo check --features=eh1,ufmt,smartled
235+
run: cd esp32c6-hal/ && cargo check --features=eh1,ufmt
236236

237237
msrv-xtensa:
238238
runs-on: ubuntu-latest
@@ -247,11 +247,11 @@ jobs:
247247

248248
# Verify the MSRV for all Xtensa chips.
249249
- name: msrv (esp32-hal)
250-
run: cd esp32-hal/ && cargo check --features=eh1,ufmt,smartled
250+
run: cd esp32-hal/ && cargo check --features=eh1,ufmt
251251
- name: msrv (esp32s2-hal)
252-
run: cd esp32s2-hal/ && cargo check --features=eh1,ufmt,smartled
252+
run: cd esp32s2-hal/ && cargo check --features=eh1,ufmt
253253
- name: msrv (esp32s3-hal)
254-
run: cd esp32s3-hal/ && cargo check --features=eh1,ufmt,smartled
254+
run: cd esp32s3-hal/ && cargo check --features=eh1,ufmt
255255

256256
# --------------------------------------------------------------------------
257257
# Lint
@@ -327,4 +327,4 @@ jobs:
327327
- name: rustfmt (esp32s2-hal)
328328
run: cargo fmt --all --manifest-path=esp32s2-hal/Cargo.toml -- --check
329329
- name: rustfmt (esp32s3-hal)
330-
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check
330+
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check

esp-hal-common/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ riscv-atomic-emulation-trap = { version = "0.4.0", optional = true }
4343
xtensa-lx = { version = "0.8.0", optional = true }
4444
xtensa-lx-rt = { version = "0.15.0", optional = true }
4545

46-
# Smart-LED (e.g., WS2812/SK68XX) support
47-
smart-leds-trait = { version = "0.2.1", optional = true }
48-
4946
# Part of `ufmt` containing only `uWrite` trait
5047
ufmt-write = { version = "0.1.0", optional = true }
5148

@@ -76,9 +73,6 @@ esp32c2_26mhz = []
7673
# Implement the `embedded-hal==1.0.0-alpha.x` traits
7774
eh1 = ["embedded-hal-1", "embedded-hal-nb", "embedded-can"]
7875

79-
# To use the external `smart_led` crate
80-
smartled = ["smart-leds-trait"]
81-
8276
# To support `ufmt`
8377
ufmt = ["ufmt-write"]
8478

esp-hal-common/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ pub mod twai;
102102
pub mod uart;
103103
#[cfg(usb_serial_jtag)]
104104
pub mod usb_serial_jtag;
105-
#[cfg(rmt)]
106-
pub mod utils;
107105

108106
/// State of the CPU saved when entering exception or interrupt
109107
pub mod trapframe {

esp-hal-common/src/utils/mod.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

esp-hal-smartled/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "esp-hal-smartled"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "RMT adapter for smartleds"
6+
repository = "https://github.com/esp-rs/esp-hal"
7+
license = "MIT OR Apache-2.0"
8+
9+
[dependencies]
10+
esp-hal-common = { version = "0.7.1", features = [], path = "../esp-hal-common" }
11+
fugit = "0.3.6"
12+
smart-leds-trait = "0.2.1"
13+
14+
[features]
15+
esp32 = ["esp-hal-common/esp32"]
16+
esp32c3 = ["esp-hal-common/esp32c3"]
17+
esp32c6 = ["esp-hal-common/esp32c6"]
18+
esp32s2 = ["esp-hal-common/esp32s2"]
19+
esp32s3 = ["esp-hal-common/esp32s3"]
20+
21+
esp32_26mhz = ["esp-hal-common/esp32_26mhz"]
22+
esp32_40mhz = ["esp-hal-common/esp32_40mhz"]

esp-hal-smartled/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# esp-hal-smartled
2+
3+
[![Crates.io](https://img.shields.io/crates/v/esp-hal-smartled?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-hal-smartled)
4+
[![docs.rs](https://img.shields.io/docsrs/esp-hal-smartled?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.rs/esp-hal-smartled)
5+
![Crates.io](https://img.shields.io/crates/l/esp-hal-smartled?labelColor=1C2C2E&style=flat-square)
6+
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)
7+
8+
This adapter allows for the use of an RMT output channel to easily interact with RGB LEDs and use the convenience functions of the [`smart-leds`](https://crates.io/crates/smart-leds) crate.
9+
10+
## [Documentation]
11+
12+
[documentation]: https://docs.rs/esp-hal-smartled/
13+
14+
## License
15+
16+
Licensed under either of:
17+
18+
- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
19+
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)
20+
21+
at your option.
22+
23+
### Contribution
24+
25+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
26+
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
27+
any additional terms or conditions.

esp-hal-common/src/utils/smart_leds_adapter.rs renamed to esp-hal-smartled/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
11
//! # Smart-LEDs RMT Adapter
22
//!
33
//! This adapter allows for the use of an RMT output channel to easily interact
4-
//! with RGB LEDs and use the convenience functions of the external
4+
//! with RGB LEDs and use the convenience functions of the
55
//! [`smart-leds`](https://crates.io/crates/smart-leds) crate.
66
//!
77
//! _This is a simple implementation where every LED is adressed in an
88
//! individual RMT operation. This is working perfectly fine in blocking mode,
99
//! but in case this is used in combination with interrupts that might disturb
1010
//! the sequential sending, an alternative implementation (addressing the LEDs
1111
//! in a sequence in a single RMT send operation) might be required!_
12+
13+
#![no_std]
1214
#![deny(missing_docs)]
1315

1416
use core::slice::IterMut;
1517

16-
use fugit::NanosDuration;
17-
use smart_leds_trait::{SmartLedsWrite, RGB8};
18-
19-
#[cfg(any(esp32, esp32s2))]
20-
use crate::pulse_control::ClockSource;
21-
use crate::{
18+
#[cfg(any(feature = "esp32", feature = "esp32s2"))]
19+
use esp_hal_common::pulse_control::ClockSource;
20+
use esp_hal_common::{
2221
gpio::OutputPin,
2322
peripheral::Peripheral,
2423
pulse_control::{ConfiguredChannel, OutputChannel, PulseCode, RepeatMode, TransmissionError},
2524
};
25+
use fugit::NanosDuration;
26+
use smart_leds_trait::{SmartLedsWrite, RGB8};
2627

2728
// Specifies what clock frequency we're using for the RMT peripheral (if
2829
// properly configured)
2930
//
3031
// TODO: Factor in clock configuration, this needs to be revisited once #24 and
3132
// #44 have been addressed.
32-
#[cfg(esp32c3)]
33+
#[cfg(feature = "esp32")]
3334
const SOURCE_CLK_FREQ: u32 = 40_000_000;
34-
#[cfg(esp32c6)]
35+
#[cfg(feature = "esp32c3")]
3536
const SOURCE_CLK_FREQ: u32 = 40_000_000;
36-
#[cfg(esp32s2)]
37+
#[cfg(feature = "esp32c6")]
3738
const SOURCE_CLK_FREQ: u32 = 40_000_000;
38-
#[cfg(esp32)]
39+
#[cfg(feature = "esp32s2")]
3940
const SOURCE_CLK_FREQ: u32 = 40_000_000;
40-
#[cfg(esp32s3)]
41+
#[cfg(feature = "esp32s3")]
4142
const SOURCE_CLK_FREQ: u32 = 40_000_000;
4243

4344
const SK68XX_CODE_PERIOD: u32 = 1200;
@@ -101,14 +102,14 @@ where
101102
where
102103
UnconfiguredChannel: OutputChannel<ConfiguredChannel<'d, O> = CHANNEL>,
103104
{
104-
#[cfg(any(esp32c3, esp32c6, esp32s3))]
105+
#[cfg(not(any(feature = "esp32", feature = "esp32s2")))]
105106
channel
106107
.set_idle_output_level(false)
107108
.set_carrier_modulation(false)
108109
.set_channel_divider(1)
109110
.set_idle_output(true);
110111

111-
#[cfg(any(esp32, esp32s2))]
112+
#[cfg(any(feature = "esp32", feature = "esp32s2"))]
112113
channel
113114
.set_idle_output_level(false)
114115
.set_carrier_modulation(false)

esp-hal.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
{
77
"path": "esp-hal-procmacros"
88
},
9+
{
10+
"path": "esp-hal-smartled"
11+
},
912
{
1013
"path": "esp32-hal"
1114
},

esp32-hal/Cargo.toml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ critical-section = "1.1.1"
3737
embassy-executor = { package = "embassy-executor", git = "https://github.com/embassy-rs/embassy/", rev = "cd9a65b", features = ["nightly", "integrated-timers"] }
3838
embedded-graphics = "0.7.1"
3939
esp-backtrace = { version = "0.6.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
40+
esp-hal-smartled = { version = "0.1.0", features = ["esp32"], path = "../esp-hal-smartled" }
4041
esp-println = { version = "0.3.1", features = ["esp32"] }
4142
sha2 = { version = "0.10.6", default-features = false}
4243
smart-leds = "0.3.0"
@@ -45,22 +46,17 @@ static_cell = "1.0.0"
4546
aes = "0.8.2"
4647

4748
[features]
48-
default = ["rt", "vectored", "xtal40mhz"]
49-
bluetooth = []
50-
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
51-
rt = []
52-
smartled = ["esp-hal-common/smartled"]
53-
ufmt = ["esp-hal-common/ufmt"]
54-
vectored = ["esp-hal-common/vectored"]
55-
async = ["esp-hal-common/async", "embedded-hal-async"]
56-
embassy = ["esp-hal-common/embassy"]
49+
default = ["rt", "vectored", "xtal40mhz"]
50+
bluetooth = []
51+
eh1 = ["esp-hal-common/eh1", "dep:embedded-hal-1", "dep:embedded-hal-nb"]
52+
rt = []
53+
ufmt = ["esp-hal-common/ufmt"]
54+
vectored = ["esp-hal-common/vectored"]
55+
async = ["esp-hal-common/async", "embedded-hal-async"]
56+
embassy = ["esp-hal-common/embassy"]
5757
embassy-time-timg0 = ["esp-hal-common/embassy-time-timg0", "embassy-time/tick-hz-1_000_000"]
58-
xtal40mhz = ["esp-hal-common/esp32_40mhz"]
59-
xtal26mhz = ["esp-hal-common/esp32_26mhz"]
60-
61-
[[example]]
62-
name = "hello_rgb"
63-
required-features = ["smartled"]
58+
xtal40mhz = ["esp-hal-common/esp32_40mhz"]
59+
xtal26mhz = ["esp-hal-common/esp32_26mhz"]
6460

6561
[[example]]
6662
name = "spi_eh1_loopback"

esp32-hal/examples/hello_rgb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use esp32_hal::{
1818
peripherals,
1919
prelude::*,
2020
timer::TimerGroup,
21-
utils::{smartLedAdapter, SmartLedsAdapter},
2221
Delay,
2322
PulseControl,
2423
Rtc,
2524
IO,
2625
};
2726
#[allow(unused_imports)]
2827
use esp_backtrace as _;
28+
use esp_hal_smartled::{smartLedAdapter, SmartLedsAdapter};
2929
use smart_leds::{
3030
brightness,
3131
gamma,

0 commit comments

Comments
 (0)