From 45eeba9bb4883312197f04aa06c44e6d28e1f628 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 20 Mar 2020 15:38:31 +0000 Subject: [PATCH] Minor linting fixes to examples --- examples/compensated-temperature.py | 6 ++---- examples/temperature-offset.py | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/compensated-temperature.py b/examples/compensated-temperature.py index d3901ca..071bbfb 100755 --- a/examples/compensated-temperature.py +++ b/examples/compensated-temperature.py @@ -4,10 +4,6 @@ import time import bme680 from subprocess import PIPE, Popen -try: - from smbus2 import SMBus -except ImportError: - from smbus import SMBus print("""compensated-temperature.py - Use the CPU temperature to compensate temperature readings from the BME680 sensor. Method adapted from Initial State's Enviro pHAT @@ -31,12 +27,14 @@ sensor.set_pressure_oversample(bme680.OS_4X) sensor.set_temperature_oversample(bme680.OS_8X) sensor.set_filter(bme680.FILTER_SIZE_3) + # Gets the CPU temperature in degrees C def get_cpu_temperature(): process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE) output, _error = process.communicate() return float(output[output.index('=') + 1:output.rindex("'")]) + factor = 1.0 # Smaller numbers adjust temp down, vice versa smooth_size = 10 # Dampens jitter due to rapid CPU temp changes diff --git a/examples/temperature-offset.py b/examples/temperature-offset.py index 7f298cd..c39700e 100755 --- a/examples/temperature-offset.py +++ b/examples/temperature-offset.py @@ -22,6 +22,7 @@ sensor.set_pressure_oversample(bme680.OS_4X) sensor.set_temperature_oversample(bme680.OS_8X) sensor.set_filter(bme680.FILTER_SIZE_3) + def display_data(offset=0): sensor.set_temp_offset(offset) sensor.get_sensor_data() @@ -32,6 +33,7 @@ def display_data(offset=0): print(output) print('') + print('Initial readings') display_data()