diff options
author | 2018-02-16 13:41:21 +0200 | |
---|---|---|
committer | 2018-02-16 13:41:21 +0200 | |
commit | 4ab7c9eb681b133dcfeee1ecdd318780e6df170e (patch) | |
tree | ba1ab528529ec3a08d88e63b16a962732cec21c6 /src/tempmodule | |
parent | 00735224ca72ea64cfa4b882e2196c8fa03b9731 (diff) | |
download | coffeetemp-4ab7c9eb681b133dcfeee1ecdd318780e6df170e.tar.gz coffeetemp-4ab7c9eb681b133dcfeee1ecdd318780e6df170e.tar.bz2 coffeetemp-4ab7c9eb681b133dcfeee1ecdd318780e6df170e.zip |
tempmodule: not even close to overflowing, swtich 64b -> 32b.
Diffstat (limited to 'src/tempmodule')
-rw-r--r-- | src/tempmodule/temperature.c | 3 | ||||
-rw-r--r-- | src/tempmodule/temperature.h | 4 |
2 files changed, 2 insertions, 5 deletions
diff --git a/src/tempmodule/temperature.c b/src/tempmodule/temperature.c index 4f0a5f1..52fd7b7 100644 --- a/src/tempmodule/temperature.c +++ b/src/tempmodule/temperature.c @@ -16,7 +16,6 @@ struct temptuple { * * Rt = Ra * Vcc / Vt - Ra * - * Using 64-bit arithmetic as 32-bit would overflow. * On WeMOS D1 Mini the A0 reads 3.2V as 1023; our Vcc is 3.31V * The correct value of the reference volume obtained by measuring * resistances with a multimeter, taking the ADC reading and applying @@ -24,7 +23,7 @@ struct temptuple { * We shift the range by one to avoid division by zero. */ -int get_resistance(int64_t vt, int64_t ra) +int get_resistance(int vt, int ra) { ++vt; return ra * 1081 / vt - ra; diff --git a/src/tempmodule/temperature.h b/src/tempmodule/temperature.h index 8d990be..72189bb 100644 --- a/src/tempmodule/temperature.h +++ b/src/tempmodule/temperature.h @@ -1,13 +1,11 @@ #ifndef TEMPERATURE_INCLUDED #define TEMPERATURE_INCLUDED -#include <inttypes.h> - #ifdef __cplusplus extern "C" { #endif -int get_resistance(int64_t vt, int64_t ra); +int get_resistance(int vt, int ra); int get_temperature(int res); int get_temp_subrange(short a, short b, int res); |