Comments (11)
that's interesting and unexpected! The change from doubles to floats cause these rounding issues? (I cannot check this because I do not have any devices with these kind of values)
from ithowifi.
Yep sure it can as there are some values which can't be exactly represented as float (or as double)
Only when printing a double, the print function often stops at less decimals than the resolution you can store in a double.
I think the default is 10 decimals for most string conversion functions if no nr of decimals is set.
Given you can store about 18 decimal values in a double, you need to have double values of over 1E9 (and some binary repeating fraction) before you ever encounter these issues.
With floats you can only store ~6 decimals (slightly more).
So you must do the formatting to N decimals yourself.
from ithowifi.
The problem seems to arise because ArduinoJson uses doubles internally. Set ‘’ARDUINOJSON_USE_DOUBLE’ to 0
bblanchon/ArduinoJson#1724 (comment)
from ithowifi.
Ok, cool stuff, I vaguely remembered something so I went to my release notes and found this:
"fix: correct rounding issues since ArduinoJSON library update"
history repeating itself but then with a different part of the code...
Ok, I would propose the following:
-
to keep the structs ithoDeviceStatus and ithoDeviceMeasurements to floats and round the values using the existing round() function to 2 (?) decimals?
That saves 4 bytes memory per instance of the struct, which on some devies with a lot of status labels can make a substantial difference.
to change these lines:
ithowifi/software/NRG_itho_wifi/main/IthoSystem.cpp
Lines 301 to 303 in 8ce7b87
to doubles again. These would bring back the settings values to the correct values again.
from ithowifi.
Statusvalues I could just round in HomeAssistant, but in settings it is quite annoying:
from ithowifi.
Also if you have similar code like this, you should add a f
next to the "magic" value.
float max = 0.0f;
Or else there will be an extra double to float conversion in the code. (not always as the compiler sometimes can detect this behavior and optimize for it)
from ithowifi.
I just tried master 6f5a113, sadly, it does not work as expected:
from ithowifi.
Thanks for trying! Will look into further
from ithowifi.
Ok, cool stuff, I vaguely remembered something so I went to my release notes and found this: "fix: correct rounding issues since ArduinoJSON library update"
history repeating itself but then with a different part of the code...
Ok, I would propose the following:
- to keep the structs ithoDeviceStatus and ithoDeviceMeasurements to floats and round the values using the existing round() function to 2 (?) decimals?
That saves 4 bytes memory per instance of the struct, which on some devies with a lot of status labels can make a substantial difference.to change these lines:
ithowifi/software/NRG_itho_wifi/main/IthoSystem.cpp
Lines 301 to 303 in 8ce7b87
to doubles again. These would bring back the settings values to the correct values again.
my oh my @tomkooij, its even worse, sorry:
#142 (comment)
from ithowifi.
I just tried master 6f5a113, sadly, it does not work as expected:
and I think I now what causes it:
ithowifi/software/NRG_itho_wifi/main/generic_functions.cpp
Lines 463 to 466 in 6f5a113
this has to be changed to double again also of course!!
from ithowifi.
Related Issues (20)
- Monitor only RF Devices not in remotesinfo HOT 5
- [Feature] Add OpenApi Spec / SwaggerUI to document api HOT 1
- Virtual remotes update remote broken HOT 2
- [Request] Ability to change through mqqt the default speed settings HOT 2
- Ventilation setpoint never goes below 30% HOT 2
- [Feature] Add fan/ventilation percentage to MQTT itho/ithostatus messages HOT 2
- Fan not keeping set speed HOT 14
- Request; turn off unit from HA HOT 2
- [Feature] autospeed relative to humidity
- HA: MQTT - TypeError: unsupported operand type(s) HOT 3
- [Request] Amber heat pump support HOT 6
- api.html?get=currentspeed not updating HOT 5
- [Request] AutoTemp fw 13 support HOT 7
- Minor typo in log message HOT 1
- Error on updating System Settings HOT 6
- Cannot switch off AP mode HOT 1
- long integer truncated in status JSON HOT 19
- [Feature Request] Support for WPU Version 41 HOT 32
- Virtual remote question HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ithowifi.