From 5c16b28fb9437135f3d7f49c5b584cb220be3bbd Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 16 Jul 2013 08:46:49 +0200 Subject: [PATCH] Use only 12 bits for the temperature. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using all 16 bits for the temperature, the resulting values are clearly wrong in some cases. Most likely the upper 4 bits are used to store something else. Even with only 12 bits, the resulting temperature range (0-409.5°C) should still be more than sufficient. --- src/mares_iconhd_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mares_iconhd_parser.c b/src/mares_iconhd_parser.c index 0c8668a..28c5c92 100644 --- a/src/mares_iconhd_parser.c +++ b/src/mares_iconhd_parser.c @@ -237,7 +237,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Temperature (1/10 °C). - unsigned int temperature = array_uint16_le (data + offset + 2); + unsigned int temperature = array_uint16_le (data + offset + 2) & 0x0FFF; sample.temperature = temperature / 10.0; if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);