Diff: HMC6343.cpp
- Revision:
- 2:2645c4d75671
- Parent:
- 1:bdf678f27614
--- a/HMC6343.cpp Sun May 01 13:51:14 2011 +0000 +++ b/HMC6343.cpp Fri Jun 17 22:35:48 2011 +0000 @@ -39,6 +39,8 @@ */ #include "HMC6343.h" +short h, r, p; + template<class TYPE> inline TYPE BIT(const TYPE & x) { return TYPE(1) << x; } @@ -68,10 +70,14 @@ wait_ms(1); i2c_->read((HMC6343_I2C_ADDRESS << 1) | 0x01, rx, 6, true); + + h = ((((int)rx[0] << 8) | (int)rx[1])); + r = ((((int)rx[4] << 8) | (int)rx[5])); + p = ((((int)rx[2] << 8) | (int)rx[3])); - p_heading->heading = (double)((((int)rx[0] << 8) | (int)rx[1])) / 10; - p_heading->roll = (double)((((int)rx[4] << 8) | (int)rx[5])) / 10; - p_heading->pitch = (double)((((int)rx[2] << 8) | (int)rx[3])) / 10; + p_heading->heading = (float)h / 10; + p_heading->roll = (float)r / 10; + p_heading->pitch = (float)p / 10; }