mirror of
https://github.com/cmur2/python-bme680.git
synced 2024-12-22 22:54:29 +01:00
Refactored get_sensor_data
This commit is contained in:
parent
b2f388a335
commit
73e93bc6d7
@ -228,6 +228,12 @@ class BME680(BME680Data):
|
||||
self.set_power_mode(FORCED_MODE)
|
||||
|
||||
for attempt in range(10):
|
||||
status = self._get_regs(FIELD0_ADDR, 1)
|
||||
|
||||
if (status & NEW_DATA_MSK) == 0:
|
||||
time.sleep(POLL_PERIOD_MS / 1000.0)
|
||||
continue
|
||||
|
||||
regs = self._get_regs(FIELD0_ADDR, FIELD_LENGTH)
|
||||
|
||||
self.data.status = regs[0] & NEW_DATA_MSK
|
||||
@ -246,7 +252,6 @@ class BME680(BME680Data):
|
||||
|
||||
self.data.heat_stable = (self.data.status & HEAT_STAB_MSK) > 0
|
||||
|
||||
if self.data.status & NEW_DATA_MSK:
|
||||
temperature = self._calc_temperature(adc_temp)
|
||||
self.data.temperature = temperature / 100.0
|
||||
self.ambient_temperature = temperature # Saved for heater calc
|
||||
@ -255,8 +260,6 @@ class BME680(BME680Data):
|
||||
self.data.humidity = self._calc_humidity(adc_hum) / 1000.0
|
||||
self.data.gas_resistance = self._calc_gas_resistance(adc_gas_res, gas_range)
|
||||
return True
|
||||
else:
|
||||
time.sleep(POLL_PERIOD_MS / 1000.0)
|
||||
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user