|
74 | 74 | _LSM6DS_CTRL_5_C = const(0x14)
|
75 | 75 | _LSM6DS_MASTER_CONFIG = const(0x14)
|
76 | 76 | _LSM6DS_CTRL9_XL = const(0x18)
|
| 77 | +_LSM6DS_CTRL10_C = const(0x19) |
77 | 78 | _LSM6DS_OUT_TEMP_L = const(0x20)
|
78 | 79 | _LSM6DS_OUT_TEMP_H = const(0x21)
|
79 | 80 | _LSM6DS_OUTX_L_G = const(0x22)
|
|
88 | 89 | _LSM6DS_OUTY_H_A = const(0x2B)
|
89 | 90 | _LSM6DS_OUTZ_L_A = const(0x2C)
|
90 | 91 | _LSM6DS_OUTZ_H_A = const(0x2D)
|
| 92 | +_LSM6DS_STEP_COUNTER = const(0x4B) |
| 93 | +_LSM6DS_TAP_CFG = const(0x58) |
91 | 94 |
|
92 | 95 | _MILLI_G_TO_ACCEL = 0.00980665
|
93 | 96 |
|
@@ -209,10 +212,16 @@ class LSM6DS: #pylint: disable=too-many-instance-attributes
|
209 | 212 | _i3c_disable = RWBit(_LSM6DS_CTRL9_XL, 1)
|
210 | 213 |
|
211 | 214 | _raw_temp = ROUnaryStruct(_LSM6DS_OUT_TEMP_L, "<h")
|
212 |
| - |
213 | 215 | _raw_accel_data = Struct(_LSM6DS_OUTX_L_A, "<hhh")
|
214 | 216 | _raw_gyro_data = Struct(_LSM6DS_OUTX_L_G, "<hhh")
|
| 217 | + |
| 218 | + pedometer_steps = ROUnaryStruct(_LSM6DS_STEP_COUNTER, "<h") |
| 219 | + pedometer_reset = RWBit(_LSM6DS_CTRL10_C, 1) |
| 220 | + _ped_enable = RWBit(_LSM6DS_TAP_CFG, 6) |
| 221 | + _func_enable = RWBit(_LSM6DS_CTRL10_C, 2) |
| 222 | + |
215 | 223 | CHIP_ID = None
|
| 224 | + |
216 | 225 | def __init__(self, i2c_bus, address=_LSM6DS_DEFAULT_ADDRESS):
|
217 | 226 | self._cached_accel_range = None
|
218 | 227 | self._cached_gyro_range = None
|
@@ -340,6 +349,17 @@ def gyro_data_rate(self, value):
|
340 | 349 | self._gyro_data_rate = value
|
341 | 350 | # sleep(.2) # needed to let new range settle
|
342 | 351 |
|
| 352 | + @property |
| 353 | + def pedometer_enable(self): |
| 354 | + """ Whether the pedometer function on the accelerometer is enabled""" |
| 355 | + return self._ped_enable and self._func_enable |
| 356 | + |
| 357 | + @pedometer_enable.setter |
| 358 | + def pedometer_enable(self, enable): |
| 359 | + self._ped_enable = enable |
| 360 | + self._func_enable = enable |
| 361 | + self.pedometer_reset = enable |
| 362 | + |
343 | 363 | class LSM6DSOX(LSM6DS): #pylint: disable=too-many-instance-attributes
|
344 | 364 |
|
345 | 365 | """Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
|
|
0 commit comments