kopia lustrzana https://github.com/peterhinch/mpy_bme280_esp8266
get rid of function only called once
rodzic
9d96b0dc51
commit
179aa6cb07
11
bme280.py
11
bme280.py
|
@ -52,13 +52,8 @@ class BME280:
|
||||||
if i2c is None:
|
if i2c is None:
|
||||||
raise ValueError('An I2C object is required.')
|
raise ValueError('An I2C object is required.')
|
||||||
self._device = Device(address, i2c)
|
self._device = Device(address, i2c)
|
||||||
|
|
||||||
# Load calibration values.
|
# Load calibration values.
|
||||||
self._load_calibration()
|
|
||||||
self._device.write8(BME280_REGISTER_CONTROL, 0x3F)
|
|
||||||
self.t_fine = 0
|
|
||||||
|
|
||||||
def _load_calibration(self):
|
|
||||||
|
|
||||||
self.dig_T1 = self._device.readU16LE(BME280_REGISTER_DIG_T1)
|
self.dig_T1 = self._device.readU16LE(BME280_REGISTER_DIG_T1)
|
||||||
self.dig_T2 = self._device.readS16LE(BME280_REGISTER_DIG_T2)
|
self.dig_T2 = self._device.readS16LE(BME280_REGISTER_DIG_T2)
|
||||||
self.dig_T3 = self._device.readS16LE(BME280_REGISTER_DIG_T3)
|
self.dig_T3 = self._device.readS16LE(BME280_REGISTER_DIG_T3)
|
||||||
|
@ -87,6 +82,10 @@ class BME280:
|
||||||
self.dig_H5 = h5 | (
|
self.dig_H5 = h5 | (
|
||||||
self._device.readU8(BME280_REGISTER_DIG_H5) >> 4 & 0x0F)
|
self._device.readU8(BME280_REGISTER_DIG_H5) >> 4 & 0x0F)
|
||||||
|
|
||||||
|
|
||||||
|
self._device.write8(BME280_REGISTER_CONTROL, 0x3F)
|
||||||
|
self.t_fine = 0
|
||||||
|
|
||||||
def read_raw_temp(self):
|
def read_raw_temp(self):
|
||||||
"""Reads the raw (uncompensated) temperature from the sensor."""
|
"""Reads the raw (uncompensated) temperature from the sensor."""
|
||||||
meas = self._mode
|
meas = self._mode
|
||||||
|
|
Ładowanie…
Reference in New Issue