mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-26 07:47:15 +00:00
* fix shutterposition 0,-45 does not keep tilt allow , on different config settings * fix shutterposition 0,-45 does not maintain tilt allow , on different config settings.
This commit is contained in:
parent
dab1a5302e
commit
b83516970f
@ -1419,7 +1419,7 @@ void CmndShutterButton(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < (1+4+4+1); str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < (1+4+4+1); str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
int field = -1;
|
int field = -1;
|
||||||
int tilt = -128;
|
int tilt = -128;
|
||||||
int pos_incrdecr = 0;
|
int pos_incrdecr = 0;
|
||||||
@ -1647,7 +1647,7 @@ void CmndShutterCalibration(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) + 1];
|
char data_copy[strlen(XdrvMailbox.data) + 1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
int field = atoi(str);
|
int field = atoi(str);
|
||||||
// The fields in a data string can only range from 1-30000.
|
// The fields in a data string can only range from 1-30000.
|
||||||
// and following value must be higher than previous one
|
// and following value must be higher than previous one
|
||||||
@ -1851,12 +1851,6 @@ void CmndShutterPosition(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//override tiltposition if explicit set (shutterbutton)
|
|
||||||
if (Shutter[index].tilt_target_pos_override != -128) {
|
|
||||||
Shutter[index].tilt_target_pos = tmin(tmax( Shutter[index].tilt_config[0],Shutter[index].tilt_target_pos_override ), Shutter[index].tilt_config[1]);
|
|
||||||
Shutter[index].tilt_target_pos_override = -128;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
||||||
target_pos_percent = ((ShutterSettings.shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source) // 1
|
target_pos_percent = ((ShutterSettings.shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source) // 1
|
||||||
&& (SRC_SERIAL != TasmotaGlobal.last_source) // 6
|
&& (SRC_SERIAL != TasmotaGlobal.last_source) // 6
|
||||||
@ -1868,6 +1862,12 @@ void CmndShutterPosition(void)
|
|||||||
if (target_pos_percent == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];}
|
if (target_pos_percent == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];}
|
||||||
if (target_pos_percent == 100 && ShutterRealToPercentPosition(Shutter[index].real_position, index) < 100) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[3];}
|
if (target_pos_percent == 100 && ShutterRealToPercentPosition(Shutter[index].real_position, index) < 100) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[3];}
|
||||||
|
|
||||||
|
//override tiltposition if explicit set (shutterbutton)
|
||||||
|
if (Shutter[index].tilt_target_pos_override != -128) {
|
||||||
|
Shutter[index].tilt_target_pos = tmin(tmax( Shutter[index].tilt_config[0],Shutter[index].tilt_target_pos_override ), Shutter[index].tilt_config[1]);
|
||||||
|
Shutter[index].tilt_target_pos_override = -128;
|
||||||
|
}
|
||||||
|
|
||||||
if (XdrvMailbox.payload != -99) {
|
if (XdrvMailbox.payload != -99) {
|
||||||
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
|
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
|
||||||
//Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1);
|
//Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1);
|
||||||
@ -1966,7 +1966,7 @@ void CmndShutterPwmRange(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 2; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 2; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
uint16_t field = atoi(str);
|
uint16_t field = atoi(str);
|
||||||
// The fields in a data string can only range from 1-30000.
|
// The fields in a data string can only range from 1-30000.
|
||||||
// and following value must be higher than previous one
|
// and following value must be higher than previous one
|
||||||
@ -2224,7 +2224,7 @@ void CmndShutterTiltConfig(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 6; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 6; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
Shutter[XdrvMailbox.index -1].tilt_config[i] = ShutterSettings.shutter_tilt_config[i][XdrvMailbox.index -1] = atoi(str);
|
Shutter[XdrvMailbox.index -1].tilt_config[i] = ShutterSettings.shutter_tilt_config[i][XdrvMailbox.index -1] = atoi(str);
|
||||||
}
|
}
|
||||||
// avoid negative runtime
|
// avoid negative runtime
|
||||||
|
@ -438,7 +438,7 @@ void ShutterInit(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d min realpos_chg: %d, min tilt_chg %d"), i+1, Shutter[i].min_realPositionChange, Shutter[i].min_TiltChange);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d min realpos_chg: %d, min tilt_chg %d"), i+1, Shutter[i].min_realPositionChange, Shutter[i].min_TiltChange);
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Openvel %d, Closevel: %d"), i+1, ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Openvel %d, Closevel: %d"), i+1, ShutterGlobal.open_velocity_max, Shutter[i].close_velocity_max);
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init. Pos %d, Inv %d, Locked %d, Endstop enab %d, webButt inv %d, Motordel: %d"),
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init. Pos %d, Inv %d, Locked %d, Endstop enab %d, webButt inv %d, Motordel: %d"),
|
||||||
i+1, Shutter[i].real_position,
|
i+1, Shutter[i].real_position,
|
||||||
(Settings->shutter_options[i] & 1) ? 1 : 0, (Settings->shutter_options[i] & 2) ? 1 : 0, (Settings->shutter_options[i] & 4) ? 1 : 0, (Settings->shutter_options[i] & 8) ? 1 : 0, Shutter[i].motordelay);
|
(Settings->shutter_options[i] & 1) ? 1 : 0, (Settings->shutter_options[i] & 2) ? 1 : 0, (Settings->shutter_options[i] & 4) ? 1 : 0, (Settings->shutter_options[i] & 8) ? 1 : 0, Shutter[i].motordelay);
|
||||||
@ -1323,12 +1323,6 @@ void CmndShutterPosition(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// manual override of tiltposition
|
|
||||||
if (Shutter[index].tilt_target_pos_override != -128) {
|
|
||||||
Shutter[index].tilt_target_pos = tmin(tmax( Shutter[index].tilt_config[0],Shutter[index].tilt_target_pos_override ), Shutter[index].tilt_config[1]);
|
|
||||||
Shutter[index].tilt_target_pos_override = -128;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
|
||||||
target_pos_percent = ((Settings->shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source)
|
target_pos_percent = ((Settings->shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source)
|
||||||
&& (SRC_SERIAL != TasmotaGlobal.last_source)
|
&& (SRC_SERIAL != TasmotaGlobal.last_source)
|
||||||
@ -1340,6 +1334,13 @@ void CmndShutterPosition(void)
|
|||||||
if (target_pos_percent == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];}
|
if (target_pos_percent == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];}
|
||||||
if (target_pos_percent == 100 && ShutterRealToPercentPosition(Shutter[index].real_position, index) < 100) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[3];}
|
if (target_pos_percent == 100 && ShutterRealToPercentPosition(Shutter[index].real_position, index) < 100) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[3];}
|
||||||
|
|
||||||
|
// manual override of tiltposition
|
||||||
|
if (Shutter[index].tilt_target_pos_override != -128) {
|
||||||
|
Shutter[index].tilt_target_pos = tmin(tmax( Shutter[index].tilt_config[0],Shutter[index].tilt_target_pos_override ), Shutter[index].tilt_config[1]);
|
||||||
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Override tilt set: %d --> %d"),Shutter[index].tilt_target_pos_override, Shutter[index].tilt_target_pos);
|
||||||
|
Shutter[index].tilt_target_pos_override = -128;
|
||||||
|
}
|
||||||
|
|
||||||
if (XdrvMailbox.payload != -99) {
|
if (XdrvMailbox.payload != -99) {
|
||||||
//target_pos_percent = (Settings->shutter_options[index] & 1) ? 100 - target_pos_percent : target_pos_percent;
|
//target_pos_percent = (Settings->shutter_options[index] & 1) ? 100 - target_pos_percent : target_pos_percent;
|
||||||
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
|
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
|
||||||
@ -1727,7 +1728,7 @@ void CmndShutterPwmRange(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 2; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 2; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
uint16_t field = atoi(str);
|
uint16_t field = atoi(str);
|
||||||
// The fields in a data string can only range from 1-30000.
|
// The fields in a data string can only range from 1-30000.
|
||||||
// and following value must be higher than previous one
|
// and following value must be higher than previous one
|
||||||
@ -1757,7 +1758,7 @@ void CmndShutterCalibration(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 5; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
int field = atoi(str);
|
int field = atoi(str);
|
||||||
// The fields in a data string can only range from 1-30000.
|
// The fields in a data string can only range from 1-30000.
|
||||||
// and following value must be higher than previous one
|
// and following value must be higher than previous one
|
||||||
@ -1842,7 +1843,7 @@ void CmndShutterTiltConfig(void)
|
|||||||
char data_copy[strlen(XdrvMailbox.data) +1];
|
char data_copy[strlen(XdrvMailbox.data) +1];
|
||||||
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
strncpy(data_copy, XdrvMailbox.data, sizeof(data_copy)); // Duplicate data as strtok_r will modify it.
|
||||||
// Loop through the data string, splitting on ' ' seperators.
|
// Loop through the data string, splitting on ' ' seperators.
|
||||||
for (char *str = strtok_r(data_copy, " ", &str_ptr); str && i < 6; str = strtok_r(nullptr, " ", &str_ptr), i++) {
|
for (char *str = strtok_r(data_copy, " ,", &str_ptr); str && i < 6; str = strtok_r(nullptr, " ,", &str_ptr), i++) {
|
||||||
Shutter[XdrvMailbox.index -1].tilt_config[i] = Settings->shutter_tilt_config[i][XdrvMailbox.index -1] = atoi(str);
|
Shutter[XdrvMailbox.index -1].tilt_config[i] = Settings->shutter_tilt_config[i][XdrvMailbox.index -1] = atoi(str);
|
||||||
}
|
}
|
||||||
// avoid negative runtime
|
// avoid negative runtime
|
||||||
|
Loading…
x
Reference in New Issue
Block a user