For 1st Year ROCO104

Dependencies:   mbed motor

Files at this revision

API Documentation at this revision

Comitter:
martinsimpson
Date:
Thu Jan 17 17:02:17 2019 +0000
Parent:
2:bc41daf2b0ce
Child:
4:8249fab4d8d3
Commit message:
alpha

Changed in this revision

motor.cpp Show diff for this revision Revisions of this file
motor.h Show diff for this revision Revisions of this file
motor.lib Show annotated file Show diff for this revision Revisions of this file
--- a/motor.cpp	Mon Dec 17 11:09:11 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-#include "motor.h"
-
-Motor::Motor(PinName pinName1, PinName pinName2, PinName pinName3, PinName pinName4) : pin1(pinName1), pin2(pinName2), pin3(pinName3), pin4(pinName4)
-{
-}
-void Motor::Fwd(float duty)
-{ 
-    this->pin1 = 0.0f;
-    this->pin2 = duty;
-    this->pin3 = 0.0f;
-    this->pin4 = duty;
-}
-void Motor::Rev(float duty)
-{
-    this->pin1 = duty;
-    this->pin2 = 0.0f;
-    this->pin3 = duty;
-    this->pin4 = 0.0f;
-}
-void Motor::Stop(void)
-{
-    this->pin1 = 0.0f;
-    this->pin2 = 0.0f;
-    this->pin3 = 0.0f;
-    this->pin4 = 0.0f;
-}
-int Motor::Speed(float speedA, float speedB)
-{
-  if(speedA>1.0f||speedA<-1.0f){ //CHECK speedA Value is in Range!
-      return -1;                  //return ERROR code -1=speedA Value out of range! EXIT Function
-   }
-   if(speedB>1.0f||speedA<-1.0f){ //CHECK speedB Value is in Range!
-      return -2;                  //return ERROR code -2=speedB Value out of range! EXIT Function
-   }
- 
-   //If speed values have passed the checks above then the following code will be executed
-   
-   if(speedA<0.0f)
-   { //Reverse A motor
-        this->pin1 = -speedA;
-        this->pin2 = 0.0f;
-   }
-   
-   else
-   { //Forward A motor
-        this->pin1 = 0.0f;
-        this->pin2 = speedA;
-   }
-   
-   if(speedB<0.0f)
-   { //Reverse B motor
-        this->pin3 = -speedB;
-        this->pin4 = 0.0f;
-   }
-   else
-   { //Forward B motor
-        this->pin3 = 0.0f;
-        this->pin4 = speedB;
-   }
-   return 0;                      //Return ERROR code Zero i.e. NO ERROR success!
-}
-
-void Motor::Period_in_ms(int msPeriod)
-{
-    this->pin1.period_ms(msPeriod);
-    this->pin2.period_ms(msPeriod);
-    this->pin3.period_ms(msPeriod);
-    this->pin4.period_ms(msPeriod);
-}
--- a/motor.h	Mon Dec 17 11:09:11 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#ifndef _MOTOR_H_
-#define _MOTOR_H_
-#include "mbed.h"
-
-  namespace mbed {
-  /** \addtogroup drivers */
-  
-  /** A Motor Driver, used for setting the pins for PWM Outpu
-   *  for use with ROCO104
-   *
-   * @note Synchronization level: Interrupt safe
-   *
-   * Example:
-   * @code
-   * // Toggle a LED
-   * #include "mbed.h"
-   *
-   * Motor Wheels(D15,D14,D13,D12);
-   *
-   * int main()
-   * {    
-   *     Wheel.Period_in_ms(2);//Set frequency of the PWMs 500Hz
-   *     while(true)
-   *     {
-   *         Wheel.Speed(0.8,0.8);//Forward 80%
-   *         wait(5.0);
-   *         Wheel.stop();
-   *         wait(1.0);
-   *         Wheel.Speed(-0.8,-0.8);//Reverse 80%
-   *         wait(5.0);
-   *         Wheel.stop();
-   *         wait(1.0);
-   *     }
-   * }
-   * @endcode
-   */
-  } // namespace mbed
-
-class Motor
-{
-public:
-    Motor(PinName pinName1, PinName pinName2, PinName pinName3, PinName pinName4);
-    void Fwd(float time);
-    void Rev(float time);
-    void Stop(void);
-    int Speed(float speedA, float speedB);
-    void Period_in_ms(int msPeriod);
-private:
-    PwmOut pin1;
-    PwmOut pin2;
-    PwmOut pin3;
-    PwmOut pin4;
-};
-
-//int motor(float speedA, float speedB);
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor.lib	Thu Jan 17 17:02:17 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/martinsimpson/code/motor/#52cb035f23fa