Skip to content

Commit

Permalink
feat: refactor code;
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldan committed Sep 11, 2024
1 parent dc8364d commit 0c6c8d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ fn main() -> ! {

## Implementation Specification

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.


![steps](/docs/steps.png)

### Step 1
Expand Down
17 changes: 4 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,10 @@ impl<P: InputPin + OutputPin, D: DelayNs> Dht11<P, D> {
///
/// * `state` - The target `PinState` to wait for (either `Low` or `High`).
fn wait_until_state(&mut self, state: PinState) -> Result<(), <P as ErrorType>::Error> {
loop {
match state {
PinState::Low => {
if self.pin.is_low()? {
break;
}
}
PinState::High => {
if self.pin.is_high()? {
break;
}
}
};
while !match state {
PinState::Low => self.pin.is_low(),
PinState::High => self.pin.is_high(),
}? {
self.delay.delay_us(1);
}
Ok(())
Expand Down

0 comments on commit 0c6c8d8

Please sign in to comment.