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:
Tue Feb 14 20:46:08 2017 +0000
Revision:
4:e87768d3cd09
Parent:
1:92be353590b4
added some doxygen tags

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 1:92be353590b4 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 1:92be353590b4 17 }
simplyellow 0:0a5af2965205 18
simplyellow 0:0a5af2965205 19 float Motor::read()
simplyellow 1:92be353590b4 20 {
simplyellow 0:0a5af2965205 21 return lastVal;
simplyellow 1:92be353590b4 22 }