From 7fe14f05e69f450092be7bf2d931f96918a04652 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 4 Jan 2019 12:30:20 -0500 Subject: [PATCH] thermistor: Avoid divide by zero error if min_temp=-273.15 Reported by @TheGuv. Signed-off-by: Kevin O'Connor --- klippy/extras/thermistor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/klippy/extras/thermistor.py b/klippy/extras/thermistor.py index c39ae66e..20c87754 100644 --- a/klippy/extras/thermistor.py +++ b/klippy/extras/thermistor.py @@ -75,6 +75,8 @@ class Thermistor: temp = 1.0/inv_t + KELVIN_TO_CELCIUS self.temperature_callback(read_time + SAMPLE_COUNT * SAMPLE_TIME, temp) def calc_adc(self, temp): + if temp <= KELVIN_TO_CELCIUS: + return 1. inv_t = 1. / (temp - KELVIN_TO_CELCIUS) if self.c3: # Solve for ln_r using Cardano's formula