mirror of https://github.com/arendst/Tasmota.git
Precise temperature without pow
Implement TuyaAdjustedTemperature which takes precision to offset the integer value. Using TempRes parameter as these should align
This commit is contained in:
parent
caecc5cb33
commit
5e9fe677f3
|
@ -318,6 +318,23 @@ int StrCmpNoCase(char const *Str1, char const *Str2) // Compare case sensistive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float TuyaAdjustedTemperature(uint8_t packetValue, uint8_t res)
|
||||||
|
{
|
||||||
|
switch (res)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return packetValue/10;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return packetValue/100;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return packetValue/1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (float)packetValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Internal Functions
|
* Internal Functions
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -1295,7 +1312,7 @@ void TuyaSensorsShow(bool json)
|
||||||
|
|
||||||
GetTextIndexed(sname, sizeof(sname), (sensor-71), kTuyaSensors);
|
GetTextIndexed(sname, sizeof(sname), (sensor-71), kTuyaSensors);
|
||||||
ResponseAppend_P(PSTR("\"%s\":%s"), sname,
|
ResponseAppend_P(PSTR("\"%s\":%s"), sname,
|
||||||
(Tuya.SensorsValid[sensor-71] ? dtostrfd((float)Tuya.Sensors[sensor-71] / pow(10, res), res, tempval) : PSTR("null")));
|
(Tuya.SensorsValid[sensor-71] ? dtostrfd(TuyaAdjustedTemperature(Tuya.Sensors[sensor-71], res), res, tempval) : PSTR("null")));
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
|
@ -1303,11 +1320,11 @@ void TuyaSensorsShow(bool json)
|
||||||
if (TuyaGetDpId(sensor) != 0) {
|
if (TuyaGetDpId(sensor) != 0) {
|
||||||
switch (sensor) {
|
switch (sensor) {
|
||||||
case 71:
|
case 71:
|
||||||
WSContentSend_Temp("", (float)Tuya.Sensors[0] / pow(10, Settings.flag2.temperature_resolution));
|
WSContentSend_Temp("", TuyaAdjustedTemperature(Tuya.Sensors[0], Settings.flag2.temperature_resolution));
|
||||||
break;
|
break;
|
||||||
case 72:
|
case 72:
|
||||||
WSContentSend_PD(PSTR("{s}" D_TEMPERATURE " Set{m}%s " D_UNIT_DEGREE "%c{e}"),
|
WSContentSend_PD(PSTR("{s}" D_TEMPERATURE " Set{m}%s " D_UNIT_DEGREE "%c{e}"),
|
||||||
dtostrfd((float)Tuya.Sensors[1] / pow(10, Settings.flag2.temperature_resolution), Settings.flag2.temperature_resolution, tempval), TempUnit());
|
dtostrfd(TuyaAdjustedTemperature(Tuya.Sensors[1], Settings.flag2.temperature_resolution), Settings.flag2.temperature_resolution, tempval), TempUnit());
|
||||||
break;
|
break;
|
||||||
case 73:
|
case 73:
|
||||||
WSContentSend_PD(HTTP_SNS_HUM, "", dtostrfd(Tuya.Sensors[2], Settings.flag2.temperature_resolution, tempval));
|
WSContentSend_PD(HTTP_SNS_HUM, "", dtostrfd(Tuya.Sensors[2], Settings.flag2.temperature_resolution, tempval));
|
||||||
|
|
Loading…
Reference in New Issue