2626import time
2727from struct import unpack_from
2828
29+ try :
30+ from typing import Optional , Tuple
31+ from busio import UART
32+ except ImportError :
33+ pass
34+
2935__version__ = "0.0.0-auto.0"
3036__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BNO08x_RVC.git"
3137
@@ -37,7 +43,7 @@ class RVCReadTimeoutError(Exception):
3743class BNO08x_RVC :
3844 """A simple class for reading heading from the BNO08x IMUs using the UART-RVC mode
3945
40- :param uart: The UART device the BNO08x_RVC is connected to.
46+ :param ~busio.UART uart: The UART device the BNO08x_RVC is connected to.
4147 :param float timeout: time to wait for readings. Defaults to :const:`1.0`
4248
4349
@@ -68,13 +74,15 @@ class BNO08x_RVC:
6874
6975 """
7076
71- def __init__ (self , uart , timeout = 1.0 ):
77+ def __init__ (self , uart : UART , timeout : float = 1.0 ) -> None :
7278 self ._uart = uart
7379 self ._debug = True
7480 self ._read_timeout = timeout
7581
7682 @staticmethod
77- def _parse_frame (frame ):
83+ def _parse_frame (
84+ frame : bytes ,
85+ ) -> Optional [Tuple [float , float , float , float , float , float ]]:
7886 heading_frame = unpack_from ("<BhhhhhhBBBB" , frame )
7987 (
8088 _index ,
@@ -101,7 +109,7 @@ def _parse_frame(frame):
101109 return (yaw , pitch , roll , x_accel , y_accel , z_accel )
102110
103111 @property
104- def heading (self ):
112+ def heading (self ) -> Tuple [ float , float , float , float , float , float ] :
105113 """The current heading made up of
106114
107115 * Yaw
0 commit comments