BME680 Refactor
1 unresolved thread
1 unresolved thread
Compare changes
Files
7+ 26
− 8
@@ -2,6 +2,7 @@
@@ -9,17 +10,28 @@
@@ -29,6 +41,8 @@
@@ -38,9 +52,13 @@
Add a sensor-class interface for the BME680 which is more pythonic than access through raw functions. This class also functions as a context-manager to automatically turn off the sensor once it is no longer needed.
The new interface allows a number of different ways to access the sensor:
import bme680
with bme680.Bme680() as environment:
# Do a measurement, just for temperature
t = environment.temperature
# Do a measurement, just for humidity
h = environment.humidity
# Get all measurements in a single call; this is faster
d = environment.get_data()
t = d.temperature
h = d.humidity
# Without context-manager
env = bme680.Bme680()
t = env.temperature
# Turn off manually:
env.close()
Closes #107 (closed)
cc @chris007
Documentation still needs adjusting:
No, because this is the result of
environment.get_data()
, which is a namedtuple.Oh, right, sorry, didn't look far enough.
d.resistance
should still bed.gas_resistance
though, right?