33
33
34
34
**Hardware:**
35
35
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
+
38
38
39
39
**Software and Dependencies:**
40
40
41
41
* Adafruit CircuitPython firmware for the supported boards:
42
42
https://github.com/adafruit/circuitpython/releases
43
43
44
- .. todo:: Uncomment or remove the Bus Device and/or the Register library dependencies based on the library's use of either.
45
44
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
48
47
"""
49
48
50
49
__version__ = "0.0.0-auto.0"
51
50
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git"
52
51
from time import sleep
53
52
from micropython import const
54
53
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
57
55
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
60
57
__version__ = "0.0.0-auto.0"
61
58
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git"
62
59
63
60
64
61
_LSM6DSOX_DEFAULT_ADDRESS = const (0x6a )
65
62
_LSM6DSOX_CHIP_ID = const (0x6C )
63
+ _ISM330DHCX_CHIP_ID = const (0x6B )
66
64
67
65
68
66
_LSM6DSOX_FUNC_CFG_ACCESS = const (0x1 )
90
88
_LSM6DSOX_OUTZ_L_A = const (0x2C )
91
89
_LSM6DSOX_OUTZ_H_A = const (0x2D )
92
90
93
- _MILLI_G_TO_ACCEL = 0.00980665
91
+ _MILLI_G_TO_ACCEL = 0.00980665
92
+
94
93
class CV :
95
94
"""struct helper"""
96
95
97
96
@classmethod
98
97
def add_values (cls , value_tuples ):
98
+ "creates CV entires"
99
99
cls .string = {}
100
100
cls .lsb = {}
101
101
@@ -107,11 +107,12 @@ def add_values(cls, value_tuples):
107
107
108
108
@classmethod
109
109
def is_valid (cls , value ):
110
+ "Returns true if the given value is a member of the CV"
110
111
return value in cls .string
111
112
112
113
class AccelRange (CV ):
113
114
"""Options for `accelerometer_range`"""
114
- pass
115
+ pass #pylint: disable=unnecessary-pass
115
116
116
117
AccelRange .add_values ((
117
118
('RANGE_2G' , 0 , 2 , 0.061 ),
@@ -122,7 +123,7 @@ class AccelRange(CV):
122
123
123
124
class GyroRange (CV ):
124
125
"""Options for `gyro_data_range`"""
125
- pass
126
+ pass #pylint: disable=unnecessary-pass
126
127
127
128
GyroRange .add_values ((
128
129
('RANGE_250_DPS' , 0 , 250 , 8.75 ),
@@ -133,7 +134,7 @@ class GyroRange(CV):
133
134
134
135
class Rate (CV ):
135
136
"""Options for `data_rate`"""
136
- pass
137
+ pass #pylint: disable=unnecessary-pass
137
138
138
139
Rate .add_values ((
139
140
('RATE_SHUTDOWN' , 0 , 0 , None ),
@@ -150,7 +151,8 @@ class Rate(CV):
150
151
('RATE_1_6_HZ' , 11 , 1.6 , None )
151
152
))
152
153
153
- class LSM6DSOX :
154
+ class LSM6DSOX : #pylint: disable=too-many-instance-attributes
155
+
154
156
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
155
157
156
158
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
@@ -173,10 +175,10 @@ class LSM6DSOX:
173
175
_lvl2_ois = RWBit (_LSM6DSOX_UI_INT_OIS , 6 )
174
176
_int2_drdy_ois = RWBit (_LSM6DSOX_UI_INT_OIS , 7 )
175
177
_lpf_xl = RWBit (_LSM6DSOX_CTRL1_XL , 1 )
176
-
178
+
177
179
_accel_range = RWBits (2 , _LSM6DSOX_CTRL1_XL , 2 )
178
180
_accel_data_rate = RWBits (4 , _LSM6DSOX_CTRL1_XL , 4 )
179
-
181
+
180
182
_gyro_data_rate = RWBits (4 , _LSM6DSOX_CTRL2_G , 4 )
181
183
_gyro_range = RWBits (2 , _LSM6DSOX_CTRL2_G , 2 )
182
184
@@ -200,13 +202,6 @@ class LSM6DSOX:
200
202
_write_once = RWBit (_LSM6DSOX_MASTER_CONFIG , 6 )
201
203
_rst_master_regs = RWBit (_LSM6DSOX_MASTER_CONFIG , 7 )
202
204
_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
-
210
205
211
206
_raw_temp = ROUnaryStruct (_LSM6DSOX_OUT_TEMP_L , "<h" )
212
207
@@ -216,24 +211,25 @@ class LSM6DSOX:
216
211
def __init__ (self , i2c_bus , address = _LSM6DSOX_DEFAULT_ADDRESS ):
217
212
self .i2c_device = i2c_device .I2CDevice (i2c_bus , address )
218
213
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!" )
221
216
self .reset ()
222
217
223
218
self ._bdu = True
224
219
self ._i3c_disable = True
225
220
self ._if_inc = True
226
221
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
229
224
230
- self ._accel_range = AccelRange .RANGE_4G
225
+ self ._accel_range = AccelRange .RANGE_4G #pylint: disable=no-member
231
226
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
233
228
self ._cached_gyro_range = self ._gyro_range
234
229
235
230
236
231
def reset (self ):
232
+ "Resets the sensor's configuration into an initial state"
237
233
self ._sw_reset = True
238
234
while self ._sw_reset :
239
235
sleep (0.001 )
0 commit comments