Skip to content

Commit aea519f

Browse files
committed
linted
1 parent d2177c1 commit aea519f

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

adafruit_lsm6dsox.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,34 @@
3333
3434
**Hardware:**
3535
36-
.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST
37-
inline format: "* `Link Text <url>`_"
36+
* `Adafruit LSM6DSOX Breakout https://www.adafruit.com/products/4438`_
37+
3838
3939
**Software and Dependencies:**
4040
4141
* Adafruit CircuitPython firmware for the supported boards:
4242
https://github.com/adafruit/circuitpython/releases
4343
44-
.. todo:: Uncomment or remove the Bus Device and/or the Register library dependencies based on the library's use of either.
4544
46-
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
47-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
45+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
46+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
4847
"""
4948

5049
__version__ = "0.0.0-auto.0"
5150
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git"
5251
from time import sleep
5352
from micropython import const
5453
import adafruit_bus_device.i2c_device as i2c_device
55-
from adafruit_register.i2c_struct import UnaryStruct, ROUnaryStruct, Struct
56-
from adafruit_register.i2c_struct_array import StructArray
54+
from adafruit_register.i2c_struct import ROUnaryStruct, Struct
5755
from adafruit_register.i2c_bits import RWBits
58-
from adafruit_register.i2c_bit import RWBit, ROBit
59-
56+
from adafruit_register.i2c_bit import RWBit
6057
__version__ = "0.0.0-auto.0"
6158
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git"
6259

6360

6461
_LSM6DSOX_DEFAULT_ADDRESS = const(0x6a)
6562
_LSM6DSOX_CHIP_ID = const(0x6C)
63+
_ISM330DHCX_CHIP_ID = const(0x6B)
6664

6765

6866
_LSM6DSOX_FUNC_CFG_ACCESS = const(0x1)
@@ -90,12 +88,14 @@
9088
_LSM6DSOX_OUTZ_L_A = const(0x2C)
9189
_LSM6DSOX_OUTZ_H_A = const(0x2D)
9290

93-
_MILLI_G_TO_ACCEL = 0.00980665
91+
_MILLI_G_TO_ACCEL = 0.00980665
92+
9493
class CV:
9594
"""struct helper"""
9695

9796
@classmethod
9897
def add_values(cls, value_tuples):
98+
"creates CV entires"
9999
cls.string = {}
100100
cls.lsb = {}
101101

@@ -107,11 +107,12 @@ def add_values(cls, value_tuples):
107107

108108
@classmethod
109109
def is_valid(cls, value):
110+
"Returns true if the given value is a member of the CV"
110111
return value in cls.string
111112

112113
class AccelRange(CV):
113114
"""Options for `accelerometer_range`"""
114-
pass
115+
pass #pylint: disable=unnecessary-pass
115116

116117
AccelRange.add_values((
117118
('RANGE_2G', 0, 2, 0.061),
@@ -122,7 +123,7 @@ class AccelRange(CV):
122123

123124
class GyroRange(CV):
124125
"""Options for `gyro_data_range`"""
125-
pass
126+
pass #pylint: disable=unnecessary-pass
126127

127128
GyroRange.add_values((
128129
('RANGE_250_DPS', 0, 250, 8.75),
@@ -133,7 +134,7 @@ class GyroRange(CV):
133134

134135
class Rate(CV):
135136
"""Options for `data_rate`"""
136-
pass
137+
pass #pylint: disable=unnecessary-pass
137138

138139
Rate.add_values((
139140
('RATE_SHUTDOWN', 0, 0, None),
@@ -150,7 +151,8 @@ class Rate(CV):
150151
('RATE_1_6_HZ', 11, 1.6, None)
151152
))
152153

153-
class LSM6DSOX:
154+
class LSM6DSOX: #pylint: disable=too-many-instance-attributes
155+
154156
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
155157
156158
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
@@ -173,10 +175,10 @@ class LSM6DSOX:
173175
_lvl2_ois = RWBit(_LSM6DSOX_UI_INT_OIS, 6)
174176
_int2_drdy_ois = RWBit(_LSM6DSOX_UI_INT_OIS, 7)
175177
_lpf_xl = RWBit(_LSM6DSOX_CTRL1_XL, 1)
176-
178+
177179
_accel_range = RWBits(2, _LSM6DSOX_CTRL1_XL, 2)
178180
_accel_data_rate = RWBits(4, _LSM6DSOX_CTRL1_XL, 4)
179-
181+
180182
_gyro_data_rate = RWBits(4, _LSM6DSOX_CTRL2_G, 4)
181183
_gyro_range = RWBits(2, _LSM6DSOX_CTRL2_G, 2)
182184

@@ -200,13 +202,6 @@ class LSM6DSOX:
200202
_write_once = RWBit(_LSM6DSOX_MASTER_CONFIG, 6)
201203
_rst_master_regs = RWBit(_LSM6DSOX_MASTER_CONFIG, 7)
202204
_i3c_disable = RWBit(_LSM6DSOX_CTRL9_XL, 1)
203-
_den_lh = RWBit(_LSM6DSOX_CTRL9_XL, 2)
204-
_den_xl_en = RWBit(_LSM6DSOX_CTRL9_XL, 3)
205-
_den_xl_g = RWBit(_LSM6DSOX_CTRL9_XL, 4)
206-
_den_z = RWBit(_LSM6DSOX_CTRL9_XL, 5)
207-
_den_y = RWBit(_LSM6DSOX_CTRL9_XL, 6)
208-
_den_x = RWBit(_LSM6DSOX_CTRL9_XL, 7)
209-
210205

211206
_raw_temp = ROUnaryStruct(_LSM6DSOX_OUT_TEMP_L, "<h")
212207

@@ -216,24 +211,25 @@ class LSM6DSOX:
216211
def __init__(self, i2c_bus, address=_LSM6DSOX_DEFAULT_ADDRESS):
217212
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
218213

219-
if self._chip_id != _LSM6DSOX_CHIP_ID:
220-
raise RuntimeError("Failed to find LSM6DSOX - check your wiring!")
214+
if self._chip_id not in [_LSM6DSOX_CHIP_ID, _ISM330DHCX_CHIP_ID]:
215+
raise RuntimeError("Failed to find LSM6DSOX or ISM330DHCX - check your wiring!")
221216
self.reset()
222217

223218
self._bdu = True
224219
self._i3c_disable = True
225220
self._if_inc = True
226221

227-
self._accel_data_rate = Rate.RATE_104_HZ
228-
self._gyro_data_rate = Rate.RATE_104_HZ
222+
self._accel_data_rate = Rate.RATE_104_HZ #pylint: disable=no-member
223+
self._gyro_data_rate = Rate.RATE_104_HZ #pylint: disable=no-member
229224

230-
self._accel_range = AccelRange.RANGE_4G
225+
self._accel_range = AccelRange.RANGE_4G #pylint: disable=no-member
231226
self._cached_accel_range = self._accel_range
232-
self._gyro_range = GyroRange.RANGE_250_DPS
227+
self._gyro_range = GyroRange.RANGE_250_DPS #pylint: disable=no-member
233228
self._cached_gyro_range = self._gyro_range
234229

235230

236231
def reset(self):
232+
"Resets the sensor's configuration into an initial state"
237233
self._sw_reset = True
238234
while self._sw_reset:
239235
sleep(0.001)

0 commit comments

Comments
 (0)