26
26
import time
27
27
from struct import unpack_from
28
28
29
+ try :
30
+ from typing import Optional , Tuple
31
+ from busio import UART
32
+ except ImportError :
33
+ pass
34
+
29
35
__version__ = "0.0.0-auto.0"
30
36
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BNO08x_RVC.git"
31
37
@@ -37,7 +43,7 @@ class RVCReadTimeoutError(Exception):
37
43
class BNO08x_RVC :
38
44
"""A simple class for reading heading from the BNO08x IMUs using the UART-RVC mode
39
45
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.
41
47
:param float timeout: time to wait for readings. Defaults to :const:`1.0`
42
48
43
49
@@ -68,13 +74,15 @@ class BNO08x_RVC:
68
74
69
75
"""
70
76
71
- def __init__ (self , uart , timeout = 1.0 ):
77
+ def __init__ (self , uart : UART , timeout : float = 1.0 ) -> None :
72
78
self ._uart = uart
73
79
self ._debug = True
74
80
self ._read_timeout = timeout
75
81
76
82
@staticmethod
77
- def _parse_frame (frame ):
83
+ def _parse_frame (
84
+ frame : bytes ,
85
+ ) -> Optional [Tuple [float , float , float , float , float , float ]]:
78
86
heading_frame = unpack_from ("<BhhhhhhBBBB" , frame )
79
87
(
80
88
_index ,
@@ -101,7 +109,7 @@ def _parse_frame(frame):
101
109
return (yaw , pitch , roll , x_accel , y_accel , z_accel )
102
110
103
111
@property
104
- def heading (self ):
112
+ def heading (self ) -> Tuple [ float , float , float , float , float , float ] :
105
113
"""The current heading made up of
106
114
107
115
* Yaw
0 commit comments