A class for driving a stepper motor via driver with indexer.

Dependents:   StepperTest

Revision:
2:70f593d34039
Parent:
1:9888802e71b9
--- a/StepperDriver.cpp	Fri Dec 02 08:35:20 2016 +0000
+++ b/StepperDriver.cpp	Fri Dec 02 15:56:53 2016 +0000
@@ -5,8 +5,8 @@
     currentPosition = previousPosition = desiredPosition = 0;
     configure(1.8f, 0, 900);
     homePosition = (maxPosition - minPosition) / 2;
-    speed = 250;
-    pulseWidth = 100e-6;
+    setSpeedSPS(250);
+    setPulseWidth(100e-6);
 }
 
 void StepperDriver::configure(uint32_t resolution, float minDegrees, float maxDegrees) {
@@ -102,4 +102,10 @@
 
 float StepperDriver::getSpeedRPM() {
     return speed * degreesPerStep / 360 * 60;
+}
+
+void StepperDriver::setPulseWidth(float pulseWidth) {
+    if (pulseWidth > 0) {
+        this->pulseWidth = pulseWidth;
+    }
 }
\ No newline at end of file