From f3e7dd5a9e9fd6aac841c38cbd2e94589a17ccf1 Mon Sep 17 00:00:00 2001 From: perfrankling <78272942+perfrankling@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:14:14 +0100 Subject: [PATCH] Check for division by zero --- Somfy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Somfy.cpp b/Somfy.cpp index 9024478..996f527 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -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.