Skip to content

Commit ef1634b

Browse files
committed
feat: preparing the structure
1 parent e74cec0 commit ef1634b

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
name = "embedded-dht-rs"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "Apache-2.0"
56

67
[dependencies]
8+
embedded-hal = "1.0.0"

src/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
pub fn add(left: u64, right: u64) -> u64 {
2-
left + right
1+
#![no_std]
2+
3+
use embedded_hal::digital::{ErrorType, InputPin, OutputPin};
4+
5+
pub struct Dht11<P: InputPin + OutputPin> {
6+
pin: P
37
}
48

5-
#[cfg(test)]
6-
mod tests {
7-
use super::*;
9+
impl<P: InputPin + OutputPin> Dht11<P> {
810

9-
#[test]
10-
fn it_works() {
11-
let result = add(2, 2);
12-
assert_eq!(result, 4);
11+
pub fn new(pin: P) -> Self {
12+
Self { pin }
1313
}
14-
}
14+
15+
pub fn read(&mut self) -> Result<bool, <P as ErrorType>::Error> {
16+
return self.pin.is_high();
17+
}
18+
}

0 commit comments

Comments
 (0)