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:
2:7674afbf8e53
added some doxygen tags

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simplyellow 4:e87768d3cd09 1 /**
simplyellow 4:e87768d3cd09 2 * @file Motor.h
simplyellow 4:e87768d3cd09 3 *
simplyellow 4:e87768d3cd09 4 * @brief Motor class implements API for controlling motors.
simplyellow 4:e87768d3cd09 5 *
simplyellow 4:e87768d3cd09 6 * @author Terrabots Team
simplyellow 4:e87768d3cd09 7 *
simplyellow 4:e87768d3cd09 8 */
simplyellow 4:e87768d3cd09 9
simplyellow 2:7674afbf8e53 10 #ifndef MOTOR_H
simplyellow 2:7674afbf8e53 11 #define MOTOR_H
simplyellow 0:0a5af2965205 12
simplyellow 0:0a5af2965205 13 #include "mbed.h"
simplyellow 0:0a5af2965205 14
simplyellow 4:e87768d3cd09 15 /**
simplyellow 4:e87768d3cd09 16 * @class Motor
simplyellow 4:e87768d3cd09 17 *
simplyellow 4:e87768d3cd09 18 * @brief Interface for controlling the dump truck's motors
simplyellow 4:e87768d3cd09 19 */
simplyellow 4:e87768d3cd09 20
simplyellow 0:0a5af2965205 21 class Motor {
simplyellow 0:0a5af2965205 22 public:
simplyellow 4:e87768d3cd09 23 /**
simplyellow 4:e87768d3cd09 24 * Constructor for the Motor object.
simplyellow 4:e87768d3cd09 25 *
simplyellow 4:e87768d3cd09 26 * @param[in] pwm The PwmOut pin used for controlling speed.
simplyellow 4:e87768d3cd09 27 * @param[in] dir The DigitalOut pin used for controlling direction.
simplyellow 4:e87768d3cd09 28 */
simplyellow 0:0a5af2965205 29 Motor(PinName pwm, PinName dir);
simplyellow 4:e87768d3cd09 30 /**
simplyellow 4:e87768d3cd09 31 * Command the motor to run at a desired speed
simplyellow 4:e87768d3cd09 32 *
simplyellow 4:e87768d3cd09 33 * @param[in] Val The desired speed of type float.
simplyellow 4:e87768d3cd09 34 */
simplyellow 0:0a5af2965205 35 void write(float Val);
simplyellow 4:e87768d3cd09 36 /**
simplyellow 4:e87768d3cd09 37 * Read the speed of the motor
simplyellow 4:e87768d3cd09 38 */
simplyellow 0:0a5af2965205 39 float read();
simplyellow 0:0a5af2965205 40 private:
simplyellow 0:0a5af2965205 41 PwmOut pwmPin;
simplyellow 0:0a5af2965205 42 DigitalOut dirPin;
simplyellow 0:0a5af2965205 43 float lastVal;
simplyellow 0:0a5af2965205 44
simplyellow 0:0a5af2965205 45 };
simplyellow 0:0a5af2965205 46
simplyellow 0:0a5af2965205 47 #endif