36
36
from adafruit_register .i2c_struct import Struct , UnaryStruct
37
37
38
38
try :
39
- from typing import Optional , Tuple , Union
39
+ from typing import Optional , Tuple , Type , Union
40
40
from busio import I2C , UART
41
41
except ImportError :
42
42
pass
@@ -221,7 +221,7 @@ class BNO055: # pylint: disable=too-many-public-methods
221
221
def __init__ (self ) -> None :
222
222
chip_id = self ._read_register (_ID_REGISTER )
223
223
if chip_id != _CHIP_ID :
224
- raise RuntimeError ("bad chip id (%x != %x)" % ( chip_id , _CHIP_ID ) )
224
+ raise RuntimeError (f "bad chip id ({ chip_id :#x } != { _CHIP_ID :#x } )" )
225
225
self ._reset ()
226
226
self .set_normal_mode ()
227
227
self ._write_register (_PAGE_REGISTER , 0x00 )
@@ -406,7 +406,7 @@ def _temperature(self) -> None:
406
406
raise NotImplementedError ("Must be implemented." )
407
407
408
408
@property
409
- def acceleration (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
409
+ def acceleration (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
410
410
"""Gives the raw accelerometer readings, in m/s.
411
411
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
412
412
"""
@@ -419,7 +419,7 @@ def _acceleration(self) -> None:
419
419
raise NotImplementedError ("Must be implemented." )
420
420
421
421
@property
422
- def magnetic (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
422
+ def magnetic (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
423
423
"""Gives the raw magnetometer readings in microteslas.
424
424
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
425
425
"""
@@ -432,7 +432,7 @@ def _magnetic(self) -> None:
432
432
raise NotImplementedError ("Must be implemented." )
433
433
434
434
@property
435
- def gyro (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
435
+ def gyro (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
436
436
"""Gives the raw gyroscope reading in radians per second.
437
437
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
438
438
"""
@@ -445,7 +445,7 @@ def _gyro(self) -> None:
445
445
raise NotImplementedError ("Must be implemented." )
446
446
447
447
@property
448
- def euler (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
448
+ def euler (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
449
449
"""Gives the calculated orientation angles, in degrees.
450
450
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
451
451
"""
@@ -458,7 +458,7 @@ def _euler(self) -> None:
458
458
raise NotImplementedError ("Must be implemented." )
459
459
460
460
@property
461
- def quaternion (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
461
+ def quaternion (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
462
462
"""Gives the calculated orientation as a quaternion.
463
463
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
464
464
"""
@@ -473,7 +473,7 @@ def _quaternion(self) -> None:
473
473
@property
474
474
def linear_acceleration (
475
475
self ,
476
- ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
476
+ ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
477
477
"""Returns the linear acceleration, without gravity, in m/s.
478
478
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
479
479
"""
@@ -486,7 +486,7 @@ def _linear_acceleration(self) -> None:
486
486
raise NotImplementedError ("Must be implemented." )
487
487
488
488
@property
489
- def gravity (self ) -> Tuple [Optonal [float ], Optional [float ], Optional [float ]]:
489
+ def gravity (self ) -> Tuple [Optional [float ], Optional [float ], Optional [float ]]:
490
490
"""Returns the gravity vector, without acceleration in m/s.
491
491
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
492
492
"""
@@ -811,9 +811,9 @@ def __init__(self, uart: UART) -> None:
811
811
self ._uart .baudrate = 115200
812
812
super ().__init__ ()
813
813
814
- def _write_register (
814
+ def _write_register ( # pylint: disable=arguments-differ,arguments-renamed
815
815
self , register : int , data : int
816
- ) -> None : # pylint: disable=arguments-differ,arguments-renamed
816
+ ) -> None :
817
817
if not isinstance (data , bytes ):
818
818
data = bytes ([data ])
819
819
self ._uart .write (bytes ([0xAA , 0x00 , register , len (data )]) + data )
@@ -826,9 +826,9 @@ def _write_register(
826
826
if resp [0 ] != 0xEE or resp [1 ] != 0x01 :
827
827
raise RuntimeError (f"UART write error: { resp [1 ]} " )
828
828
829
- def _read_register (
829
+ def _read_register ( # pylint: disable=arguments-differ
830
830
self , register : int , length : int = 1
831
- ) -> int : # pylint: disable=arguments-differ
831
+ ) -> int :
832
832
i = 0
833
833
while i < 3 :
834
834
self ._uart .write (bytes ([0xAA , 0x01 , register , length ]))
0 commit comments