mirror of https://github.com/ArduPilot/ardupilot
Teach the compass init code how to detect whether there is a compass present
at all. This lets systems where it's optional decide whether to try to use it or not... git-svn-id: https://arducopter.googlecode.com/svn/trunk@684 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
2e5be5d86b
commit
502b6ee0f7
|
@ -1,3 +1,4 @@
|
|||
// -*- tab-width: 4; Mode: C++; c-basic-offset: 3; indent-tabs-mode: t -*-
|
||||
/*
|
||||
APM_Compass.cpp - Arduino Library for HMC5843 I2C Magnetometer
|
||||
Code by Jordi Muñoz and Jose Julio. DIYDrones.com
|
||||
|
@ -78,7 +79,7 @@ APM_Compass_Class::APM_Compass_Class() : orientation(0), declination(0.0)
|
|||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
void APM_Compass_Class::Init(void)
|
||||
bool APM_Compass_Class::Init(void)
|
||||
{
|
||||
unsigned long currentTime = millis(); // record current time
|
||||
int numAttempts = 0;
|
||||
|
@ -102,7 +103,8 @@ void APM_Compass_Class::Init(void)
|
|||
Wire.beginTransmission(CompassAddress);
|
||||
Wire.send(ConfigRegA);
|
||||
Wire.send(PositiveBiasConfig);
|
||||
Wire.endTransmission();
|
||||
if (0 != Wire.endTransmission())
|
||||
continue; // compass not responding on the bus
|
||||
delay(50);
|
||||
|
||||
// set gains
|
||||
|
@ -146,6 +148,7 @@ void APM_Compass_Class::Init(void)
|
|||
Wire.endTransmission(); // End transmission
|
||||
delay(50);
|
||||
}
|
||||
return(success);
|
||||
}
|
||||
|
||||
// Read Sensor data
|
||||
|
|
|
@ -35,7 +35,7 @@ class APM_Compass_Class
|
|||
unsigned long lastUpdate;
|
||||
|
||||
APM_Compass_Class(); // Constructor
|
||||
void Init();
|
||||
bool Init();
|
||||
void Read();
|
||||
void Calculate(float roll, float pitch);
|
||||
void SetOrientation(int newOrientation);
|
||||
|
|
Loading…
Reference in New Issue