File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -174,11 +174,14 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
174
174
# Structs
175
175
_raw_accel_data = Struct (_LSM6DS_OUTX_L_A , "<hhh" )
176
176
_raw_gyro_data = Struct (_LSM6DS_OUTX_L_G , "<hhh" )
177
+ _raw_temp_data = Struct (_LSM6DS_OUT_TEMP_L , "<hh" )
178
+
177
179
# RWBits:
178
180
179
181
_accel_range = RWBits (2 , _LSM6DS_CTRL1_XL , 2 )
180
182
_accel_data_rate = RWBits (4 , _LSM6DS_CTRL1_XL , 4 )
181
183
184
+
182
185
_gyro_data_rate = RWBits (4 , _LSM6DS_CTRL2_G , 4 )
183
186
_gyro_range = RWBits (2 , _LSM6DS_CTRL2_G , 2 )
184
187
_gyro_range_125dps = RWBit (_LSM6DS_CTRL2_G , 1 )
@@ -248,6 +251,15 @@ def _add_accel_ranges():
248
251
)
249
252
)
250
253
254
+ @property
255
+ def temperature (self ):
256
+ raw_temp_data = self ._raw_temp_data
257
+
258
+ temperature_raw = raw_temp_data [0 ] | (raw_temp_data [1 ] << 8 )
259
+ temperature_c = temperature_raw / 16.0 + 25.0
260
+
261
+ return temperature_c
262
+
251
263
@property
252
264
def acceleration (self ):
253
265
"""The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2."""
You can’t perform that action at this time.
0 commit comments