|
@@ -1,5 +1,6 @@
|
1
|
1
|
/*
|
2
|
2
|
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
|
3
|
+ * Contributions: Mihai Tudor Panu <mihai.t.panu@intel.com>
|
3
|
4
|
* Copyright (c) 2014 Intel Corporation.
|
4
|
5
|
*
|
5
|
6
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
@@ -94,7 +95,7 @@ Hmc5883l::Hmc5883l(int bus)
|
94
|
95
|
Hmc5883l::update();
|
95
|
96
|
}
|
96
|
97
|
|
97
|
|
-int
|
|
98
|
+mraa_result_t
|
98
|
99
|
Hmc5883l::update(void)
|
99
|
100
|
{
|
100
|
101
|
mraa_i2c_address(m_i2c, HMC5883L_I2C_ADDR);
|
|
@@ -116,13 +117,17 @@ Hmc5883l::update(void)
|
116
|
117
|
float
|
117
|
118
|
Hmc5883l::direction(void)
|
118
|
119
|
{
|
119
|
|
- return atan2(m_coor[1] * SCALE_0_92_MG, m_coor[0] * SCALE_0_92_MG);
|
|
120
|
+ return atan2(m_coor[1] * SCALE_0_92_MG, m_coor[0] * SCALE_0_92_MG) + m_declination;
|
120
|
121
|
}
|
121
|
122
|
|
122
|
123
|
float
|
123
|
124
|
Hmc5883l::heading(void)
|
124
|
125
|
{
|
125
|
|
- return Hmc5883l::direction() * 180/M_PI;
|
|
126
|
+ float dir = Hmc5883l::direction() * 180/M_PI;
|
|
127
|
+ if(dir < 0){
|
|
128
|
+ dir += 360.0;
|
|
129
|
+ }
|
|
130
|
+ return dir;
|
126
|
131
|
}
|
127
|
132
|
|
128
|
133
|
int*
|
|
@@ -130,3 +135,15 @@ Hmc5883l::coordinates(void)
|
130
|
135
|
{
|
131
|
136
|
return &m_coor[0];
|
132
|
137
|
}
|
|
138
|
+
|
|
139
|
+void
|
|
140
|
+Hmc5883l::set_declination(float dec)
|
|
141
|
+{
|
|
142
|
+ m_declination = dec;
|
|
143
|
+}
|
|
144
|
+
|
|
145
|
+float
|
|
146
|
+Hmc5883l::get_declination()
|
|
147
|
+{
|
|
148
|
+ return m_declination;
|
|
149
|
+}
|