Dependencies: PID_ PWMOut YMotorDriverBase YMotorDriverPusher YMotorDriverServo YMotorDriverShooter YMotorDriverSupplier
Diff: YMotorDriver.cpp
- Revision:
- 2:2e3b56f045f5
- Parent:
- 1:793d739ebf5e
- Child:
- 4:7b3ed02bf4cc
diff -r 793d739ebf5e -r 2e3b56f045f5 YMotorDriver.cpp --- a/YMotorDriver.cpp Sun Aug 23 15:19:34 2015 +0000 +++ b/YMotorDriver.cpp Wed Oct 14 06:05:13 2015 +0000 @@ -7,33 +7,31 @@ const PinName YMotorDriver::mAddressDeciderPinName[] = { dp17, dp18, dp26, dp25 }; + const char YMotorDriver::mYMotorDriverBaseAddress[] = { 0xA0 | ( 0x01 << 1 ), 0xA0 | ( 0x02 << 1 ), - 0xA0 | ( 0x03 << 1 ), - 0xA0 | ( 0x04 << 1 ) + 0xA0 | ( 0x03 << 1 ) }; const char YMotorDriver::mYMotorDriverServoAddress[] = { + 0xA0 | ( 0x04 << 1 ), 0xA0 | ( 0x05 << 1 ), 0xA0 | ( 0x06 << 1 ), - 0xA0 | ( 0x07 << 1 ), - 0xA0 | ( 0x08 << 1 ), - 0xA0 | ( 0x09 << 1 ), + 0xA0 | ( 0x0D << 1 ), + 0xA0 | ( 0x08 << 1 ) +}; +const char YMotorDriver::mYMotorDriverShooterAddress[] = { + 0xA0 | ( 0x09 << 1 ) +}; +const char YMotorDriver::mYMotorDriverPusherAddress[] = { 0xA0 | ( 0x0A << 1 ) }; const char YMotorDriver::mYMotorDriverSupplierAddress[] = { - 0xA0 | ( 0x0B << 1 ), - 0xA0 | ( 0x0C << 1 ) -}; -const char YMotorDriver::mYMotorDriverPusherAddress[] = { - 0xA0 | ( 0x0D << 1 ) + 0xA0 | ( 0x0B << 1 ) }; -const char YMotorDriver::mYMotorDriverShooterAddress[] = { - 0xA0 | ( 0x0E << 1 ) -}; -const size_t YMotorDriver::mNumOfYMotorDriverBaseAddress = 4; -const size_t YMotorDriver::mNumOfYMotorDriverServoAddress = 6; -const size_t YMotorDriver::mNumOfYMotorDriverSupplierAddress = 2; +const size_t YMotorDriver::mNumOfYMotorDriverBaseAddress = 3; +const size_t YMotorDriver::mNumOfYMotorDriverServoAddress = 5; +const size_t YMotorDriver::mNumOfYMotorDriverSupplierAddress = 1; const size_t YMotorDriver::mNumOfYMotorDriverPusherAddress = 1; const size_t YMotorDriver::mNumOfYMotorDriverShooterAddress = 1; @@ -45,10 +43,11 @@ address |= d.read() << ( i + 1 ); } + // アドレスによって機能を変える // Motor for ( int i = 0; i < mNumOfYMotorDriverBaseAddress; ++i ){ if ( address == mYMotorDriverBaseAddress[ i ] ){ - mYMotorDriver = new YMotorDriverBase( address ); + mYMotorDriver = new YMotorDriverBase( address, i ); return; } } @@ -80,7 +79,8 @@ return; } } - + + // 機能が割り振られていないアドレスならLEDを点滅させておく DigitalOut err( dp28 ); while ( true ){ printf( "address:%d\r", address );