Skip to content

Commit 3c0bf24

Browse files
authored
Merge pull request #36 from Ninic0c0/master
Add temperature support
2 parents 25ea19f + f6748a3 commit 3c0bf24

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

adafruit_lsm6ds/__init__.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
164164
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
165165
166166
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
167-
:param address: The I2C slave address of the sensor
168-
167+
:param address: The I2C address of the sensor
169168
"""
170169

171170
# ROUnaryStructs:
@@ -174,6 +173,8 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
174173
# Structs
175174
_raw_accel_data = Struct(_LSM6DS_OUTX_L_A, "<hhh")
176175
_raw_gyro_data = Struct(_LSM6DS_OUTX_L_G, "<hhh")
176+
_raw_temp_data = Struct(_LSM6DS_OUT_TEMP_L, "<bb")
177+
177178
# RWBits:
178179

179180
_accel_range = RWBits(2, _LSM6DS_CTRL1_XL, 2)
@@ -248,6 +249,16 @@ def _add_accel_ranges():
248249
)
249250
)
250251

252+
@property
253+
def temperature(self):
254+
"""The temperature, in degrees Celsius."""
255+
raw_temp_data = self._raw_temp_data
256+
257+
temperature_raw = raw_temp_data[0] | (raw_temp_data[1] << 8)
258+
temperature_c = temperature_raw / 16.0 + 25.0
259+
260+
return temperature_c
261+
251262
@property
252263
def acceleration(self):
253264
"""The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2."""

adafruit_lsm6ds/ism330dhcx.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class ISM330DHCX(LSM6DS): # pylint: disable=too-many-instance-attributes
1515
"""Driver for the LSM6DS33 6-axis accelerometer and gyroscope.
1616
1717
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to.
18-
:param address: The I2C slave address of the sensor
19-
18+
:param address: The I2C address of the sensor
2019
"""
2120

2221
CHIP_ID = 0x6B

adafruit_lsm6ds/lsm6ds33.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class LSM6DS33(LSM6DS): # pylint: disable=too-many-instance-attributes
1212
"""Driver for the LSM6DS33 6-axis accelerometer and gyroscope.
1313
1414
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to.
15-
:param address: The I2C slave address of the sensor
16-
15+
:param address: The I2C address of the sensor
1716
"""
1817

1918
CHIP_ID = 0x69

adafruit_lsm6ds/lsm6dso32.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class LSM6DSO32(LSM6DS): # pylint: disable=too-many-instance-attributes
1212
"""Driver for the LSM6DSO32 6-axis accelerometer and gyroscope.
1313
1414
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSO32 is connected to.
15-
:param address: The I2C slave address of the sensor
16-
15+
:param address: The I2C address of the sensor
1716
"""
1817

1918
CHIP_ID = LSM6DS_CHIP_ID

adafruit_lsm6ds/lsm6dsox.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class LSM6DSOX(LSM6DS): # pylint: disable=too-many-instance-attributes
1212
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
1313
1414
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
15-
:param address: The I2C slave address of the sensor
16-
15+
:param address: The I2C address of the sensor
1716
"""
1817

1918
CHIP_ID = LSM6DS_CHIP_ID

0 commit comments

Comments
 (0)