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 MotorLib by
Diff: motor.cpp
- Revision:
- 8:4dd59b6f4e92
- Parent:
- 7:439458133bba
- Child:
- 9:5983c10d5f8e
--- a/motor.cpp Thu Mar 09 11:58:10 2017 +0000
+++ b/motor.cpp Mon Jul 17 11:45:44 2017 +0000
@@ -57,7 +57,7 @@
void Motor::RunDegrees(MotorDir dir, float degree) {
SetDirection( dir);
- NumSteps = (int)(degree * MotorFullTurn / 360.0);
+ NumSteps = (int)(degree * (float)MotorFullTurn / (float)360.0);
SetCommand(MOTOR_start);
}
void Motor::SetDirection(MotorDir dir) {
@@ -137,7 +137,7 @@
if (command == MOTOR_pause) {
state = Motor_PAUSE;
}
- else if ((command == MOTOR_stop)||(NumSteps<=0)) {
+ else if ((command == MOTOR_stop)||(NumSteps==0)) {
StopMotor();
state = Motor_IDLE;
}
