cleaned up motor class with separate header and .cpp files

Dependencies:   mbed

Dependents:   TerraBot_Drive_2D TerraBot_Drive_2D TerraBot_Drive_2D_FINAL DUMP_TRUCK_Test ... more

Committer:
simplyellow
Date:
Fri Oct 07 01:21:10 2016 +0000
Revision:
0:0a5af2965205
Child:
1:92be353590b4
cleaned up motor class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simplyellow 0:0a5af2965205 1 #include "Motor.h"
simplyellow 0:0a5af2965205 2
simplyellow 0:0a5af2965205 3 Motor::Motor(PinName pwm, PinName dir) : pwmPin(pwm), dirPin(dir)
simplyellow 0:0a5af2965205 4 {
simplyellow 0:0a5af2965205 5 }
simplyellow 0:0a5af2965205 6
simplyellow 0:0a5af2965205 7 void Motor::write(float Val)
simplyellow 0:0a5af2965205 8 {
simplyellow 0:0a5af2965205 9 if (Val >= 0) {
simplyellow 0:0a5af2965205 10 dirPin = 1;
simplyellow 0:0a5af2965205 11 pwmPin = Val;
simplyellow 0:0a5af2965205 12 }else {
simplyellow 0:0a5af2965205 13 dirPin = 0;
simplyellow 0:0a5af2965205 14 pwmPin = -1 * Val;
simplyellow 0:0a5af2965205 15 }
simplyellow 0:0a5af2965205 16 lastVal = Val;
simplyellow 0:0a5af2965205 17 }
simplyellow 0:0a5af2965205 18
simplyellow 0:0a5af2965205 19 float Motor::read()
simplyellow 0:0a5af2965205 20 {
simplyellow 0:0a5af2965205 21 return lastVal;
simplyellow 0:0a5af2965205 22 }