From 452908afa9b7e360be0488aca65efc927b3ff6ba Mon Sep 17 00:00:00 2001 From: jbernardis Date: Mon, 27 Apr 2015 19:05:16 -0400 Subject: [PATCH] Configtool: prevent negative numbers in thermistor tables. --- configtool/thermistortablefile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configtool/thermistortablefile.py b/configtool/thermistortablefile.py index a6d7851..1b3e9b9 100644 --- a/configtool/thermistortablefile.py +++ b/configtool/thermistortablefile.py @@ -88,6 +88,8 @@ def generateTempTables(sensors, settings): for i in range(N): adcs.append(int(ct)) ct += increment + if ct > maxadc: + ct = maxadc counter = 0 for adc in adcs: @@ -104,8 +106,11 @@ def generateTempTables(sensors, settings): sep = " " else: sep = "," + val = int(thm.temp(adc) * mult) + if val < 0: + val = 0 ostr = (" {%4s, %5s}%s // %6.2f C, %6.0f ohms, %0.3f V," - " %0.2f C/count, %0.2f mW") % (adc, int(thm.temp(adc) * mult), + " %0.2f C/count, %0.2f mW") % (adc, val, sep, degC, resistance, vTherm, resolution, ptherm * 1000) ofp.output(ostr) if tcount == len(tl):