Skip to content

Commit

Permalink
Merge pull request #55 from jerryneedell/jerryn_temperature
Browse files Browse the repository at this point in the history
fix temperature calculation
  • Loading branch information
FoamyGuy committed Mar 20, 2022
2 parents d8f3c0a + e31548e commit 98653ee
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions adafruit_lsm6ds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class AccelHPF(CV):
_LSM6DS_TAP_CFG = const(0x58)
_LSM6DS_MLC0_SRC = const(0x70)
_MILLI_G_TO_ACCEL = 0.00980665

_TEMPERATURE_SENSITIVITY = 256
_TEMPERATURE_OFFSET = 25.0

_LSM6DS_EMB_FUNC_EN_A = const(0x04)
_LSM6DS_EMB_FUNC_EN_B = const(0x05)
Expand Down Expand Up @@ -399,10 +400,7 @@ def temperature(self) -> float:

temp = self._raw_temp_data[0]

if temp > 0x550:
return (temp - 2 ** 13) * 0.0625

return temp * 0.0625
return temp / _TEMPERATURE_SENSITIVITY + _TEMPERATURE_OFFSET

def _set_embedded_functions(self, enable, emb_ab=None):
"""Enable/disable embedded functions - returns prior settings when disabled"""
Expand Down

0 comments on commit 98653ee

Please sign in to comment.