Skip to content

Commit 7977cc3

Browse files
committed
Add method to disable gas heater
Setting either of temperature or heat time to zero will disable Fixes #63
1 parent d7909fe commit 7977cc3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

adafruit_bme680.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,30 +482,27 @@ def _read(self, register: int, length: int) -> bytearray:
482482
def _write(self, register: int, values: bytearray) -> None:
483483
raise NotImplementedError()
484484

485-
# garberw added begin ===========================
486485
def set_gas_heater(self, heater_temp: UINT16, heater_time: UINT16) -> bool:
487486
"""
488-
* @brief Enable and configure gas reading + heater
487+
* @brief Enable and configure gas reading + heater (0 disables)
489488
* @param heater_temp
490489
* Desired temperature in degrees Centigrade
491490
* @param heater_time
492491
* Time to keep heater on in milliseconds
493492
* @return True on success, False on failure
494493
"""
495-
if (heater_temp == 0) or (heater_time == 0):
496-
return False
497-
# enable = BME68X_ENABLE
498494
try:
499-
self._set_heatr_conf(heater_temp, heater_time)
495+
if (heater_temp == 0) or (heater_time == 0):
496+
self._set_heatr_conf(heater_temp, heater_time, enable=False)
497+
else:
498+
self._set_heatr_conf(heater_temp, heater_time)
500499
except GasHeaterException:
501500
return False
502501
return True
503502

504-
def _set_heatr_conf(self, heater_temp: UINT16, heater_time: UINT16) -> None:
503+
def _set_heatr_conf(self, heater_temp: UINT16, heater_time: UINT16, enable: bool=True) -> None:
505504
# restrict to BME68X_FORCED_MODE
506505
op_mode: UINT8 = _BME68X_FORCED_MODE
507-
# restrict to enable = True
508-
enable: bool = True
509506
nb_conv: UINT8 = 0
510507
hctrl: UINT8 = _BME68X_ENABLE_HEATER
511508
run_gas: UINT8 = 0

0 commit comments

Comments
 (0)