version for edu_robot TM
Fork of SRF02 by
Diff: SRF02.cpp
- Revision:
- 2:9da88e2889b6
- Parent:
- 0:8ac34d529a3b
--- a/SRF02.cpp Fri Dec 16 14:09:37 2011 +0000 +++ b/SRF02.cpp Wed Feb 26 08:29:45 2014 +0000 @@ -3,6 +3,7 @@ /* Creates an instance of class. Setting the pin used for I2C, the address of device and the measure range type. */ SRF02::SRF02(PinName sda, PinName scl, int addr, char type) : _i2c(sda, scl), _addr(addr) { + _typem = type; } @@ -19,6 +20,7 @@ char result[2]; command[0] = 0x00; // Set the command register + command[1] = _typem; // Ranging results in type indicated in a costructor _i2c.write(_addr, command, 2); // Send the command to start a ranging burst @@ -31,4 +33,4 @@ float range = (result[0]<<8)+result[1]; // Convert the two byte in a float value return range; -} +} \ No newline at end of file