Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

Revision:
12:8295c02d740f
Parent:
7:a80cb6b06320
Child:
18:1c9dc6caab9d
--- a/arm.cpp	Wed Nov 02 16:29:13 2016 +0000
+++ b/arm.cpp	Thu Nov 03 13:08:44 2016 +0000
@@ -6,10 +6,13 @@
 */
 
 // Create an arm
-Arm::Arm(float initialLength, PinName motorPWM, PinName motorDir, PinName encoderPin1, PinName encoderPin2): motorControl(motorPWM), 
-                                                                                                             motorDirection(motorDir),
-                                                                                                             qei(encoderPin1, encoderPin2, NC, pulsesPerRevolution) {
+Arm::Arm(float initialLength, float maxVelocity, PinName motorPWM, PinName motorDir, PinName encoderPin1, PinName encoderPin2)
+: motorControl(motorPWM)
+, motorDirection(motorDir)
+, qei(encoderPin1, encoderPin2, NC, pulsesPerRevolution)
+{
     length = initialLength;
+    maxAllowedVelocity = maxVelocity;
     velocity = 0;
     encoderVelocity = 0;
     motorDirection = clockwise;
@@ -36,11 +39,11 @@
     // Counterclockwise rotation
     if (referenceVelocity < 0) {
         motorDirection = counterClockwise;
-        velocity = (referenceVelocity < -1 * maxVelocity)? -1 * maxVelocity:referenceVelocity;
+        velocity = (referenceVelocity < -1 * maxAllowedVelocity)? -1 * maxAllowedVelocity:referenceVelocity;
     // Clockwise rotation
     } else {
         motorDirection = clockwise;
-        velocity = (referenceVelocity > maxVelocity)? maxVelocity:referenceVelocity;
+        velocity = (referenceVelocity > maxAllowedVelocity)? maxAllowedVelocity:referenceVelocity;
     }
     // Output to motor
     setMotor(velocity/motorGain);