From 87f04cdb786f57df52550ded8c642204e1ee000e Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 27 Oct 2020 22:50:02 +0100 Subject: [PATCH] Add read_scratchpad method to Ds18b20 struct This is a bit more convenient to use than `read_scratchpad(&ds18b20.address(), ...)`. --- src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 54e738c..c87e035 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,6 +61,20 @@ impl Ds18b20 { Ok(()) } + /// Read and return the raw scratchpad data (after checking the CRC). + pub fn read_scratchpad( + &self, + onewire: &mut OneWire, + delay: &mut impl DelayUs, + ) -> OneWireResult<[u8; 9], E> + where + T: InputPin, + T: OutputPin, + { + let scratchpad = read_scratchpad(&self.address, onewire, delay)?; + Ok(scratchpad) + } + pub fn read_data( &self, onewire: &mut OneWire, @@ -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( address: &Address, onewire: &mut OneWire,