From ad82a02360515028f2566d3b71c74aa903caee01 Mon Sep 17 00:00:00 2001 From: aquaticus <1891400+aquaticus@users.noreply.github.com> Date: Sun, 16 Sep 2018 00:36:35 +0300 Subject: [PATCH] Added support for bad wheater. Negative temperature properly handled. (#6) --- digoo.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/digoo.cpp b/digoo.cpp index 6db2cc6..9df4a8d 100644 --- a/digoo.cpp +++ b/digoo.cpp @@ -22,7 +22,7 @@ digoo::digoo() { packet_size = 37; - END_PACKET = 3000; + END_PACKET = 3000; MIN_PACKET = 650; } @@ -43,7 +43,9 @@ uint8_t digoo::getChannel(uint64_t packet) { } float digoo::getTemperature(uint64_t packet) { - float temperature = float((packet >> 12) & 0xFFF) / 10; + int16_t t = packet >> 12 & 0x0FFF; + t = 0x0800 & t ? 0xF000 | t : t; + float temperature = float(t) / 10; return temperature; } @@ -87,4 +89,3 @@ void digoo::processPacket() { } #endif } -