Skip to content

Commit

Permalink
Merge pull request #8 from ladyada/master
Browse files Browse the repository at this point in the history
add high pass filter support
  • Loading branch information
ladyada committed Mar 5, 2020
2 parents edac0b2 + 6b051ef commit effd1ba
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions adafruit_lsm6ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
_LSM6DS_CTRL3_C = const(0x12)
_LSM6DS_CTRL_5_C = const(0x14)
_LSM6DS_MASTER_CONFIG = const(0x14)
_LSM6DS_CTRL8_XL = const(0x17)
_LSM6DS_CTRL9_XL = const(0x18)
_LSM6DS_CTRL10_C = const(0x19)
_LSM6DS_OUT_TEMP_L = const(0x20)
Expand Down Expand Up @@ -157,6 +158,17 @@ class Rate(CV):
('RATE_1_6_HZ', 11, 1.6, None)
))

class AccelHPF(CV):
"""Options for the accelerometer high pass filter"""
pass #pylint: disable=unnecessary-pass

AccelHPF.add_values((
('SLOPE', 0, 0, None),
('HPF_DIV100', 1, 0, None),
('HPF_DIV9', 2, 0, None),
('HPF_DIV400', 3, 0, None),
))


class LSM6DS: #pylint: disable=too-many-instance-attributes

Expand Down Expand Up @@ -220,6 +232,9 @@ class LSM6DS: #pylint: disable=too-many-instance-attributes
_ped_enable = RWBit(_LSM6DS_TAP_CFG, 6)
_func_enable = RWBit(_LSM6DS_CTRL10_C, 2)

high_pass_filter_enabled = RWBit(_LSM6DS_CTRL8_XL, 2)
_pass_filter = RWBits(2, _LSM6DS_CTRL8_XL, 5)

CHIP_ID = None

def __init__(self, i2c_bus, address=_LSM6DS_DEFAULT_ADDRESS):
Expand Down Expand Up @@ -360,6 +375,18 @@ def pedometer_enable(self, enable):
self._func_enable = enable
self.pedometer_reset = enable

@property
def high_pass_filter(self):
"""The high pass filter applied to accelerometer data"""
return self._pass_filter

@high_pass_filter.setter
def high_pass_filter(self, value):
if not AccelHPF.is_valid(value):
raise AttributeError("range must be an `AccelHPF`")
self._pass_filter = value


class LSM6DSOX(LSM6DS): #pylint: disable=too-many-instance-attributes

"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
Expand Down

0 comments on commit effd1ba

Please sign in to comment.