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.
Stepper.cpp
00001 #include "Stepper.h" 00002 #include "mbed.h" 00003 00004 stepper::stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir):en(_en), 00005 microstepping(ms1, ms2, ms3), 00006 stepPin(_stepPin), 00007 direction(dir) 00008 { 00009 } 00010 00011 void stepper::step(int microstep, int dir, float speed) 00012 { 00013 if (microstep == 1) { 00014 microstepping = 0; 00015 } else if (microstep <= 4) { 00016 microstepping = microstep / 2; 00017 } else if (microstep > 4) { 00018 microstepping = (microstep / 2) - 1; 00019 } 00020 if (dir == 1) { 00021 direction = 0; 00022 } else if (dir == 0) { 00023 direction = 1; 00024 } 00025 00026 // Step... 00027 stepPin = 1; 00028 wait(1/speed); 00029 stepPin = 0; 00030 wait(1/speed); 00031 } 00032 00033 void stepper::enable() 00034 { 00035 en = 0; 00036 } 00037 00038 void stepper::disable() 00039 { 00040 en = 1; 00041 }
Generated on Thu Jul 14 2022 01:11:01 by
1.7.2