Revision:
1:e06cf312e9f0
Parent:
0:d4e07340fb0e
Child:
2:0f03a5729afc
--- a/I2CServo.h	Thu Jul 02 00:58:28 2015 +0000
+++ b/I2CServo.h	Fri Aug 21 04:51:40 2015 +0000
@@ -6,16 +6,41 @@
 
 class I2CServo : public I2CDevice{
 public:
-    I2CServo( I2C* i2c, char address );
+    I2CServo( char address, int id );
     
-    void setPosition( float p ){
-        setPosition( static_cast< unsigned short >( p * 1024 ) );
+    void setTargetPosition( float p ){
+        if ( p < 0.0f ){
+            p = 0.0f;
+        } else if ( p > 1.0f ){
+            p = 1.0f;
+        }
+        
+        if ( p != mTargetPosition ){
+            mIsStop = false;
+        }
+        
+        mTargetPosition = p;
     }
     
-    void write();
-    void read(){}
+    bool isStop(){
+        return mIsStop;
+    }
+    float getPosition(){
+        return mPosition;
+    }
+    
+    virtual void write();
+    virtual void read();
+    
 private:
-    unsigned short mPosition;
+    float mTargetPosition;
+    bool mIsStop;
+    float mPosition;
+    
+    int mID;
+    
+    static const float mRangeMax[];
+    static const float mRangeMin[];
 };
 
 #endif
\ No newline at end of file