Browse Source

Include compass in OSD sensors calibration message

master
Hubert Jozwiak 4 years ago
parent
commit
60494f44ac
  1. 1
      AUTHORS
  2. 13
      src/main/fc/fc_core.c
  3. 2
      src/main/fc/fc_core.h
  4. 10
      src/main/sensors/compass.c
  5. 1
      src/main/sensors/compass.h
  6. 2
      src/main/telemetry/mavlink.c

1
AUTHORS

@ -35,6 +35,7 @@ Gaël James
Gregor Ottmann
Google LLC
Hyon Lim
Hubert Jozwiak
James Harrison
Jan Staal
Jeremy Waters

13
src/main/fc/fc_core.c

@ -45,6 +45,7 @@ FILE_COMPILE_FOR_SPEED
#include "sensors/boardalignment.h"
#include "sensors/acceleration.h"
#include "sensors/barometer.h"
#include "sensors/compass.h"
#include "sensors/pitotmeter.h"
#include "sensors/gyro.h"
#include "sensors/battery.h"
@ -135,7 +136,7 @@ static emergencyArmingState_t emergencyArming;
static bool prearmWasReset = false; // Prearm must be reset (RC Mode not active) before arming is possible
static timeMs_t prearmActivationTime = 0;
bool isCalibrating(void)
bool areSensorsCalibrating(void)
{
#ifdef USE_BARO
if (sensors(SENSOR_BARO) && !baroIsCalibrationComplete()) {
@ -143,6 +144,12 @@ bool isCalibrating(void)
}
#endif
#ifdef USE_MAG
if (sensors(SENSOR_MAG) && !compassIsCalibrationComplete()) {
return true;
}
#endif
#ifdef USE_PITOT
if (sensors(SENSOR_PITOT) && !pitotIsCalibrationComplete()) {
return true;
@ -183,7 +190,7 @@ static void updateArmingStatus(void)
} else {
/* CHECK: Run-time calibration */
static bool calibratingFinishedBeep = false;
if (isCalibrating()) {
if (areSensorsCalibrating()) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_SENSORS_CALIBRATING);
calibratingFinishedBeep = false;
}
@ -711,7 +718,7 @@ void processRx(timeUs_t currentTimeUs)
// Handle passthrough mode
if (STATE(FIXED_WING_LEGACY)) {
if ((IS_RC_MODE_ACTIVE(BOXMANUAL) && !navigationRequiresAngleMode() && !failsafeRequiresAngleMode()) || // Normal activation of passthrough
(!ARMING_FLAG(ARMED) && isCalibrating())){ // Backup - if we are not armed - enforce passthrough while calibrating
(!ARMING_FLAG(ARMED) && areSensorsCalibrating())){ // Backup - if we are not armed - enforce passthrough while calibrating
ENABLE_FLIGHT_MODE(MANUAL_MODE);
} else {
DISABLE_FLIGHT_MODE(MANUAL_MODE);

2
src/main/fc/fc_core.h

@ -43,7 +43,7 @@ disarmReason_t getDisarmReason(void);
void emergencyArmingUpdate(bool armingSwitchIsOn);
bool isCalibrating(void);
bool areSensorsCalibrating(void);
float getFlightTime(void);
float getArmTime(void);

10
src/main/sensors/compass.c

@ -329,6 +329,16 @@ bool compassIsReady(void)
return magUpdatedAtLeastOnce;
}
bool compassIsCalibrationComplete(void)
{
if (STATE(COMPASS_CALIBRATED)) {
return true;
}
else {
return false;
}
}
void compassUpdate(timeUs_t currentTimeUs)
{
static sensorCalibrationState_t calState;

1
src/main/sensors/compass.h

@ -78,5 +78,6 @@ bool compassInit(void);
void compassUpdate(timeUs_t currentTimeUs);
bool compassIsReady(void);
bool compassIsHealthy(void);
bool compassIsCalibrationComplete(void);
#endif

2
src/main/telemetry/mavlink.c

@ -733,7 +733,7 @@ void mavlinkSendHUDAndHeartbeat(void)
mavSystemState = MAV_STATE_ACTIVE;
}
}
else if (isCalibrating()) {
else if (areSensorsCalibrating()) {
mavSystemState = MAV_STATE_CALIBRATING;
}
else {

Loading…
Cancel
Save