Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Revision:
8:a0760acdc59e
Parent:
7:6f5cb6377bd4
Child:
12:5790e56a056f
--- a/motor.h	Fri May 05 00:08:59 2017 +0000
+++ b/motor.h	Fri May 05 01:21:33 2017 +0000
@@ -2,75 +2,46 @@
 #define MOTOR_H
 
 #include "mbed.h"
-#include "main.h"
-
-#include "QEI.h"
+//#include "main.h"
 
 #define BRAKE_VOLTAGE 0.2
 
+/*
 extern PwmOut left1;
 extern PwmOut left2;
 extern PwmOut right1;
 extern PwmOut right2;
 
 extern DigitalOut enableLeftMotor;
-extern DigitalOut enableRightMotor;
+extern DigitalOut enableRightMotor; */
+
+class Motor
+{
+    public:
+        Motor( PinName f, PinName b, PinName e ) : 
+            forw( f ), back( b ), enableMotor( e )
+        {
+            enableMotor.write( 1 );
+        }
+    
+        void backward( double voltage );
+        void forward( double voltage );
+        void brake();
+        void coast();
+        
+    private:
+        PwmOut forw;
+        PwmOut back;
+        DigitalOut enableMotor;  
+};
 
 //QEI leftWheel(
 
+/*
 inline void enableMotors(){
     enableLeftMotor.write(1);
     enableRightMotor.write(1);
-}
-
-inline void rightWheelBackward(double voltage) {
-    right1.write(voltage);
-    right2.write(0);
-}
-
-inline void rightWheelForward(double voltage) {
-    right1.write(0);
-    right2.write(voltage);
-}
-
-inline void leftWheelForward(double voltage) {
-    left1.write(0);
-    left2.write(voltage);
-}
-
-inline void leftWheelBackward(double voltage) {
-    left1.write(voltage);
-    left2.write(0);
-}
+}*/
 
-inline void brakeLeftWheel() {
-    left1.write(BRAKE_VOLTAGE);
-    left2.write(BRAKE_VOLTAGE);
-}
-
-inline void brakeRightWheel() {
-    right1.write(BRAKE_VOLTAGE);
-    right2.write(BRAKE_VOLTAGE);
-}
-
-inline void brake() {
-    brakeLeftWheel();
-    brakeRightWheel();
-}
-
-inline void coastLeftWheel() {
-    left1.write(0);
-    left2.write(0);
-}
-
-inline void coastRightWheel() {
-    right1.write(0);
-    right2.write(0);
-}
-
-inline void coast() {
-    coastLeftWheel();
-    coastRightWheel();
-}
 
 #endif
\ No newline at end of file