aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
Diffstat (limited to 'klippy')
-rw-r--r--klippy/heater.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/klippy/heater.py b/klippy/heater.py
index 445f868b..c666ddec 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -35,6 +35,7 @@ class Thermistor:
self.c2 = (inv_t12 - self.c3 * ln3_r12) / ln_r12
self.c1 = inv_t1 - self.c2 * ln_r1 - self.c3 * ln3_r1
def calc_temp(self, adc):
+ adc = max(.00001, min(.99999, adc))
r = self.pullup * adc / (1.0 - adc)
ln_r = math.log(r)
inv_t = self.c1 + self.c2 * ln_r + self.c3 * ln_r**3