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