From 392990044b302f0190a5d8eaebd7912d53e95cd3 Mon Sep 17 00:00:00 2001
From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de>
Date: Fri, 14 Oct 2016 13:37:01 +0200
Subject: [PATCH] Reopen issue #34 (previous fix was buggy)

---
 source/Motor.m | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/source/Motor.m b/source/Motor.m
index bfc6abf..ba7e78d 100755
--- a/source/Motor.m
+++ b/source/Motor.m
@@ -599,19 +599,23 @@ classdef Motor < MaskedHandle & dynamicprops
         function set.speedRegulation(motor, speedRegulation)
             if ~isBool(speedRegulation)
                 error('Motor::set.speedRegulation: Given parameter is not a bool.');
-            elseif motor.connectedToBrick && motor.physicalMotorConnected && ...
-                    motor.currentSpeed ~= 0
-                error(['Motor::set.speedRegulation: Cannot change speed regulation while ', ...
-                       'is motor is moving.']);
+%             elseif motor.connectedToBrick && motor.physicalMotorConnected
+%                 pause(0.5);
+%                 if motor.currentSpeed ~= 0
+%                     error(['Motor::set.speedRegulation: Cannot change speed regulation while ', ...
+%                         'is motor is moving.']);
+%                 end
             end
             
-            if ~isempty(motor.speedRegulation) && speedRegulation ~= motor.speedRegulation
+            speedRegulation = str2bool(speedRegulation);
+            
+            if ~isempty(motor.speedRegulation) && (speedRegulation ~= motor.speedRegulation)
                 if motor.sendPowerOnSet
                     motor.sendOnStart = bitset(motor.sendOnStart, SendOnStart.Power, 1);
                 end
             end
             
-            motor.speedRegulation = str2bool(speedRegulation);
+            motor.speedRegulation = speedRegulation;
         end
         
         function set.smoothStart(motor, steps)
-- 
GitLab