Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
I2CMotor.cpp@0:89910534fad4, 2015-07-02 (annotated)
- Committer:
 - inst
 - Date:
 - Thu Jul 02 00:57:59 2015 +0000
 - Revision:
 - 0:89910534fad4
 - Child:
 - 1:46cf8d086b38
 
2015 robocon beta
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| inst | 0:89910534fad4 | 1 | #include "I2CMotor.h" | 
| inst | 0:89910534fad4 | 2 | #include "mbed.h" | 
| inst | 0:89910534fad4 | 3 | |
| inst | 0:89910534fad4 | 4 | I2CMotor::I2CMotor( I2C* i2c, char address ) : I2CDevice( i2c, address ){ | 
| inst | 0:89910534fad4 | 5 | mActionType = BRAKE; | 
| inst | 0:89910534fad4 | 6 | mDuty = 0; | 
| inst | 0:89910534fad4 | 7 | |
| inst | 0:89910534fad4 | 8 | char dutyLimit[ 2 ]; | 
| inst | 0:89910534fad4 | 9 | |
| inst | 0:89910534fad4 | 10 | ( ( I2CDevice* )this )->read( ( char* )dutyLimit, ( size_t )2 ); | 
| inst | 0:89910534fad4 | 11 | |
| inst | 0:89910534fad4 | 12 | mMinDuty = dutyLimit[ 0 ]; | 
| inst | 0:89910534fad4 | 13 | mMinDuty /= 255.0f; | 
| inst | 0:89910534fad4 | 14 | |
| inst | 0:89910534fad4 | 15 | mMaxDuty = dutyLimit[ 1 ]; | 
| inst | 0:89910534fad4 | 16 | mMaxDuty /= 255.0f; | 
| inst | 0:89910534fad4 | 17 | } | 
| inst | 0:89910534fad4 | 18 | |
| inst | 0:89910534fad4 | 19 | |
| inst | 0:89910534fad4 | 20 | void I2CMotor::write(){ | 
| inst | 0:89910534fad4 | 21 | char trans[] = { | 
| inst | 0:89910534fad4 | 22 | static_cast< char >( mActionType ), | 
| inst | 0:89910534fad4 | 23 | static_cast< char >( mDuty * 255.0f ) | 
| inst | 0:89910534fad4 | 24 | }; | 
| inst | 0:89910534fad4 | 25 | mI2C->write( mAddress, trans, 2 ); | 
| inst | 0:89910534fad4 | 26 | } |