Change venetian blind tilt behavior at 0% and 100%

The original target tilt is maintained for the next operation. Anyhow the shutter stops at end position without any tilt change
This commit is contained in:
stefanbode 2021-11-26 09:05:01 +01:00 committed by GitHub
parent 9f28529d37
commit e55025295f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 14 deletions

View File

@ -486,11 +486,10 @@ void ShutterPowerOff(uint8_t i)
TasmotaGlobal.rules_flag.shutter_moved = 1;
switch (Shutter[i].switch_mode) {
case SHT_SWITCH:
if ((1 << (Settings->shutter_startrelay[i]-1)) & TasmotaGlobal.power) {
ExecuteCommandPowerShutter(Settings->shutter_startrelay[i], 0, SRC_SHUTTER);
for (int8_t k=0;k<2;k++) {
if ((1 << (Settings->shutter_startrelay[i]+k-1)) & TasmotaGlobal.power) {
ExecuteCommandPowerShutter(Settings->shutter_startrelay[i]+k, 0, SRC_SHUTTER);
}
if ((1 << (Settings->shutter_startrelay[i])) & TasmotaGlobal.power) {
ExecuteCommandPowerShutter(Settings->shutter_startrelay[i]+1, 0, SRC_SHUTTER);
}
break;
case SHT_PULSE:
@ -516,11 +515,8 @@ void ShutterPowerOff(uint8_t i)
char scmnd[20];
#ifdef SHUTTER_CLEAR_PWM_ONSTOP
// free the PWM servo lock on stop.
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_PWM "%d 0" ), i+1);
#else
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_PWM "%d %d" ), i+1,Shutter[i].pwm_value);
analogWrite(Pin(GPIO_PWM1, i), 0);
#endif
ExecuteCommand(scmnd, SRC_BUTTON);
break;
}
Settings->save_data = savedata_original;
@ -556,11 +552,9 @@ void ShutterUpdatePosition(void)
Settings->shutter_position[i] = ShutterRealToPercentPosition(Shutter[i].real_position, i);
Shutter[i].start_position = Shutter[i].real_position;
// manage venetian blinds
Shutter[i].tilt_target_pos = Settings->shutter_position[i] == 0 ? Shutter[i].tilt_config[0] : Shutter[i].tilt_target_pos;
Shutter[i].tilt_target_pos = Settings->shutter_position[i] == 100 ? Shutter[i].tilt_config[1] : Shutter[i].tilt_target_pos;
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Pre: Tilt not match %d -> %d, moving: %d"),Shutter[i].tilt_real_pos,Shutter[i].tilt_target_pos,Shutter[i].tiltmoving);
if (abs(Shutter[i].tilt_real_pos - Shutter[i].tilt_target_pos) > Shutter[i].min_TiltChange && Shutter[i].tiltmoving == 0) {
if (abs(Shutter[i].tilt_real_pos - Shutter[i].tilt_target_pos) > Shutter[i].min_TiltChange && Shutter[i].tiltmoving == 0
&& Settings->shutter_position[i] > 0 && Settings->shutter_position[i] < 100) {
AddLog(LOG_LEVEL_INFO, PSTR("SHT: Tilt not match %d -> %d"),Shutter[i].tilt_real_pos,Shutter[i].tilt_target_pos);
char databuf[1] = "";
XdrvMailbox.data = databuf;