@@ -186,37 +186,38 @@ def _reset(self):
186
186
@property
187
187
def mode (self ):
188
188
"""
189
- legend: x=on, -=off
190
-
191
- +------------------+-------+---------+------+----------+
192
- | Mode | Accel | Compass | Gyro | Absolute |
193
- +==================+=======+=========+======+==========+
194
- | CONFIG_MODE | - | - | - | - |
195
- +------------------+-------+---------+------+----------+
196
- | ACCONLY_MODE | X | - | - | - |
197
- +------------------+-------+---------+------+----------+
198
- | MAGONLY_MODE | - | X | - | - |
199
- +------------------+-------+---------+------+----------+
200
- | GYRONLY_MODE | - | - | X | - |
201
- +------------------+-------+---------+------+----------+
202
- | ACCMAG_MODE | X | X | - | - |
203
- +------------------+-------+---------+------+----------+
204
- | ACCGYRO_MODE | X | - | X | - |
205
- +------------------+-------+---------+------+----------+
206
- | MAGGYRO_MODE | - | X | X | - |
207
- +------------------+-------+---------+------+----------+
208
- | AMG_MODE | X | X | X | - |
209
- +------------------+-------+---------+------+----------+
210
- | IMUPLUS_MODE | X | - | X | - |
211
- +------------------+-------+---------+------+----------+
212
- | COMPASS_MODE | X | X | - | X |
213
- +------------------+-------+---------+------+----------+
214
- | M4G_MODE | X | X | - | - |
215
- +------------------+-------+---------+------+----------+
216
- | NDOF_FMC_OFF_MODE| X | X | X | X |
217
- +------------------+-------+---------+------+----------+
218
- | NDOF_MODE | X | X | X | X |
219
- +------------------+-------+---------+------+----------+
189
+ legend: x=on, -=off (see Table 3-3 in datasheet)
190
+
191
+ +------------------+-------+---------+------+----------+----------+
192
+ | Mode | Accel | Compass | Gyro | Fusion | Fusion |
193
+ | | | (Mag) | | Absolute | Relative |
194
+ +==================+=======+=========+======+==========+==========+
195
+ | CONFIG_MODE | - | - | - | - | - |
196
+ +------------------+-------+---------+------+----------+----------+
197
+ | ACCONLY_MODE | X | - | - | - | - |
198
+ +------------------+-------+---------+------+----------+----------+
199
+ | MAGONLY_MODE | - | X | - | - | - |
200
+ +------------------+-------+---------+------+----------+----------+
201
+ | GYRONLY_MODE | - | - | X | - | - |
202
+ +------------------+-------+---------+------+----------+----------+
203
+ | ACCMAG_MODE | X | X | - | - | - |
204
+ +------------------+-------+---------+------+----------+----------+
205
+ | ACCGYRO_MODE | X | - | X | - | - |
206
+ +------------------+-------+---------+------+----------+----------+
207
+ | MAGGYRO_MODE | - | X | X | - | - |
208
+ +------------------+-------+---------+------+----------+----------+
209
+ | AMG_MODE | X | X | X | - | - |
210
+ +------------------+-------+---------+------+----------+----------+
211
+ | IMUPLUS_MODE | X | - | X | - | X |
212
+ +------------------+-------+---------+------+----------+----------+
213
+ | COMPASS_MODE | X | X | - | X | - |
214
+ +------------------+-------+---------+------+----------+----------+
215
+ | M4G_MODE | X | X | - | - | X |
216
+ +------------------+-------+---------+------+----------+----------+
217
+ | NDOF_FMC_OFF_MODE| X | X | X | X | - |
218
+ +------------------+-------+---------+------+----------+----------+
219
+ | NDOF_MODE | X | X | X | X | - |
220
+ +------------------+-------+---------+------+----------+----------+
220
221
221
222
The default mode is ``NDOF_MODE``.
222
223
@@ -362,7 +363,7 @@ def magnetic(self):
362
363
"""Gives the raw magnetometer readings in microteslas.
363
364
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
364
365
"""
365
- if self .mode not in [0x00 , 0x03 , 0x05 , 0x08 ]:
366
+ if self .mode not in [0x00 , 0x01 , 0x03 , 0x05 , 0x08 ]:
366
367
return self ._magnetic
367
368
return (None , None , None )
368
369
@@ -388,7 +389,7 @@ def euler(self):
388
389
"""Gives the calculated orientation angles, in degrees.
389
390
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
390
391
"""
391
- if self .mode in [0x09 , 0x0B , 0x0C ]:
392
+ if self .mode in [0x08 , 0x09 , 0x0A , 0x0B , 0x0C ]:
392
393
return self ._euler
393
394
return (None , None , None )
394
395
@@ -401,7 +402,7 @@ def quaternion(self):
401
402
"""Gives the calculated orientation as a quaternion.
402
403
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
403
404
"""
404
- if self .mode in [0x09 , 0x0B , 0x0C ]:
405
+ if self .mode in [0x08 , 0x09 , 0x0A , 0x0B , 0x0C ]:
405
406
return self ._quaternion
406
407
return (None , None , None , None )
407
408
@@ -414,7 +415,7 @@ def linear_acceleration(self):
414
415
"""Returns the linear acceleration, without gravity, in m/s.
415
416
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
416
417
"""
417
- if self .mode in [0x09 , 0x0B , 0x0C ]:
418
+ if self .mode in [0x08 , 0x09 , 0x0A , 0x0B , 0x0C ]:
418
419
return self ._linear_acceleration
419
420
return (None , None , None )
420
421
@@ -427,7 +428,7 @@ def gravity(self):
427
428
"""Returns the gravity vector, without acceleration in m/s.
428
429
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
429
430
"""
430
- if self .mode in [0x09 , 0x0B , 0x0C ]:
431
+ if self .mode in [0x08 , 0x09 , 0x0A , 0x0B , 0x0C ]:
431
432
return self ._gravity
432
433
return (None , None , None )
433
434
@@ -713,37 +714,37 @@ def _temperature(self):
713
714
@property
714
715
def _acceleration (self ):
715
716
resp = struct .unpack ("<hhh" , self ._read_register (0x08 , 6 ))
716
- return tuple ([ x / 100 for x in resp ] )
717
+ return tuple (x / 100 for x in resp )
717
718
718
719
@property
719
720
def _magnetic (self ):
720
721
resp = struct .unpack ("<hhh" , self ._read_register (0x0E , 6 ))
721
- return tuple ([ x / 16 for x in resp ] )
722
+ return tuple (x / 16 for x in resp )
722
723
723
724
@property
724
725
def _gyro (self ):
725
726
resp = struct .unpack ("<hhh" , self ._read_register (0x14 , 6 ))
726
- return tuple ([ x * 0.001090830782496456 for x in resp ] )
727
+ return tuple (x * 0.001090830782496456 for x in resp )
727
728
728
729
@property
729
730
def _euler (self ):
730
731
resp = struct .unpack ("<hhh" , self ._read_register (0x1A , 6 ))
731
- return tuple ([ x / 16 for x in resp ] )
732
+ return tuple (x / 16 for x in resp )
732
733
733
734
@property
734
735
def _quaternion (self ):
735
736
resp = struct .unpack ("<hhhh" , self ._read_register (0x20 , 8 ))
736
- return tuple ([ x / (1 << 14 ) for x in resp ] )
737
+ return tuple (x / (1 << 14 ) for x in resp )
737
738
738
739
@property
739
740
def _linear_acceleration (self ):
740
741
resp = struct .unpack ("<hhh" , self ._read_register (0x28 , 6 ))
741
- return tuple ([ x / 100 for x in resp ] )
742
+ return tuple (x / 100 for x in resp )
742
743
743
744
@property
744
745
def _gravity (self ):
745
746
resp = struct .unpack ("<hhh" , self ._read_register (0x2E , 6 ))
746
- return tuple ([ x / 100 for x in resp ] )
747
+ return tuple (x / 100 for x in resp )
747
748
748
749
@property
749
750
def offsets_accelerometer (self ):
0 commit comments