Revision 1:b6face630ed3, committed 2015-10-14
- Comitter:
- inst
- Date:
- Wed Oct 14 06:05:07 2015 +0000
- Parent:
- 0:9b3bf538a693
- Commit message:
Changed in this revision
YMotorDriverShooter.cpp | Show annotated file Show diff for this revision Revisions of this file |
YMotorDriverShooter.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9b3bf538a693 -r b6face630ed3 YMotorDriverShooter.cpp --- a/YMotorDriverShooter.cpp Sun Aug 23 15:18:25 2015 +0000 +++ b/YMotorDriverShooter.cpp Wed Oct 14 06:05:07 2015 +0000 @@ -1,23 +1,25 @@ #include "YMotorDriverShooter.h" #include "YMotorDriverBase.h" +#include "YMotorDriver.h" #include "mbed.h" const PinName YMotorDriverShooter::mRelayDriveDoutPinName[] = { - dp6, - dp13, - dp14 + dp14, + dp11, + dp4, + dp2 }; -YMotorDriverShooter::YMotorDriverShooter( char address ) : YMotorDriverBase( address ){ - mRelayDriveDout = new DigitalOut*[ 3 ]; - for ( int i = 0; i < 3; ++i ){ +YMotorDriverShooter::YMotorDriverShooter( char address ) : YMotorDriverBase( address, YMotorDriver::SHOOTER_ID ){ + mRelayDriveDout = new DigitalOut*[ 4 ]; + for ( int i = 0; i < 4; ++i ){ mRelayDriveDout[ i ] = new DigitalOut( mRelayDriveDoutPinName[ i ] ); } mActionType = STOP; } -void YMotorDriverShooter::update(){ +void YMotorDriverShooter::updateI2CSlave(){ switch ( mI2C->receive() ){ case I2CSlave::ReadAddressed:{ char buf = mActionType; @@ -37,12 +39,10 @@ case I2CSlave::NoData: break; } - - write(); } void YMotorDriverShooter::write(){ - for ( int i = 0; i < 3; ++i ){ + for ( int i = 0; i < 4; ++i ){ mRelayDriveDout[ i ]->write( ( mActionType >> i ) & 0x01 ); } }
diff -r 9b3bf538a693 -r b6face630ed3 YMotorDriverShooter.h --- a/YMotorDriverShooter.h Sun Aug 23 15:18:25 2015 +0000 +++ b/YMotorDriverShooter.h Wed Oct 14 06:05:07 2015 +0000 @@ -6,19 +6,21 @@ class YMotorDriverShooter : public YMotorDriverBase{ public: enum ShooterActionType{ - STOP = 0, - WORKING_8V = 4, - WORKING_12V = 5, - WORKING_16V = 6 + STOP = 0x00, // 0000(2) + WORKING_8V = 0x01, // 0001(2) + WORKING_12V = 0x03, // 0011(2) + WORKING_16V = 0x07, // 0111(2) + WORKING_20V = 0x0F // 1111(2) }; YMotorDriverShooter( char address ); - virtual void update(); private: - void write(); + virtual void write(); + virtual void updateI2CSlave(); static const PinName mRelayDriveDoutPinName[]; + DigitalOut** mRelayDriveDout; ShooterActionType mActionType; };