dsaf

Dependents:   Ex_3Dprinter_copy

Fork of a4998 by Keegan Hu

Files at this revision

API Documentation at this revision

Comitter:
brainliang
Date:
Tue May 08 01:19:00 2018 +0000
Parent:
0:173936452e07
Commit message:
fds

Changed in this revision

a4988.cpp Show annotated file Show diff for this revision Revisions of this file
a4988.h Show annotated file Show diff for this revision Revisions of this file
diff -r 173936452e07 -r ab0f997c2d9c a4988.cpp
--- a/a4988.cpp	Wed May 02 10:48:23 2018 +0000
+++ b/a4988.cpp	Tue May 08 01:19:00 2018 +0000
@@ -1,6 +1,7 @@
 #include "a4988.h"
 #include "mbed.h"
-Stepper::Stepper(PinName _en, PinName _stepPin, PinName _direction):en(_en),
+Stepper::Stepper(PinName _en, PinName _stepPin, PinName _direction):
+    en(_en),
     stepPin(_stepPin),
     direction(_direction)
 {
@@ -34,12 +35,10 @@
         if(remain == 0)
         {         
             return;
+        }else if(stepPin){
+            stepPin = 0; //STEP 1->0
+            remain--;
+        }else{
+            stepPin = 1; //STEP 0->1
         }
-        
-                if(stepPin){
-                        stepPin = 0; //STEP 1->0
-                        remain--;
-                }else{
-                        stepPin = 1; //STEP 0->1
-                }
 }
diff -r 173936452e07 -r ab0f997c2d9c a4988.h
--- a/a4988.h	Wed May 02 10:48:23 2018 +0000
+++ b/a4988.h	Tue May 08 01:19:00 2018 +0000
@@ -9,7 +9,7 @@
 {
 public:
     Stepper(PinName _en,PinName _stepPin, PinName _direction);
-    void step(int dir, int frequency ,volatile int _remain);
+    void step(int dir, int frequency ,volatile int _remain);            //方向,频率,步数3个参数
     void enable();
     void disable();
 private: