File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 39
39
40
40
import math
41
41
import analogio
42
- import microcontroller
42
+ try :
43
+ import typing # pylint: disable=unused-import
44
+ import microcontroller
45
+ except ImportError :
46
+ pass
43
47
44
48
__version__ = "0.0.0-auto.0"
45
49
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermistor.git"
@@ -86,14 +90,14 @@ class Thermistor:
86
90
87
91
def __init__ (
88
92
self ,
89
- pin : microcontroller .pin ,
93
+ pin : microcontroller .Pin ,
90
94
series_resistor : int ,
91
95
nominal_resistance : int ,
92
96
nominal_temperature : int ,
93
97
b_coefficient : int ,
94
98
* ,
95
99
high_side : bool = True
96
- ):
100
+ ) -> None :
97
101
# pylint: disable=too-many-arguments
98
102
self .pin = analogio .AnalogIn (pin )
99
103
self .series_resistor = series_resistor
@@ -103,7 +107,7 @@ def __init__(
103
107
self .high_side = high_side
104
108
105
109
@property
106
- def resistance (self ):
110
+ def resistance (self ) -> float :
107
111
"""The resistance of the thermistor in Ohms"""
108
112
if self .high_side :
109
113
# Thermistor connected from analog input to high logic level.
@@ -116,7 +120,7 @@ def resistance(self):
116
120
return reading
117
121
118
122
@property
119
- def temperature (self ):
123
+ def temperature (self ) -> float :
120
124
"""The temperature of the thermistor in Celsius"""
121
125
steinhart = self .resistance / self .nominal_resistance # (R/Ro)
122
126
steinhart = math .log (steinhart ) # ln(R/Ro)
You can’t perform that action at this time.
0 commit comments