diff --git a/src/lib.rs b/src/lib.rs index 9417ab1..8424253 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,7 +209,7 @@ where impl Ft6X06 where - I2C: i2c::WriteRead + i2c::Write, + I2C: i2c::WriteRead + i2c::Write, E: core::fmt::Debug { /// Creates a new sensor associated with an I2C peripheral. /// @@ -274,6 +274,20 @@ where Ok(value == 0) } + /// Get the value of an 8 bit register + pub fn get_u8_reg(&self, i2c: &mut I2C, reg: u8) -> Result { + let mut ibuf: [u8; 1] = [0]; + i2c.write_read(self.addr, &[reg], &mut ibuf)?; + Ok(ibuf[0]) + } + + /// Set the value of an 8 bit register + pub fn set_u8_reg(&self, i2c: &mut I2C, reg: u8, val: u8) -> Result<(), E> { + let obuf: [u8; 2] = [reg, val]; + i2c.write(self.addr, &obuf)?; + Ok(()) + } + /// Run an internal calibration on the FT6X06 pub fn ts_calibration( &mut self,