29
29
from typing_extensions import Literal
30
30
from circuitpython_typing import WriteableBuffer
31
31
from adafruit_onewire .bus import OneWireBus # pylint: disable=ungrouped-imports
32
+ from adafruit_onewire .device import OneWireAddress
32
33
except ImportError :
33
34
pass
34
35
35
36
_CONVERT = b"\x44 "
36
37
_RD_SCRATCH = b"\xBE "
37
38
_WR_SCRATCH = b"\x4E "
38
39
_CONVERSION_TIMEOUT = const (1 )
39
- RESOLUTION = (9 , 10 , 11 , 12 )
40
+ RESOLUTION : tuple [ Literal [ 9 , 10 , 11 , 12 ], ...] = (9 , 10 , 11 , 12 )
40
41
# Maximum conversion delay in seconds, from DS18B20 datasheet.
41
42
_CONVERSION_DELAY = {9 : 0.09375 , 10 : 0.1875 , 11 : 0.375 , 12 : 0.750 }
42
43
@@ -74,7 +75,7 @@ class DS18X20:
74
75
75
76
"""
76
77
77
- def __init__ (self , bus : OneWireBus , address : int ) -> None :
78
+ def __init__ (self , bus : OneWireBus , address : OneWireAddress ) -> None :
78
79
if address .family_code in (0x10 , 0x28 ):
79
80
self ._address = address
80
81
self ._device = OneWireDevice (bus , address )
@@ -84,7 +85,7 @@ def __init__(self, bus: OneWireBus, address: int) -> None:
84
85
raise ValueError ("Incorrect family code in device address." )
85
86
86
87
@property
87
- def temperature (self ):
88
+ def temperature (self ) -> float :
88
89
"""The temperature in degrees Celsius."""
89
90
self ._convert_temp ()
90
91
return self ._read_temp ()
0 commit comments