File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 26
26
import time
27
27
28
28
try :
29
- from typing import Union
29
+ from typing import Optional
30
30
from busio import UART
31
31
except ImportError :
32
32
pass
35
35
class US100 :
36
36
"""Control a US-100 ultrasonic range sensor."""
37
37
38
- def __init__ (self , uart : UART ):
38
+ def __init__ (self , uart : UART ) -> None :
39
39
self ._uart = uart
40
40
41
41
@property
42
- def distance (self ) -> float :
42
+ def distance (self ) -> Optional [ float ] :
43
43
"""Return the distance measured by the sensor in cm.
44
44
This is the function that will be called most often in user code.
45
45
If no signal is received, return ``None``. This can happen when the
@@ -73,7 +73,7 @@ def distance(self) -> float:
73
73
return dist
74
74
75
75
@property
76
- def temperature (self ) -> Union [ None , int ]:
76
+ def temperature (self ) -> Optional [ int ]:
77
77
"""Return the on-chip temperature, in Celsius"""
78
78
for _ in range (2 ): # Attempt to read twice.
79
79
self ._uart .write (bytes ([0x50 ]))
You can’t perform that action at this time.
0 commit comments