From 14f6f6f22b11bc816b7807699b2e5d49d2fd5702 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 18 Nov 2019 12:15:49 +0100 Subject: [PATCH] Add command TempOffset -12.6 .. 12.6 Add command TempOffset -12.6 .. 12.6 to set global temperature sensor offset (#6958) --- tasmota/_changelog.ino | 1 + tasmota/settings.h | 5 +++-- tasmota/support_command.ino | 21 ++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tasmota/_changelog.ino b/tasmota/_changelog.ino index 52fef550d..c1423443d 100644 --- a/tasmota/_changelog.ino +++ b/tasmota/_changelog.ino @@ -1,6 +1,7 @@ /*********************************************************************************************\ * 7.0.0.5 20191118 * Fix boot loop regression + * Add command TempOffset -12.6 .. 12.6 to set global temperature sensor offset (#6958) * * 7.0.0.4 20191108 * Add command WifiPower 0 .. 20.5 to set Wifi Output Power which will be default set to 17dBm diff --git a/tasmota/settings.h b/tasmota/settings.h index 7e557e15e..876e0bde5 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -434,8 +434,9 @@ struct SYSCFG { uint32_t deepsleep; // E94 uint16_t energy_power_delta; // E98 uint8_t shutter_motordelay[MAX_SHUTTERS]; // E9A - int8_t temp_comp; - uint8_t free_e9e[1]; // E9E + int8_t temp_comp; // E9E + + uint8_t free_e9f[1]; // E9F uint8_t web_color2[2][3]; // EA0 - Needs to be on integer / 3 distance from web_color diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 11d51f610..7156e6ed8 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -57,6 +57,13 @@ void ResponseCmndNumber(int value) Response_P(S_JSON_COMMAND_NVALUE, XdrvMailbox.command, value); } +void ResponseCmndFloat(float value, uint32_t decimals) +{ + char stemp1[TOPSZ]; + dtostrfd(value, decimals, stemp1); + Response_P(S_JSON_COMMAND_XVALUE, XdrvMailbox.command, stemp1); // Return float value without quotes +} + void ResponseCmndIdxNumber(int value) { Response_P(S_JSON_COMMAND_INDEX_NVALUE, XdrvMailbox.command, XdrvMailbox.index, value); @@ -498,13 +505,15 @@ void CmndState(void) void CmndTempOffset(void) { - if ((XdrvMailbox.payload > -127) && (XdrvMailbox.payload < 127) && (XdrvMailbox.data_len > 0)) { - Settings.temp_comp = XdrvMailbox.payload; + if (XdrvMailbox.data_len > 0) { + int value = (int)(CharToFloat(XdrvMailbox.data) * 10); + if ((value > -127) && (value < 127)) { + Settings.temp_comp = value; + } } - ResponseCmndNumber(Settings.temp_comp); + ResponseCmndFloat((float)(Settings.temp_comp) / 10, 1); } - void CmndSleep(void) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 251)) { @@ -1549,9 +1558,7 @@ void CmndWifiPower(void) } WifiSetOutputPower(); } - char stemp1[TOPSZ]; - dtostrfd((float)(Settings.wifi_output_power) / 10, 1, stemp1); - Response_P(S_JSON_COMMAND_XVALUE, XdrvMailbox.command, stemp1); // Return float value without quotes + ResponseCmndFloat((float)(Settings.wifi_output_power) / 10, 1); } #ifdef USE_I2C