Dependents:   RobotBase

Revision:
0:89910534fad4
Child:
1:46cf8d086b38
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2CMotor.h	Thu Jul 02 00:57:59 2015 +0000
@@ -0,0 +1,54 @@
+#ifndef INCLUDED_I2C_MOTOR_H
+#define INCLUDED_I2C_MOTOR_H
+
+#include "I2CDevice.h"
+#include "mbed.h"
+
+class I2CMotor : public I2CDevice{
+public:
+    enum ActionType{
+        RELEASE,
+        LEFT,
+        RIGHT,
+        BRAKE
+    };
+    I2CMotor( I2C* i2c, char address );
+    
+    void setActionType( ActionType action ){
+        mActionType = action;
+    }
+    void setDuty( float duty ){
+        if ( duty > 1.0f ){
+            duty = 1.0f;
+        } else if ( duty < 0.0f ){
+            duty = 0.0f;
+        }
+        
+        mDuty = duty;
+    }
+    ActionType getActionType(){
+        return mActionType;
+    }
+    float getDuty(){
+        return mDuty;
+    }
+    
+    float getMaxDuty(){
+        return mMaxDuty;
+    }
+    float getMinDuty(){
+        return mMinDuty;
+    }
+    
+protected:
+    virtual void write();
+    virtual void read(){}
+private:
+    ActionType mActionType;
+    float mDuty;
+    
+    float mMaxDuty;
+    float mMinDuty;
+};
+
+#endif
\ No newline at end of file