From 32909f20bee8eae6364ccee161c64df4cd148770 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 28 Nov 2023 16:01:47 +0100 Subject: [PATCH] Removed need for abs() --- Motor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Motor.cpp b/Motor.cpp index 8151321..ea6b55d 100644 --- a/Motor.cpp +++ b/Motor.cpp @@ -18,7 +18,7 @@ void Motor::SetSpeed(float targetSpeed) { bool Motor::Drive(float distance) { if (!this->driving) { this->startTime = time(NULL); - this->targetDistance = abs(distance); + this->targetDistance = distance >= 0 ? distance : -distance; this->driving = true; } double duration = difftime(time(NULL), this->startTime);