Dependents:   YMotor

Revision:
1:c8ed08beefb9
Parent:
0:a2bbf76ca734
Child:
2:871d1f6d311e
--- a/YMotorDriverBase.h	Sun Aug 23 15:18:04 2015 +0000
+++ b/YMotorDriverBase.h	Wed Oct 14 06:04:34 2015 +0000
@@ -14,6 +14,8 @@
     };
 
     YMotorDriverBase( char address );
+    YMotorDriverBase( char address, int id );
+    YMotorDriverBase( char address, float maxDuty, float minDuty );
     ~YMotorDriverBase();
     
     virtual void update();
@@ -34,30 +36,15 @@
     }
     
 protected:
-    void write();
+    virtual void write();
+    void updatePwmDuty();
     
     I2CSlave* mI2C;
     DigitalOut* mLED;
 
 private:
-    PWMOut* mMotorDrivePwm;
-    DigitalOut* mMotorDriveDout[ 4 ];
-    
-    MotorAction mAction;
-    float mDuty;
-    
-    const char mAddress;
-    
-    static const PinName mMotorDriveDoutPinName[ 4 ];
-    static const PinName mMotorDrivePwmPinName;
-    static const PinName mLEDPinName;
-    static const PinName mSerialPinName[ 2 ];
-    static const PinName mI2CPinName[ 2 ];
-    static const int mPwmCycle_us;
-    static const float mMaxDuty;
-    static const float mMinDuty;
-    
-    void updatePwmDuty();
+    virtual void updateI2CSlave();
+    virtual void updateSpecial(){}
     
     static float middle( float min, float d, float max ){
         if ( min > max ){
@@ -74,6 +61,28 @@
         
         return d;
     }
+    
+    void init();
+
+    PWMOut* mMotorDrivePwm;
+    DigitalOut* mMotorDriveDout[ 4 ];
+    
+    MotorAction mAction;
+    float mDuty;
+    
+    const char mAddress;
+    int mID;
+    
+    static const PinName mMotorDriveDoutPinName[ 4 ];
+    static const PinName mMotorDrivePwmPinName;
+    static const PinName mLEDPinName;
+    static const PinName mSerialPinName[ 2 ];
+    static const PinName mI2CPinName[ 2 ];
+    static const int mPwmCycle_us;
+    static const float mMaxDutyList[];
+    static const float mMinDutyList[];
+    float mMaxDuty;
+    float mMinDuty;
 };
 
 #endif
\ No newline at end of file