I2CMotor.h@1:46cf8d086b38, 2015-08-21 (annotated)
- Committer:
- inst
- Date:
- Fri Aug 21 04:51:31 2015 +0000
- Revision:
- 1:46cf8d086b38
- Parent:
- 0:89910534fad4
- Child:
- 2:5b17e7dffb3d
y evol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inst | 0:89910534fad4 | 1 | #ifndef INCLUDED_I2C_MOTOR_H |
inst | 0:89910534fad4 | 2 | #define INCLUDED_I2C_MOTOR_H |
inst | 0:89910534fad4 | 3 | |
inst | 0:89910534fad4 | 4 | #include "I2CDevice.h" |
inst | 0:89910534fad4 | 5 | #include "mbed.h" |
inst | 0:89910534fad4 | 6 | |
inst | 0:89910534fad4 | 7 | class I2CMotor : public I2CDevice{ |
inst | 0:89910534fad4 | 8 | public: |
inst | 0:89910534fad4 | 9 | enum ActionType{ |
inst | 1:46cf8d086b38 | 10 | FORWARD, |
inst | 1:46cf8d086b38 | 11 | REVERSE, |
inst | 1:46cf8d086b38 | 12 | BRAKE, |
inst | 0:89910534fad4 | 13 | RELEASE, |
inst | 0:89910534fad4 | 14 | }; |
inst | 1:46cf8d086b38 | 15 | I2CMotor( char address ); |
inst | 0:89910534fad4 | 16 | |
inst | 0:89910534fad4 | 17 | void setActionType( ActionType action ){ |
inst | 0:89910534fad4 | 18 | mActionType = action; |
inst | 0:89910534fad4 | 19 | } |
inst | 0:89910534fad4 | 20 | void setDuty( float duty ){ |
inst | 1:46cf8d086b38 | 21 | if ( duty > mMaxDuty ){ |
inst | 1:46cf8d086b38 | 22 | duty = mMaxDuty; |
inst | 1:46cf8d086b38 | 23 | } else if ( duty < mMinDuty ){ |
inst | 1:46cf8d086b38 | 24 | duty = mMinDuty; |
inst | 0:89910534fad4 | 25 | } |
inst | 0:89910534fad4 | 26 | |
inst | 0:89910534fad4 | 27 | mDuty = duty; |
inst | 0:89910534fad4 | 28 | } |
inst | 1:46cf8d086b38 | 29 | ActionType getActionType() const{ |
inst | 0:89910534fad4 | 30 | return mActionType; |
inst | 0:89910534fad4 | 31 | } |
inst | 1:46cf8d086b38 | 32 | float getDuty() const{ |
inst | 0:89910534fad4 | 33 | return mDuty; |
inst | 0:89910534fad4 | 34 | } |
inst | 0:89910534fad4 | 35 | |
inst | 1:46cf8d086b38 | 36 | float getMaxDuty() const{ |
inst | 0:89910534fad4 | 37 | return mMaxDuty; |
inst | 0:89910534fad4 | 38 | } |
inst | 1:46cf8d086b38 | 39 | float getMinDuty() const{ |
inst | 0:89910534fad4 | 40 | return mMinDuty; |
inst | 0:89910534fad4 | 41 | } |
inst | 0:89910534fad4 | 42 | |
inst | 0:89910534fad4 | 43 | protected: |
inst | 0:89910534fad4 | 44 | virtual void write(); |
inst | 0:89910534fad4 | 45 | virtual void read(){} |
inst | 0:89910534fad4 | 46 | private: |
inst | 0:89910534fad4 | 47 | ActionType mActionType; |
inst | 0:89910534fad4 | 48 | float mDuty; |
inst | 0:89910534fad4 | 49 | |
inst | 0:89910534fad4 | 50 | float mMaxDuty; |
inst | 0:89910534fad4 | 51 | float mMinDuty; |
inst | 0:89910534fad4 | 52 | }; |
inst | 0:89910534fad4 | 53 | |
inst | 0:89910534fad4 | 54 | #endif |