Diff: I2CServo.h
- Revision:
- 2:0f03a5729afc
- Parent:
- 1:e06cf312e9f0
--- a/I2CServo.h Fri Aug 21 04:51:40 2015 +0000 +++ b/I2CServo.h Wed Oct 14 03:50:40 2015 +0000 @@ -6,41 +6,30 @@ class I2CServo : public I2CDevice{ public: - I2CServo( char address, int id ); + I2CServo( char address ); - 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 setTargetPosition( float p ); - bool isStop(){ - return mIsStop; + bool hasStopped(){ + return mHasStopped; } float getPosition(){ return mPosition; } - virtual void write(); - virtual void read(); + void stop(){ + mTargetPosition = mPosition; + mHasStopped = true; + } + + virtual int write(); + virtual int read(); private: + static const float mAllowableError; float mTargetPosition; - bool mIsStop; + bool mHasStopped; float mPosition; - - int mID; - - static const float mRangeMax[]; - static const float mRangeMin[]; }; #endif \ No newline at end of file