Skip to content

Commit

Permalink
feat: add features
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldan committed Oct 6, 2024
1 parent 3008668 commit 6ab2f48
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ embedded-hal = "1.0.0"
[dev-dependencies]
embedded-hal-mock = "0.11.1"

[features]
dht11 = []
dht20 = []
dht22 = []
default = []

[lib]
doctest = false

Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ Here are some general tutorials that provide brief introductions to embedded pro
- **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)


### Example - ESP32
### Install


To include the `dht11` feature:

```rust
cargo add embedded-dht-rs
```

To include all features (`dht11`, `dht20`, and `dht22`):

```rust
cargo add embedded-dht-rs --features "dht11,dht20,dht22"
```

### Example - ESP32


```rust
#![no_std]
#![no_main]
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#![no_std]

mod dht;

#[cfg(feature = "dht11")]
pub mod dht11;

#[cfg(feature = "dht20")]
pub mod dht20;

#[cfg(feature = "dht22")]
pub mod dht22;

/// Represents a reading from the sensor.
Expand Down

0 comments on commit 6ab2f48

Please sign in to comment.