Skip to content

Commit 61c5d57

Browse files
Simplify code a bit
1 parent 7e7d9a6 commit 61c5d57

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

src/hosted.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ where
4848
/// You may need to look at the datasheet and your own hal to verify this.
4949
///
5050
pub fn new(spi: SPI) -> Self {
51-
let data = if cfg!(feature = "mosi_idle_high") {
52-
vec![0; 140]
53-
} else {
54-
vec![]
55-
};
51+
let data = vec![0; 140];
5652

5753
Self {
5854
spi,
@@ -75,11 +71,7 @@ where
7571
// The spi frequencies are just the limits, the available timing data isn't
7672
// complete
7773
pub fn new_sk6812w(spi: SPI) -> Self {
78-
let data = if cfg!(feature = "mosi_idle_high") {
79-
vec![0; 140]
80-
} else {
81-
vec![]
82-
};
74+
let data = vec![0; 140];
8375

8476
Self {
8577
spi,
@@ -109,11 +101,7 @@ where
109101
fn send_data(&mut self) -> Result<(), E> {
110102
self.data.extend_from_slice(&[0; 140]);
111103
self.spi.write(&self.data)?;
112-
self.data.truncate(if cfg!(feature = "mosi_idle_high") {
113-
140
114-
} else {
115-
0
116-
});
104+
self.data.truncate(140);
117105
Ok(())
118106
}
119107
}

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
// Timings for ws2812 from https://cpldcpu.files.wordpress.com/2014/01/ws2812_timing_table.png
1111
// Timings for sk6812 from https://cpldcpu.wordpress.com/2016/03/09/the-sk6812-another-intelligent-rgb-led/
1212

13-
#![no_std]
14-
15-
#[cfg(feature = "std")]
16-
extern crate std;
13+
#![cfg_attr(not(feature = "std"), no_std)]
1714

1815
use embedded_hal as hal;
1916

0 commit comments

Comments
 (0)