Dependencies:   PID_ PWMOut YMotorDriverBase YMotorDriverPusher YMotorDriverServo YMotorDriverShooter YMotorDriverSupplier

Dependents:   YMD

Files at this revision

API Documentation at this revision

Comitter:
inst
Date:
Fri Nov 13 08:19:04 2015 +0000
Parent:
3:f30031faee81
Commit message:

Changed in this revision

YMotorDriver.cpp Show annotated file Show diff for this revision Revisions of this file
YMotorDriver.h Show annotated file Show diff for this revision Revisions of this file
YMotorDriverBase.lib Show annotated file Show diff for this revision Revisions of this file
--- a/YMotorDriver.cpp	Wed Oct 14 06:07:50 2015 +0000
+++ b/YMotorDriver.cpp	Fri Nov 13 08:19:04 2015 +0000
@@ -4,10 +4,10 @@
 #include "YMotorDriverPusher.h"
 #include "YMotorDriverShooter.h"
 
+YMotorDriver* YMotorDriver::mInstance = NULL;
 const PinName YMotorDriver::mAddressDeciderPinName[]  = {
     dp17, dp18, dp26, dp25
 };
-
 const char YMotorDriver::mYMotorDriverBaseAddress[] = {
     0xA0 | ( 0x01 << 1 ),
     0xA0 | ( 0x02 << 1 ),
--- a/YMotorDriver.h	Wed Oct 14 06:07:50 2015 +0000
+++ b/YMotorDriver.h	Fri Nov 13 08:19:04 2015 +0000
@@ -12,17 +12,24 @@
         STEERING_1_ID,
         STEERING_2_ID,
         SHOOTER_ID,
-        GENERAL_ID,
+        GENERAL_ID
     };
     
+    static YMotorDriver* getInstance(){
+        if ( mInstance == NULL ){
+            mInstance = new YMotorDriver();
+        }
+        return mInstance;
+    }
+    void update();
+    
+private:
     YMotorDriver();
     ~YMotorDriver();
     
-    void update();
-private:
-    YMotorDriverBase* mYMotorDriver;
+    static YMotorDriver* mInstance;
 
-    static const PinName mAddressDeciderPinName[ 4 ];
+    static const PinName mAddressDeciderPinName[];
     static const char mYMotorDriverBaseAddress[];
     static const char mYMotorDriverServoAddress[];
     static const char mYMotorDriverSupplierAddress[];
@@ -37,6 +44,7 @@
     static const size_t mNumOfYMotorDriverShooterAddress;
     static const size_t mNumOfYMotorDriverPositionManagerAddress;
     
+    YMotorDriverBase* mYMotorDriver;
     char mAddress;
 };
 
--- a/YMotorDriverBase.lib	Wed Oct 14 06:07:50 2015 +0000
+++ b/YMotorDriverBase.lib	Fri Nov 13 08:19:04 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/inst/code/YMotorDriverBase/#c8ed08beefb9
+https://developer.mbed.org/users/inst/code/YMotorDriverBase/#22f19e076931