aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/hmc5883/hmc5883.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-04-27 19:51:06 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-04-27 19:51:06 +0200
commit8040b9b96e8f7c07aa981150c33f850096062f70 (patch)
tree92497e6f4a8a85ab78ccf4e305f7d323dc34836c /src/drivers/hmc5883/hmc5883.cpp
parent7ac617242da56f6f826eb7496e7689f7f36c8fa2 (diff)
downloadpx4-firmware-8040b9b96e8f7c07aa981150c33f850096062f70.tar.gz
px4-firmware-8040b9b96e8f7c07aa981150c33f850096062f70.tar.bz2
px4-firmware-8040b9b96e8f7c07aa981150c33f850096062f70.zip
Allowed for onboard bus to be not present
Diffstat (limited to 'src/drivers/hmc5883/hmc5883.cpp')
-rw-r--r--src/drivers/hmc5883/hmc5883.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/drivers/hmc5883/hmc5883.cpp b/src/drivers/hmc5883/hmc5883.cpp
index d71f469e9..c406a7588 100644
--- a/src/drivers/hmc5883/hmc5883.cpp
+++ b/src/drivers/hmc5883/hmc5883.cpp
@@ -841,6 +841,7 @@ HMC5883::collect()
* 74 from all measurements centers them around zero.
*/
+#ifdef PX4_I2C_BUS_ONBOARD
if (_bus == PX4_I2C_BUS_ONBOARD) {
/* to align the sensor axes with the board, x and y need to be flipped */
_reports[_next_report].x = ((report.y * _range_scale) - _scale.x_offset) * _scale.x_scale;
@@ -849,13 +850,16 @@ HMC5883::collect()
/* z remains z */
_reports[_next_report].z = ((report.z * _range_scale) - _scale.z_offset) * _scale.z_scale;
} else {
+#endif
/* XXX axis assignment of external sensor is yet unknown */
_reports[_next_report].x = ((report.y * _range_scale) - _scale.x_offset) * _scale.x_scale;
/* flip axes and negate value for y */
_reports[_next_report].y = ((((report.x == -32768) ? 32767 : -report.x) * _range_scale) - _scale.y_offset) * _scale.y_scale;
/* z remains z */
_reports[_next_report].z = ((report.z * _range_scale) - _scale.z_offset) * _scale.z_scale;
+#ifdef PX4_I2C_BUS_ONBOARD
}
+#endif
/* publish it */
orb_publish(ORB_ID(sensor_mag), _mag_topic, &_reports[_next_report]);