Skip to content

Commit

Permalink
Add read_scratchpad method to Ds18b20 struct
Browse files Browse the repository at this point in the history
This is a bit more convenient to use than
`read_scratchpad(&ds18b20.address(), ...)`.
  • Loading branch information
dbrgn committed Oct 27, 2020
1 parent bd0f996 commit 87f04cd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ impl Ds18b20 {
Ok(())
}

/// Read and return the raw scratchpad data (after checking the CRC).
pub fn read_scratchpad<T, E>(
&self,
onewire: &mut OneWire<T>,
delay: &mut impl DelayUs<u16>,
) -> OneWireResult<[u8; 9], E>
where
T: InputPin<Error = E>,
T: OutputPin<Error = E>,
{
let scratchpad = read_scratchpad(&self.address, onewire, delay)?;
Ok(scratchpad)
}

pub fn read_data<T, E>(
&self,
onewire: &mut OneWire<T>,
Expand Down Expand Up @@ -157,6 +171,7 @@ where
save_to_eeprom(None, onewire, delay)
}

/// Read and return the raw scratchpad data (after checking the CRC).
pub fn read_scratchpad<T, E>(
address: &Address,
onewire: &mut OneWire<T>,
Expand Down

0 comments on commit 87f04cd

Please sign in to comment.