Dependents:   RobotBase

Committer:
inst
Date:
Thu Jul 02 00:58:51 2015 +0000
Revision:
0:91d31b26ae9e
Child:
1:48028dcad4e2

        

Who changed what in which revision?

UserRevisionLine numberNew 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 0:91d31b26ae9e 5 Robot::Robot( int numOfI2CDevice ) : mNumOfI2CDevice( numOfI2CDevice ){
inst 0:91d31b26ae9e 6 }
inst 0:91d31b26ae9e 7
inst 0:91d31b26ae9e 8 Robot::~Robot(){
inst 0:91d31b26ae9e 9 delete[] mI2CDevice;
inst 0:91d31b26ae9e 10 }
inst 0:91d31b26ae9e 11
inst 0:91d31b26ae9e 12 void Robot::update(){
inst 0:91d31b26ae9e 13 readI2CDevice();
inst 0:91d31b26ae9e 14 updateAction();
inst 0:91d31b26ae9e 15 writeI2CDevice();
inst 0:91d31b26ae9e 16 }
inst 0:91d31b26ae9e 17
inst 0:91d31b26ae9e 18 void Robot::writeI2CDevice(){
inst 0:91d31b26ae9e 19 for ( int i = 0; i < mNumOfI2CDevice; ++i ){
inst 0:91d31b26ae9e 20 mI2CDevice[ i ]->write();
inst 0:91d31b26ae9e 21 }
inst 0:91d31b26ae9e 22 }
inst 0:91d31b26ae9e 23
inst 0:91d31b26ae9e 24 void Robot::readI2CDevice(){
inst 0:91d31b26ae9e 25 for ( int i = 0; i < mNumOfI2CDevice; ++i ){
inst 0:91d31b26ae9e 26 mI2CDevice[ i ]->read();
inst 0:91d31b26ae9e 27 }
inst 0:91d31b26ae9e 28 }