From d1e85635e3bdc48fbd53ae45995e134385cc2575 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Thu, 24 Aug 2023 12:39:42 +0200 Subject: [PATCH] fix inverted shutter inconsistencies (#19374) * inverted shutter fix on overflow * fix inverted_shutter > 9 fix on inverted shutter at esp32. fix tilt behavior on inverted shutter * fix tilt behavior on inverted shutter --- .../xdrv_27_esp32_shutter.ino | 17 +++++++++-------- tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino | 9 +++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino index 7d88e10e4..ae6f9603c 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino @@ -1506,10 +1506,6 @@ void CmndShutterPosition(void) } - // if position is either 0 or 100 reset the tilt to avoid tilt moving at the end - if (XdrvMailbox.payload == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];} - if (XdrvMailbox.payload == 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]); @@ -1517,10 +1513,15 @@ void CmndShutterPosition(void) } 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) - || (SRC_SERIAL != TasmotaGlobal.last_source) - || (SRC_WEBCOMMAND != TasmotaGlobal.last_source) - )) ? 100 - target_pos_percent : target_pos_percent; + target_pos_percent = ((ShutterSettings.shutter_options[index] & 1) && ((SRC_MQTT != TasmotaGlobal.last_source) // 1 + && (SRC_SERIAL != TasmotaGlobal.last_source) // 6 + && (SRC_WEBGUI != TasmotaGlobal.last_source) // 7 + && (SRC_WEBCOMMAND != TasmotaGlobal.last_source) // 8 + )) ? 100 - target_pos_percent : target_pos_percent; + + // if position is either 0 or 100 reset the tilt to avoid tilt moving at the end + 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 (XdrvMailbox.payload != -99) { Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino index 29ffe43f4..c82e62ff2 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino @@ -1328,10 +1328,6 @@ void CmndShutterPosition(void) } } - // if position is either 0 or 100 reset the tilt to avoid tilt moving at the end - if (XdrvMailbox.payload == 0 && ShutterRealToPercentPosition(Shutter[index].real_position, index) > 0 ) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];} - if (XdrvMailbox.payload == 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]); @@ -1344,6 +1340,11 @@ void CmndShutterPosition(void) && (SRC_WEBGUI != TasmotaGlobal.last_source) && (SRC_WEBCOMMAND != TasmotaGlobal.last_source) )) ? 100 - target_pos_percent : target_pos_percent; + + // if position is either 0 or 100 reset the tilt to avoid tilt moving at the end + 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 (XdrvMailbox.payload != -99) { //target_pos_percent = (Settings->shutter_options[index] & 1) ? 100 - target_pos_percent : target_pos_percent; Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);