From 2a788cb2d0db66e2b68357c78a42ca1ed613e687 Mon Sep 17 00:00:00 2001 From: Ray Jones Date: Sun, 4 Aug 2019 08:19:59 +1000 Subject: [PATCH] Fixed rounding issue of TempCurrent in JSON data, always 0.1 low --- src/Utility/BTC_JSON.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Utility/BTC_JSON.cpp b/src/Utility/BTC_JSON.cpp index 78d6ac9..e65f3bc 100644 --- a/src/Utility/BTC_JSON.cpp +++ b/src/Utility/BTC_JSON.cpp @@ -325,7 +325,9 @@ bool makeJSONString(CModerator& moderator, char* opStr, int len) bool bSend = false; // reset should send flag float tidyTemp = getTemperatureSensor(); - tidyTemp = int(tidyTemp * 10) * 0.1f; // round to 0.1 resolution + DebugPort.printf("tidyTemp=%.1f ", tidyTemp); + tidyTemp = int(tidyTemp * 10 + 0.5) * 0.1f; // round to 0.1 resolution + DebugPort.printf("tidyTemp(rounded)=%.1f\r\n", tidyTemp); if(tidyTemp > -80) { bSend |= moderator.addJson("TempCurrent", tidyTemp, root); }