Skip to content

fixed annotations issues #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions adafruit_thermistor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
import math
import analogio

try:
import typing # pylint: disable=unused-import
import microcontroller
except ImportError:
pass

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermistor.git"

Expand Down Expand Up @@ -85,14 +91,14 @@ class Thermistor:

def __init__(
self,
pin,
series_resistor,
nominal_resistance,
nominal_temperature,
b_coefficient,
pin: microcontroller.Pin,
series_resistor: int,
nominal_resistance: int,
nominal_temperature: int,
b_coefficient: int,
*,
high_side=True
):
high_side: bool = True
) -> None:
# pylint: disable=too-many-arguments
self.pin = analogio.AnalogIn(pin)
self.series_resistor = series_resistor
Expand All @@ -102,7 +108,7 @@ def __init__(
self.high_side = high_side

@property
def resistance(self):
def resistance(self) -> float:
"""The resistance of the thermistor in Ohms"""
if self.high_side:
# Thermistor connected from analog input to high logic level.
Expand All @@ -115,7 +121,7 @@ def resistance(self):
return reading

@property
def temperature(self):
def temperature(self) -> float:
"""The temperature of the thermistor in Celsius"""
steinhart = self.resistance / self.nominal_resistance # (R/Ro)
steinhart = math.log(steinhart) # ln(R/Ro)
Expand Down