Avoid ghost switching in position 0 and 100

confirming the position and setting the tilt in 0 and 100% causes ghost switching of the relays. #16435
This commit is contained in:
stefanbode 2022-12-06 16:27:34 +01:00 committed by GitHub
parent 9d9d46db9c
commit 35475d9353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1212,8 +1212,8 @@ void CmndShutterPosition(void)
}
// if position is either 0 or 100 reset the tilt to avoid tilt moving at the end
if (XdrvMailbox.payload == 0) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[4];}
if (XdrvMailbox.payload == 100) {Shutter[index].tilt_target_pos = Shutter[index].tilt_config[3];}
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];}
int8_t target_pos_percent = (XdrvMailbox.payload < 0) ? (XdrvMailbox.payload == -99 ? ShutterRealToPercentPosition(Shutter[index].real_position, index) : 0) : ((XdrvMailbox.payload > 100) ? 100 : XdrvMailbox.payload);
// webgui still send also on inverted shutter the native position.