Robot.cpp@2:0d9bb8e1876b, 2015-10-14 (annotated)
- Committer:
- inst
- Date:
- Wed Oct 14 03:50:52 2015 +0000
- Revision:
- 2:0d9bb8e1876b
- Parent:
- 1:48028dcad4e2
- Child:
- 3:4dbbd511a49d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inst | 0:91d31b26ae9e | 1 | #include "mbed.h" |
inst | 0:91d31b26ae9e | 2 | #include "Robot.h" |
inst | 0:91d31b26ae9e | 3 | #include "I2CDevice.h" |
inst | 0:91d31b26ae9e | 4 | |
inst | 2:0d9bb8e1876b | 5 | // XBee : ---- 1 |
inst | 2:0d9bb8e1876b | 6 | // Steering { |
inst | 2:0d9bb8e1876b | 7 | // I2CMotor * 3, I2CServo * 3 ---- 6 |
inst | 2:0d9bb8e1876b | 8 | // ShootingSystem : |
inst | 2:0d9bb8e1876b | 9 | // I2CServo * 1 ---- 1 |
inst | 2:0d9bb8e1876b | 10 | // } |
inst | 2:0d9bb8e1876b | 11 | // ShootingSystem { |
inst | 2:0d9bb8e1876b | 12 | // Shooter: ---- 1 |
inst | 2:0d9bb8e1876b | 13 | // AmmoPusher: ---- 1 |
inst | 2:0d9bb8e1876b | 14 | // AmmoSupplier: ---- 1 |
inst | 2:0d9bb8e1876b | 15 | // } |
inst | 1:48028dcad4e2 | 16 | const int Robot::mNumOfI2CDevice = 12; |
inst | 0:91d31b26ae9e | 17 | |
inst | 0:91d31b26ae9e | 18 | void Robot::update(){ |
inst | 0:91d31b26ae9e | 19 | readI2CDevice(); |
inst | 0:91d31b26ae9e | 20 | updateAction(); |
inst | 0:91d31b26ae9e | 21 | writeI2CDevice(); |
inst | 0:91d31b26ae9e | 22 | } |
inst | 0:91d31b26ae9e | 23 | |
inst | 0:91d31b26ae9e | 24 | void Robot::writeI2CDevice(){ |
inst | 0:91d31b26ae9e | 25 | for ( int i = 0; i < mNumOfI2CDevice; ++i ){ |
inst | 2:0d9bb8e1876b | 26 | mI2CDevice[ i ]->writeI2C(); |
inst | 0:91d31b26ae9e | 27 | } |
inst | 0:91d31b26ae9e | 28 | } |
inst | 0:91d31b26ae9e | 29 | |
inst | 0:91d31b26ae9e | 30 | void Robot::readI2CDevice(){ |
inst | 0:91d31b26ae9e | 31 | for ( int i = 0; i < mNumOfI2CDevice; ++i ){ |
inst | 2:0d9bb8e1876b | 32 | mI2CDevice[ i ]->readI2C(); |
inst | 0:91d31b26ae9e | 33 | } |
inst | 1:48028dcad4e2 | 34 | } |