Skip to content

Commit

Permalink
Fix incorrect handling of negative temperatures in ambient_weather.c (m…
Browse files Browse the repository at this point in the history
…erbanan#376)

* Fix incorrect handling of negative temperatures in ambient_weather.c

As described in issue merbanan#375

* Use int instead of uint32_t as suggested by zuckschwerdt.
  • Loading branch information
meadowface authored and merbanan committed May 15, 2016
1 parent bf4f9b4 commit 76635e9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/devices/ambient_weather.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 76635e9

Please sign in to comment.