I2CMotor.cpp@1:46cf8d086b38, 2015-08-21 (annotated)
- Committer:
- inst
- Date:
- Fri Aug 21 04:51:31 2015 +0000
- Revision:
- 1:46cf8d086b38
- Parent:
- 0:89910534fad4
- Child:
- 2:5b17e7dffb3d
y evol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inst | 0:89910534fad4 | 1 | #include "I2CMotor.h" |
inst | 1:46cf8d086b38 | 2 | #include "I2CDevice.h" |
inst | 0:89910534fad4 | 3 | #include "mbed.h" |
inst | 0:89910534fad4 | 4 | |
inst | 1:46cf8d086b38 | 5 | I2CMotor::I2CMotor( char address ) : I2CDevice( address ){ |
inst | 0:89910534fad4 | 6 | mActionType = BRAKE; |
inst | 0:89910534fad4 | 7 | mDuty = 0; |
inst | 0:89910534fad4 | 8 | |
inst | 0:89910534fad4 | 9 | char dutyLimit[ 2 ]; |
inst | 0:89910534fad4 | 10 | |
inst | 0:89910534fad4 | 11 | ( ( I2CDevice* )this )->read( ( char* )dutyLimit, ( size_t )2 ); |
inst | 1:46cf8d086b38 | 12 | //read( ( char* )dutyLimit, ( size_t )2 ); |
inst | 0:89910534fad4 | 13 | |
inst | 0:89910534fad4 | 14 | mMinDuty = dutyLimit[ 0 ]; |
inst | 0:89910534fad4 | 15 | mMinDuty /= 255.0f; |
inst | 0:89910534fad4 | 16 | |
inst | 0:89910534fad4 | 17 | mMaxDuty = dutyLimit[ 1 ]; |
inst | 0:89910534fad4 | 18 | mMaxDuty /= 255.0f; |
inst | 0:89910534fad4 | 19 | } |
inst | 0:89910534fad4 | 20 | |
inst | 0:89910534fad4 | 21 | |
inst | 0:89910534fad4 | 22 | void I2CMotor::write(){ |
inst | 0:89910534fad4 | 23 | char trans[] = { |
inst | 0:89910534fad4 | 24 | static_cast< char >( mActionType ), |
inst | 0:89910534fad4 | 25 | static_cast< char >( mDuty * 255.0f ) |
inst | 0:89910534fad4 | 26 | }; |
inst | 0:89910534fad4 | 27 | mI2C->write( mAddress, trans, 2 ); |
inst | 0:89910534fad4 | 28 | } |