@@ -162,16 +162,22 @@ class ICM20X: # pylint:disable=too-many-instance-attributes
162
162
"""
163
163
164
164
# Bank 0
165
- _device_id = ROUnaryStruct (_ICM20X_WHO_AM_I , "< B" )
166
- _bank_reg = UnaryStruct (_ICM20X_REG_BANK_SEL , "< B" )
165
+ _device_id = ROUnaryStruct (_ICM20X_WHO_AM_I , "> B" )
166
+ _bank_reg = UnaryStruct (_ICM20X_REG_BANK_SEL , "> B" )
167
167
_reset = RWBit (_ICM20X_PWR_MGMT_1 , 7 )
168
168
_sleep = RWBit (_ICM20X_PWR_MGMT_1 , 6 )
169
169
_low_power_en = RWBit (_ICM20X_PWR_MGMT_1 , 5 )
170
170
_clock_source = RWBits (3 , _ICM20X_PWR_MGMT_1 , 0 )
171
171
172
- _raw_accel_data = Struct (_ICM20X_ACCEL_XOUT_H , ">hhh" )
172
+ _raw_accel_data = Struct (_ICM20X_ACCEL_XOUT_H , ">hhh" ) # ds says LE :|
173
173
_raw_gyro_data = Struct (_ICM20X_GYRO_XOUT_H , ">hhh" )
174
174
175
+ _lp_config_reg = UnaryStruct (_ICM20X_LP_CONFIG , ">B" )
176
+
177
+ _i2c_master_cycle_en = RWBit (_ICM20X_LP_CONFIG , 6 )
178
+ _accel_cycle_en = RWBit (_ICM20X_LP_CONFIG , 5 )
179
+ _gyro_cycle_en = RWBit (_ICM20X_LP_CONFIG , 4 )
180
+
175
181
# Bank 2
176
182
_gyro_dlpf_enable = RWBits (1 , _ICM20X_GYRO_CONFIG_1 , 0 )
177
183
_gyro_range = RWBits (2 , _ICM20X_GYRO_CONFIG_1 , 1 )
@@ -220,63 +226,6 @@ class ICM20X: # pylint:disable=too-many-instance-attributes
220
226
)
221
227
)
222
228
223
- @property
224
- def accel_dlpf_cutoff (self ):
225
- """The cutoff frequency for the accelerometer's digital low pass filter. Signals
226
- above the given frequency will be filtered out. Must be an ``AccelDLPFCutoff``.
227
- Use AccelDLPFCutoff.DISABLED to disable the filter
228
-
229
- **Note** readings immediately following setting a cutoff frequency will be
230
- inaccurate due to the filter "warming up" """
231
- self ._bank = 2
232
- return self ._accel_dlpf_config
233
-
234
- @accel_dlpf_cutoff .setter
235
- def accel_dlpf_cutoff (self , cutoff_frequency ):
236
- if not AccelDLPFFreq .is_valid (cutoff_frequency ):
237
- raise AttributeError ("accel_dlpf_cutoff must be an `AccelDLPFFreq`" )
238
- self ._bank = 2
239
- # check for shutdown
240
- if cutoff_frequency is AccelDLPFFreq .DISABLED : # pylint: disable=no-member
241
- self ._accel_dlpf_enable = False
242
- return
243
- self ._accel_dlpf_enable = True
244
- self ._accel_dlpf_config = cutoff_frequency
245
-
246
- @property
247
- def gyro_dlpf_cutoff (self ):
248
- """The cutoff frequency for the gyro's digital low pass filter. Signals above the
249
- given frequency will be filtered out. Must be a ``GyroDLPFFreq``. Use
250
- GyroDLPFCutoff.DISABLED to disable the filter
251
-
252
- **Note** readings immediately following setting a cutoff frequency will be
253
- inaccurate due to the filter "warming up" """
254
- self ._bank = 2
255
- return self ._gyro_dlpf_config
256
-
257
- @gyro_dlpf_cutoff .setter
258
- def gyro_dlpf_cutoff (self , cutoff_frequency ):
259
- if not GyroDLPFFreq .is_valid (cutoff_frequency ):
260
- raise AttributeError ("gyro_dlpf_cutoff must be a `GyroDLPFFreq`" )
261
- self ._bank = 2
262
- # check for shutdown
263
- if cutoff_frequency is GyroDLPFFreq .DISABLED : # pylint: disable=no-member
264
- self ._gyro_dlpf_enable = False
265
- return
266
- self ._gyro_dlpf_enable = True
267
- self ._gyro_dlpf_config = cutoff_frequency
268
-
269
- @property
270
- def low_power (self ):
271
- """Enables or disables a low power mode for the sensors digital circuitry"""
272
- self ._bank = 0
273
- return self ._low_power_en
274
-
275
- @low_power .setter
276
- def low_power (self , enabled ):
277
- self ._bank = 0
278
- self ._low_power_en = enabled
279
-
280
229
@property
281
230
def _bank (self ):
282
231
return self ._bank_reg >> 4
@@ -481,6 +430,63 @@ def gyro_data_rate(self, value):
481
430
divisor = round (((1125.0 - value ) / value ))
482
431
self .gyro_data_rate_divisor = divisor
483
432
433
+ @property
434
+ def accel_dlpf_cutoff (self ):
435
+ """The cutoff frequency for the accelerometer's digital low pass filter. Signals
436
+ above the given frequency will be filtered out. Must be an ``AccelDLPFCutoff``.
437
+ Use AccelDLPFCutoff.DISABLED to disable the filter
438
+
439
+ **Note** readings immediately following setting a cutoff frequency will be
440
+ inaccurate due to the filter "warming up" """
441
+ self ._bank = 2
442
+ return self ._accel_dlpf_config
443
+
444
+ @accel_dlpf_cutoff .setter
445
+ def accel_dlpf_cutoff (self , cutoff_frequency ):
446
+ if not AccelDLPFFreq .is_valid (cutoff_frequency ):
447
+ raise AttributeError ("accel_dlpf_cutoff must be an `AccelDLPFFreq`" )
448
+ self ._bank = 2
449
+ # check for shutdown
450
+ if cutoff_frequency is AccelDLPFFreq .DISABLED : # pylint: disable=no-member
451
+ self ._accel_dlpf_enable = False
452
+ return
453
+ self ._accel_dlpf_enable = True
454
+ self ._accel_dlpf_config = cutoff_frequency
455
+
456
+ @property
457
+ def gyro_dlpf_cutoff (self ):
458
+ """The cutoff frequency for the gyro's digital low pass filter. Signals above the
459
+ given frequency will be filtered out. Must be a ``GyroDLPFFreq``. Use
460
+ GyroDLPFCutoff.DISABLED to disable the filter
461
+
462
+ **Note** readings immediately following setting a cutoff frequency will be
463
+ inaccurate due to the filter "warming up" """
464
+ self ._bank = 2
465
+ return self ._gyro_dlpf_config
466
+
467
+ @gyro_dlpf_cutoff .setter
468
+ def gyro_dlpf_cutoff (self , cutoff_frequency ):
469
+ if not GyroDLPFFreq .is_valid (cutoff_frequency ):
470
+ raise AttributeError ("gyro_dlpf_cutoff must be a `GyroDLPFFreq`" )
471
+ self ._bank = 2
472
+ # check for shutdown
473
+ if cutoff_frequency is GyroDLPFFreq .DISABLED : # pylint: disable=no-member
474
+ self ._gyro_dlpf_enable = False
475
+ return
476
+ self ._gyro_dlpf_enable = True
477
+ self ._gyro_dlpf_config = cutoff_frequency
478
+
479
+ @property
480
+ def low_power (self ):
481
+ """Enables or disables a low power mode for the sensors digital circuitry"""
482
+ self ._bank = 0
483
+ return self ._low_power_en
484
+
485
+ @low_power .setter
486
+ def low_power (self , enabled ):
487
+ self ._bank = 0
488
+ self ._low_power_en = enabled
489
+
484
490
485
491
class ICM20649 (ICM20X ):
486
492
"""Library for the ST ICM-20649 Wide-Range 6-DoF Accelerometer and Gyro.
@@ -521,6 +527,7 @@ class ICM20948(ICM20X): # pylint:disable=too-many-instance-attributes
521
527
522
528
_slave_finished = ROBit (_ICM20X_I2C_MST_STATUS , 6 )
523
529
530
+ # mag data is LE
524
531
_raw_mag_data = Struct (_ICM20948_EXT_SLV_SENS_DATA_00 , "<hhhh" )
525
532
526
533
_bypass_i2c_master = RWBit (_ICM20X_REG_INT_PIN_CFG , 1 )
0 commit comments