Skip to content

Commit 6ab2f48

Browse files
committed
feat: add features
1 parent 3008668 commit 6ab2f48

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ embedded-hal = "1.0.0"
1616
[dev-dependencies]
1717
embedded-hal-mock = "0.11.1"
1818

19+
[features]
20+
dht11 = []
21+
dht20 = []
22+
dht22 = []
23+
default = []
24+
1925
[lib]
2026
doctest = false
2127

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,24 @@ Here are some general tutorials that provide brief introductions to embedded pro
2424
- **Part 3 (DHT11 Library)** - [Building a Rust library for DHT11 sensor](https://rust-dd.com/post/building-a-rust-library-for-dht11-sensor-a-step-by-step-guide)
2525

2626

27-
### Example - ESP32
27+
### Install
28+
29+
30+
To include the `dht11` feature:
2831

2932
```rust
3033
cargo add embedded-dht-rs
3134
```
3235

36+
To include all features (`dht11`, `dht20`, and `dht22`):
37+
38+
```rust
39+
cargo add embedded-dht-rs --features "dht11,dht20,dht22"
40+
```
41+
42+
### Example - ESP32
43+
44+
3345
```rust
3446
#![no_std]
3547
#![no_main]

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#![no_std]
22

33
mod dht;
4+
5+
#[cfg(feature = "dht11")]
46
pub mod dht11;
7+
8+
#[cfg(feature = "dht20")]
59
pub mod dht20;
10+
11+
#[cfg(feature = "dht22")]
612
pub mod dht22;
713

814
/// Represents a reading from the sensor.

0 commit comments

Comments
 (0)