Skip to content

Commit

Permalink
Merge pull request #68 from CTho9305/main
Browse files Browse the repository at this point in the history
Fix #67
  • Loading branch information
FoamyGuy committed Dec 23, 2023
2 parents 467981e + 08cab89 commit 41fca05
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions adafruit_bme680.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def __init__(self, *, refresh_rate: int = 10) -> None:
self._humidity_oversample = 0b010
self._filter = 0b010

# Gas measurements, as a mask applied to _BME680_RUNGAS
self._run_gas = 0xFF

self._adc_pres = None
self._adc_temp = None
self._adc_hum = None
Expand Down Expand Up @@ -389,9 +392,9 @@ def _perform_reading(self) -> None:
self._write(_BME680_REG_CTRL_HUM, [self._humidity_oversample])
# gas measurements enabled
if self._chip_variant == 0x01:
self._write(_BME680_REG_CTRL_GAS, [_BME680_RUNGAS << 1])
self._write(_BME680_REG_CTRL_GAS, [(self._run_gas & _BME680_RUNGAS) << 1])
else:
self._write(_BME680_REG_CTRL_GAS, [_BME680_RUNGAS])
self._write(_BME680_REG_CTRL_GAS, [(self._run_gas & _BME680_RUNGAS)])
ctrl = self._read_byte(_BME680_REG_CTRL_MEAS)
ctrl = (ctrl & 0xFC) | 0x01 # enable single shot!
self._write(_BME680_REG_CTRL_MEAS, [ctrl])
Expand Down Expand Up @@ -492,6 +495,7 @@ def _set_heatr_conf(
else:
hctrl = _BME68X_DISABLE_HEATER
run_gas = _BME68X_DISABLE_GAS_MEAS
self._run_gas = ~(run_gas - 1)

ctrl_gas_data_0 = bme_set_bits(
ctrl_gas_data_0, _BME68X_HCTRL_MSK, _BME68X_HCTRL_POS, hctrl
Expand Down Expand Up @@ -598,7 +602,7 @@ def _calc_gas_wait(self, dur: int) -> int:
factor: int = 0
durval: int = 0xFF # Max duration

if dur < 0xFC0:
if dur >= 0xFC0:
return durval
while dur > 0x3F:
dur = dur / 4
Expand Down

0 comments on commit 41fca05

Please sign in to comment.