Skip to content

Commit

Permalink
Fix issue with targets not defining USE_MAG
Browse files Browse the repository at this point in the history
  • Loading branch information
shellixyz committed Apr 7, 2021
1 parent 8b8ee12 commit 438dd40
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/main/flight/secondary_imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

#include "stdint.h"

#include "build/debug.h"

#include "common/utils.h"
#include "common/axis.h"
#include "flight/secondary_imu.h"
#include "config/parameter_group_ids.h"
#include "sensors/boardalignment.h"
#include "sensors/compass.h"

#include "build/debug.h"
#include "config/parameter_group_ids.h"

#include "drivers/sensor.h"
#include "drivers/accgyro/accgyro_bno055.h"

#include "fc/settings.h"

#include "flight/secondary_imu.h"

#include "sensors/boardalignment.h"
#include "sensors/compass.h"

PG_REGISTER_WITH_RESET_FN(secondaryImuConfig_t, secondaryImuConfig, PG_SECONDARY_IMU, 1);

EXTENDED_FASTRAM secondaryImuState_t secondaryImuState;
Expand Down Expand Up @@ -62,8 +69,13 @@ void secondaryImuInit(void)
{
secondaryImuState.active = false;
// Create magnetic declination matrix
#ifdef USE_MAG
const int deg = compassConfig()->mag_declination / 100;
const int min = compassConfig()->mag_declination % 100;
#else
const int deg = 0;
const int min = 0;
#endif

secondaryImuSetMagneticDeclination(deg + min / 60.0f);

Expand Down Expand Up @@ -171,4 +183,4 @@ void secondaryImuFetchCalibration(void) {

void secondaryImuSetMagneticDeclination(float declination) { //Incoming units are degrees
secondaryImuState.magDeclination = declination * 10.0f; //Internally declination is stored in decidegrees
}
}

0 comments on commit 438dd40

Please sign in to comment.