mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-13 08:56:38 +02:00
added round to 3 decimals for API JSON (reduced transmitted length)
This commit is contained in:
parent
6e39b779f4
commit
50bfbf8a38
2 changed files with 6 additions and 2 deletions
|
@ -281,7 +281,7 @@ void webApi::getLive(JsonObject obj) {
|
||||||
obj2[F("ch_names")][0] = "AC";
|
obj2[F("ch_names")][0] = "AC";
|
||||||
for (uint8_t fld = 0; fld < 11; fld++) {
|
for (uint8_t fld = 0; fld < 11; fld++) {
|
||||||
pos = (iv->getPosByChFld(CH0, list[fld], rec));
|
pos = (iv->getPosByChFld(CH0, list[fld], rec));
|
||||||
ch0[fld] = (0xff != pos) ? iv->getValue(pos, rec) : 0.0;
|
ch0[fld] = (0xff != pos) ? round3(iv->getValue(pos, rec)) : 0.0;
|
||||||
obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : F("n/a");
|
obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : F("n/a");
|
||||||
obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : F("n/a");
|
obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : F("n/a");
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ void webApi::getLive(JsonObject obj) {
|
||||||
case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break;
|
case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break;
|
||||||
case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break;
|
case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break;
|
||||||
}
|
}
|
||||||
cur[k] = (0xff != pos) ? iv->getValue(pos, rec) : 0.0;
|
cur[k] = (0xff != pos) ? round3(iv->getValue(pos, rec)) : 0.0;
|
||||||
if(1 == j) {
|
if(1 == j) {
|
||||||
obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : F("n/a");
|
obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : F("n/a");
|
||||||
obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : F("n/a");
|
obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : F("n/a");
|
||||||
|
|
|
@ -41,6 +41,10 @@ class webApi {
|
||||||
|
|
||||||
Inverter<> *getInverter(DynamicJsonDocument jsonIn, JsonObject jsonOut);
|
Inverter<> *getInverter(DynamicJsonDocument jsonIn, JsonObject jsonOut);
|
||||||
|
|
||||||
|
double round3(double value) {
|
||||||
|
return (int)(value * 1000 + 0.5) / 1000.0;
|
||||||
|
}
|
||||||
|
|
||||||
AsyncWebServer *mSrv;
|
AsyncWebServer *mSrv;
|
||||||
app *mApp;
|
app *mApp;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue