Diff: YMotorDriverServo.h
- Revision:
- 2:16e29a3a8f58
- Parent:
- 1:d1ca02f9536c
diff -r d1ca02f9536c -r 16e29a3a8f58 YMotorDriverServo.h --- a/YMotorDriverServo.h Sun Aug 30 23:26:12 2015 +0000 +++ b/YMotorDriverServo.h Wed Oct 14 06:04:45 2015 +0000 @@ -10,19 +10,41 @@ YMotorDriverServo( char address, int id ); ~YMotorDriverServo(); +protected: + void stop(){ + mTargetPosition = mPosition; + } + void setTargetPosition( float p ){ + if ( p < 0.0f ){ + p = 0.0f; + } else if ( p > 1.0f ){ + p = 1.0f; + } + mTargetPosition = ( mServoRangeMax[ mID ] - mServoRangeMin[ mID ] ) * p + mServoRangeMin[ mID ]; + } + float getPosition(){ + return mPosition; + } + float getTargetPosition(){ + return mTargetPosition; + } + private: virtual void updateSpecial(); virtual void updateI2CSlave(); virtual void control( float c ); + virtual void updateServoSpecial(){} - static const float mAllowableError; + static const float mAllowableError[]; static const PinName mAnalogInPinName; - static const float mLowPassFilterCoeff; + static const float mLowPassFilterCoeff[]; static const float mPCoeff[]; static const float mICoeff[]; static const float mDCoeff[]; - static const float mServoMaxDuty; - static const float mServoMinDuty; + static const float mServoMaxDuty[]; + static const float mServoMinDuty[]; + static const float mServoRangeMin[]; + static const float mServoRangeMax[]; AnalogIn* mAnalogIn; float mPosition;