Diff: AmmoPusher.h
- Revision:
- 2:5ec2a3097d4c
- Parent:
- 1:42d2772575c5
diff -r 42d2772575c5 -r 5ec2a3097d4c AmmoPusher.h --- a/AmmoPusher.h Fri Aug 21 04:52:43 2015 +0000 +++ b/AmmoPusher.h Wed Oct 14 03:52:34 2015 +0000 @@ -2,27 +2,51 @@ #define INCLUDED_AMMO_PUSHER_H #include "mbed.h" -class I2CMotor; +#include "I2CDevice.h" -class AmmoPusher { +class AmmoPusher : public I2CDevice{ public: - AmmoPusher( I2CMotor* drawerMotor ); + enum ActionType{ + NO_OPERATION, + DRAWING, + PUSHING + }; + enum State{ + BETWEEN, + HAS_FINISHED_DRAWING, + HAS_FINISHED_PUSHING + }; + + AmmoPusher( char address ); - void update(); - void draw(); - void push(); + void push(){ + setActionType( PUSHING ); + } + void draw(){ + setActionType( DRAWING ); + } + void setActionType( ActionType action ){ + mActionType = action; + } + State getState(){ + return mState; + } + bool isWorking(){ + return ( ( mState == BETWEEN ) && ( mActionType != NO_OPERATION ) ); + } + bool hasPushed(){ + return ( mState == HAS_FINISHED_PUSHING ); + } + bool hasDrawn(){ + return ( mState == HAS_FINISHED_DRAWING ); + } - bool hasPusherFinishedDrawing(); - bool hasPusherFinishedPushing(); + virtual int write(); + virtual int read(); private: - static const float mDuty; - static const PinName mDrawingLimitSwitchPinName; - static const PinName mPushingLimitSwitchPinName; - - DigitalIn* mDrawingLimitSwitch; - DigitalIn* mPushingLimitSwitch; - I2CMotor* mDrawerMotor; + ActionType mActionType; + State mState; }; #endif