Add command TempOffset -12.6 .. 12.6

Add command TempOffset -12.6 .. 12.6 to set global temperature sensor offset (#6958)
This commit is contained in:
Theo Arends 2019-11-18 12:15:49 +01:00
parent 95673103dd
commit 14f6f6f22b
3 changed files with 18 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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