Skip to content

Add method to disable gas heater #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions adafruit_bme680.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,30 +482,29 @@ def _read(self, register: int, length: int) -> bytearray:
def _write(self, register: int, values: bytearray) -> None:
raise NotImplementedError()

# garberw added begin ===========================
def set_gas_heater(self, heater_temp: UINT16, heater_time: UINT16) -> bool:
"""
* @brief Enable and configure gas reading + heater
* @brief Enable and configure gas reading + heater (None disables)
* @param heater_temp
* Desired temperature in degrees Centigrade
* @param heater_time
* Time to keep heater on in milliseconds
* @return True on success, False on failure
"""
if (heater_temp == 0) or (heater_time == 0):
return False
# enable = BME68X_ENABLE
try:
self._set_heatr_conf(heater_temp, heater_time)
if (heater_temp is None) or (heater_time is None):
self._set_heatr_conf(heater_temp or 0, heater_time or 0, enable=False)
else:
self._set_heatr_conf(heater_temp, heater_time)
except GasHeaterException:
return False
return True

def _set_heatr_conf(self, heater_temp: UINT16, heater_time: UINT16) -> None:
def _set_heatr_conf(
self, heater_temp: UINT16, heater_time: UINT16, enable: bool = True
) -> None:
# restrict to BME68X_FORCED_MODE
op_mode: UINT8 = _BME68X_FORCED_MODE
# restrict to enable = True
enable: bool = True
nb_conv: UINT8 = 0
hctrl: UINT8 = _BME68X_ENABLE_HEATER
run_gas: UINT8 = 0
Expand Down