diff --git a/bme280.py b/bme280.py index c63d80c..b9f4548 100644 --- a/bme280.py +++ b/bme280.py @@ -85,7 +85,8 @@ class BME280: self._device.readU8(BME280_REGISTER_DIG_H5) >> 4 & 0x0F) - self._device.write8(BME280_REGISTER_CONTROL, 0x3F) + self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL, + bytearray([0x3F])) self.t_fine = 0 def read_raw_data(self): @@ -99,7 +100,6 @@ class BME280: self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL_HUM, bytearray([meas])) meas = self._mode << 5 | self._mode << 2 | 1 - self._device.write8(BME280_REGISTER_CONTROL, meas) self.i2c.writeto_mem(self.address, BME280_REGISTER_CONTROL, bytearray([meas])) diff --git a/i2c_device.py b/i2c_device.py index 30fa73e..fccdbea 100644 --- a/i2c_device.py +++ b/i2c_device.py @@ -45,18 +45,6 @@ class Device: self._address = address self._i2c = i2c - def writeRaw8(self, value): - """Write an 8-bit value on the bus (without register).""" - buf = bytearray(1) - buf[0] = value & 0xFF - self._i2c.writeto(self._address, buf) - - def write8(self, register, value): - """Write an 8-bit value to the specified register.""" - buf = bytearray(1) - buf[0] = value & 0xFF - self._i2c.writeto_mem(self._address, register, buf) - def readRaw8(self): """Read an 8-bit value on the bus (without register).""" return int.from_bytes(self._i2c.readfrom(self._address, 1)) & 0xFF