From fe006021ee3e8d6c92813c8b9147ae181cda2e84 Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Thu, 14 Apr 2016 18:01:06 -0400 Subject: [PATCH] thermistortablefile.py: keep fractional part when computing table. The Thermistortablefile.py routine prematurely drops the fractional part of the temperature when computing the 14.2 temperature values to emit in the code. Keep this instead until the last moment when we finally calculate the integer format we will store. --- configtool/thermistortablefile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configtool/thermistortablefile.py b/configtool/thermistortablefile.py index 27f2348..e03355a 100644 --- a/configtool/thermistortablefile.py +++ b/configtool/thermistortablefile.py @@ -103,7 +103,7 @@ def BetaTable(ofp, params, names, settings, finalTable): samples = optimizeTempTable(thrm, N, hiadc) for i in samples: - t = int(thrm.temp(i)) + t = thrm.temp(i) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue @@ -118,7 +118,7 @@ def BetaTable(ofp, params, names, settings, finalTable): else: c = "," ostr = (" {%4s, %5s}%s // %4d C, %6.0f ohms, %0.3f V," - " %0.2f mW") % (i, t * 4, c, t, int(round(r)), + " %0.2f mW") % (i, int(t * 4), c, int(t), int(round(r)), vTherm, ptherm * 1000) ofp.output(ostr) @@ -146,7 +146,7 @@ def SteinhartHartTable(ofp, params, names, settings, finalTable): samples = optimizeTempTable(thrm, N, hiadc) for i in samples: - t = int(thrm.temp(i)) + t = thrm.temp(i) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue @@ -158,7 +158,7 @@ def SteinhartHartTable(ofp, params, names, settings, finalTable): else: c = "," ofp.output(" {%4d, %5d}%s // %4d C, %6d ohms" % - (i, t * 4, c, t, int(round(r)))) + (i, int(t * 4), c, int(t), int(round(r)))) if finalTable: ofp.output(" }")