22
22
23
23
import time
24
24
from micropython import const
25
- from adafruit_onewire .device import OneWireDevice
25
+ from adafruit_onewire .device import OneWireAddress , OneWireDevice
26
26
27
27
try :
28
28
import typing # pylint: disable=unused-import
36
36
_RD_SCRATCH = b"\xBE "
37
37
_WR_SCRATCH = b"\x4E "
38
38
_CONVERSION_TIMEOUT = const (1 )
39
- RESOLUTION = (9 , 10 , 11 , 12 )
39
+ RESOLUTION : tuple [ Literal [ 9 , 10 , 11 , 12 ], ...] = (9 , 10 , 11 , 12 )
40
40
# Maximum conversion delay in seconds, from DS18B20 datasheet.
41
41
_CONVERSION_DELAY = {9 : 0.09375 , 10 : 0.1875 , 11 : 0.375 , 12 : 0.750 }
42
42
@@ -74,7 +74,7 @@ class DS18X20:
74
74
75
75
"""
76
76
77
- def __init__ (self , bus : OneWireBus , address : int ) -> None :
77
+ def __init__ (self , bus : OneWireBus , address : OneWireAddress ) -> None :
78
78
if address .family_code in (0x10 , 0x28 ):
79
79
self ._address = address
80
80
self ._device = OneWireDevice (bus , address )
@@ -84,7 +84,7 @@ def __init__(self, bus: OneWireBus, address: int) -> None:
84
84
raise ValueError ("Incorrect family code in device address." )
85
85
86
86
@property
87
- def temperature (self ):
87
+ def temperature (self ) -> float :
88
88
"""The temperature in degrees Celsius."""
89
89
self ._convert_temp ()
90
90
return self ._read_temp ()
0 commit comments