removed some errors in RESULT message. Wrong values
Limit tilt duration time to 127 steps (6.35sec) and avoid negative numbers
This commit is contained in:
stefanbode 2022-05-13 19:11:00 +02:00 committed by GitHub
parent 5680bc9cef
commit e501994919
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 17 deletions

View File

@ -126,6 +126,7 @@ struct SHUTTERGLOBAL {
#define SHT_DIV_ROUND(__A, __B) (((__A) + (__B)/2) / (__B))
void ShutterLogPos(uint32_t i)
{
char stemp2[10];
@ -1242,7 +1243,7 @@ void CmndShutterPosition(void)
ShutterReportPosition(true, index);
}
XdrvMailbox.index = index +1; // Fix random index for ShutterClose
if (XdrvMailbox.command)
strcpy( XdrvMailbox.command , D_CMND_SHUTTER_POSITION);
ResponseCmndIdxNumber((Settings->shutter_options[index] & 1) ? 100 - target_pos_percent : target_pos_percent);
} else {
ShutterReportPosition(true, MAX_SHUTTERS);
@ -1632,7 +1633,6 @@ void CmndShutterSetTilt(void)
}
XdrvMailbox.data[0] = '\0';
AddLog(LOG_LEVEL_INFO, PSTR("SHT: TiltTarget %d, payload %d"), Shutter[XdrvMailbox.index -1].tilt_target_pos,XdrvMailbox.payload);
ResponseCmndNumber(Shutter[XdrvMailbox.index -1].tilt_target_pos);
Shutter[XdrvMailbox.index -1].tiltmoving = 1;
CmndShutterPosition();
}
@ -1649,13 +1649,13 @@ void CmndShutterTiltConfig(void)
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);
}
// avoid negative runtime
Settings->shutter_tilt_config[2][XdrvMailbox.index -1] = Shutter[XdrvMailbox.index -1].tilt_config[2] = Shutter[XdrvMailbox.index -1].tilt_config[2] >= 0 ? Shutter[XdrvMailbox.index -1].tilt_config[2] : 127;
ShutterInit();
ResponseCmndIdxChar(XdrvMailbox.data);
} else {
char setting_chr[30] = "0";
snprintf_P(setting_chr, sizeof(setting_chr), PSTR("%d %d %d %d %d"), Shutter[XdrvMailbox.index -1].tilt_config[0], Shutter[XdrvMailbox.index -1].tilt_config[1],Shutter[XdrvMailbox.index -1].tilt_config[2],Shutter[XdrvMailbox.index -1].tilt_config[3],Shutter[XdrvMailbox.index -1].tilt_config[4]);
ResponseCmndIdxChar(setting_chr);
}
char setting_chr[30] = "0";
snprintf_P(setting_chr, sizeof(setting_chr), PSTR("%d %d %d %d %d"), XdrvMailbox.index -1,Shutter[XdrvMailbox.index -1].tilt_config[0], Shutter[XdrvMailbox.index -1].tilt_config[1],Shutter[XdrvMailbox.index -1].tilt_config[2],Shutter[XdrvMailbox.index -1].tilt_config[3],Shutter[XdrvMailbox.index -1].tilt_config[4]);
ResponseCmndIdxChar(setting_chr);
AddLog(LOG_LEVEL_INFO, PSTR("SHT: TiltConfig %d, min: %d, max %d, runtime %d, close_pos: %d, open_pos: %d"), XdrvMailbox.index ,Shutter[XdrvMailbox.index -1].tilt_config[0], Shutter[XdrvMailbox.index -1].tilt_config[1],Shutter[XdrvMailbox.index -1].tilt_config[2],Shutter[XdrvMailbox.index -1].tilt_config[3],Shutter[XdrvMailbox.index -1].tilt_config[4]);
}
}
@ -1663,13 +1663,12 @@ void CmndShutterTiltConfig(void)
void CmndShutterTiltIncDec(void)
{
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Change in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source );
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= TasmotaGlobal.shutters_present)) {
if (XdrvMailbox.data_len > 0) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= TasmotaGlobal.shutters_present) && XdrvMailbox.data_len > 0) {
XdrvMailbox.payload = Shutter[XdrvMailbox.index -1].tilt_target_pos+XdrvMailbox.payload;
CmndShutterSetTilt();
} else {
ResponseCmndIdxNumber(XdrvMailbox.payload);
}
}
ResponseCmndNumber(Shutter[XdrvMailbox.index -1].tilt_target_pos);
}
/*********************************************************************************************\