From 76635e90ec82368ca4b179daccda0753a14f0e3c Mon Sep 17 00:00:00 2001 From: Marc Meadows Date: Sat, 14 May 2016 20:27:51 -0400 Subject: [PATCH] Fix incorrect handling of negative temperatures in ambient_weather.c (#376) * Fix incorrect handling of negative temperatures in ambient_weather.c As described in issue #375 * Use int instead of uint32_t as suggested by zuckschwerdt. --- src/devices/ambient_weather.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/devices/ambient_weather.c b/src/devices/ambient_weather.c index c9f0db808..647d33556 100644 --- a/src/devices/ambient_weather.c +++ b/src/devices/ambient_weather.c @@ -5,13 +5,10 @@ static float get_temperature (uint8_t * msg) { - uint32_t temp_f = msg[4] & 0x7f; + int temp_f = msg[4]; temp_f <<= 4; temp_f |= ((msg[5] & 0xf0) >> 4); temp_f -= 400; - if (msg[4] & 0x80) { - temp_f = -temp_f; - } return (temp_f / 10.0f); }