I2CMotor.cpp
- Committer:
- inst
- Date:
- 2015-08-21
- Revision:
- 1:46cf8d086b38
- Parent:
- 0:89910534fad4
- Child:
- 2:5b17e7dffb3d
File content as of revision 1:46cf8d086b38:
#include "I2CMotor.h" #include "I2CDevice.h" #include "mbed.h" I2CMotor::I2CMotor( char address ) : I2CDevice( address ){ mActionType = BRAKE; mDuty = 0; char dutyLimit[ 2 ]; ( ( I2CDevice* )this )->read( ( char* )dutyLimit, ( size_t )2 ); //read( ( char* )dutyLimit, ( size_t )2 ); mMinDuty = dutyLimit[ 0 ]; mMinDuty /= 255.0f; mMaxDuty = dutyLimit[ 1 ]; mMaxDuty /= 255.0f; } void I2CMotor::write(){ char trans[] = { static_cast< char >( mActionType ), static_cast< char >( mDuty * 255.0f ) }; mI2C->write( mAddress, trans, 2 ); }