Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of a4998 by
Revision 1:ab0f997c2d9c, committed 2018-05-08
- 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 |
--- 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
- }
}
--- 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:
