Check for division by zero

This commit is contained in:
perfrankling 2025-02-02 23:14:14 +01:00 committed by GitHub
parent 4a72c6badc
commit f3e7dd5a9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3009,10 +3009,10 @@ void SomfyShade::moveToTiltTarget(float target) {
uint8_t step = 1;
if(target < this->currentTiltPos){
cmd = somfy_commands::StepUp; //Converted to somfy_commands::Up in sendCommand for non-80-bits shades
step = (this->currentTiltPos - target) * this->tiltTime / this->stepSize / 100;
if (this->stepSize > 0) step = (this->currentTiltPos - target) * this->tiltTime / this->stepSize / 100;
} else if(target > this->currentTiltPos){
cmd = somfy_commands::StepDown; //Converted to somfy_commands::Down in sendCommand for non-80-bits shades
step = (target - this->currentTiltPos) * this->tiltTime / this->stepSize / 100;
if (this->stepSize > 0) step = (target - this->currentTiltPos) * this->tiltTime / this->stepSize / 100;
}
if(target >= 0.0f && target <= 100.0f) {
// Only send a command if the lift is not moving.