Added various bits, main reformatted. Added .get to class Servo to allow waiting for rotation before recording information.
Fork of Lab6_Basic by
Diff: Motor.h
- Revision:
- 6:a64d79286726
- Parent:
- 3:b787aa49b900
- Child:
- 8:c2f0e524696b
--- a/Motor.h Fri Nov 18 03:59:01 2016 +0000 +++ b/Motor.h Sat Nov 19 08:32:04 2016 +0000 @@ -1,63 +1,51 @@ +#include "Motor.h" #include "mbed.h" -#ifndef MOTOR_H -#define MOTOR_H -/** Motor class - * \author Ziad Eldebri - * \date Aug 15, 2016 - * \bug No bugs yet +#include "SLCD.h" +#ifndef MBED_SERVO_H +#define MBED_SERVO_H + +/** Servo control class, based on a Motor Class object + * * Example: * @code * #include "mbed.h" * #include "Motor.h" - * + * #include "Servo.h" * Motor my_motor(P12,P13P,p11); - * + * Servo my_servo(p21,my_motor); + * * int main() { - * my_motor.Direction(LEFT); will move in the specified direction + * added .get() to approximate position * } * @endcode */ - - #define LEFT 1 - #define RIGHT 2 +class Servo { - -class Motor -{ public: - /** - * Motor Will Create a Motor object Connected to the Specified pins. - * @param Pins to be Connected to the specified L293 http://www.ti.com/lit/ds/symlink/l293.pdf - * @param Positive - * @param Negative - * @param Speed + /** Create a servo object. + * + * @param pin AnalogIn pin to be feedback, motor is a Motor object from Motor.h */ - Motor (PinName Positive, PinName Negative,PinName Speed); - /** - * Control the Direction of the Movement - * @param move will specefiy the Direction. - * Input 1 or 2. - * 1 : Postive VCC Negtaive GND, 2 : Postive GND Negtaive VCC + Servo(PinName analog_input,PinName Positive, PinName Negative,PinName Speed); + + /** Set the servo position + * + * @param angle intger in degrees 0-180 to represent the full range. */ - void Direction(int move); - /** - * Stops the Movement of the motor - * @param None. - * Input 1 or 2. - */ - void Stop(); - /** - * Controls the speed of the motor with a input. - * @param motor_speed from 0 to 100. 0 is the slowest and 100 is max speed. - * - */ - void Speed(int motor_speed); - + void set(int degree); + + /** Read the servo current position in degrees from 0-180 + * + * @return returns the current anlge of the servo + */ + unsigned int get(); + void move(void); + + void check(); protected: - DigitalOut _positive; - DigitalOut _negative; - PwmOut _speed; - - -}; //end of Motor class -#endif \ No newline at end of file + AnalogIn _feedback; + Motor _motor; +}; + +#endif + \ No newline at end of file