Skip to content

Commit 0c6c8d8

Browse files
committed
feat: refactor code;
1 parent dc8364d commit 0c6c8d8

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ fn main() -> ! {
6161

6262
## Implementation Specification
6363

64+
We have gathered all the information you need to understand in order to implement a library like this. Additionally, we’ve included a few comments in the code for those curious about the details, based on the following specification.
65+
66+
6467
![steps](/docs/steps.png)
6568

6669
### Step 1

src/lib.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,10 @@ impl<P: InputPin + OutputPin, D: DelayNs> Dht11<P, D> {
8080
///
8181
/// * `state` - The target `PinState` to wait for (either `Low` or `High`).
8282
fn wait_until_state(&mut self, state: PinState) -> Result<(), <P as ErrorType>::Error> {
83-
loop {
84-
match state {
85-
PinState::Low => {
86-
if self.pin.is_low()? {
87-
break;
88-
}
89-
}
90-
PinState::High => {
91-
if self.pin.is_high()? {
92-
break;
93-
}
94-
}
95-
};
83+
while !match state {
84+
PinState::Low => self.pin.is_low(),
85+
PinState::High => self.pin.is_high(),
86+
}? {
9687
self.delay.delay_us(1);
9788
}
9889
Ok(())

0 commit comments

Comments
 (0)