Add function to read the aging offset

pull/4/head
Diego Barrios Romero 2018-10-31 06:51:04 +01:00
parent ca36814a09
commit 70657dd917
2 changed files with 9 additions and 0 deletions

View File

@ -59,6 +59,11 @@ where
self.iface.write_register(Register::AGING_OFFSET, offset as u8) self.iface.write_register(Register::AGING_OFFSET, offset as u8)
} }
/// Read the aging offset.
pub fn get_aging_offset(&mut self) -> Result<i8, Error<E>> {
let offset = self.iface.read_register(Register::AGING_OFFSET)?;
Ok(offset as i8)
}
fn write_control(&mut self, control: u8) -> Result<(), Error<E>> { fn write_control(&mut self, control: u8) -> Result<(), Error<E>> {
self.iface.write_register(Register::CONTROL, control)?; self.iface.write_register(Register::CONTROL, control)?;
self.control = control; self.control = control;

View File

@ -55,3 +55,7 @@ change_if_necessary_test!(conv_temp, convert_temperature, CONTROL, CONTROL_POR_V
set_param_test!(set_aging_offset_min, set_aging_offset, AGING_OFFSET, -128, 0b1000_0000); set_param_test!(set_aging_offset_min, set_aging_offset, AGING_OFFSET, -128, 0b1000_0000);
set_param_test!(set_aging_offset_max, set_aging_offset, AGING_OFFSET, 127, 127); set_param_test!(set_aging_offset_max, set_aging_offset, AGING_OFFSET, 127, 127);
get_param_test!(get_aging_offset_min, get_aging_offset, AGING_OFFSET, -128, 0b1000_0000);
get_param_test!(get_aging_offset_max, get_aging_offset, AGING_OFFSET, 127, 127);