Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include compass in OSD sensors calibration message #6995

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Gaël James
Gregor Ottmann
Google LLC
Hyon Lim
Hubert Jozwiak
James Harrison
Jan Staal
Jeremy Waters
Expand Down
13 changes: 10 additions & 3 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -135,14 +136,20 @@ 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()) {
return true;
}
#endif

#ifdef USE_MAG
if (sensors(SENSOR_MAG) && !compassIsCalibrationComplete()) {
return true;
}
#endif

#ifdef USE_PITOT
if (sensors(SENSOR_PITOT) && !pitotIsCalibrationComplete()) {
return true;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/fc_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ disarmReason_t getDisarmReason(void);

void emergencyArmingUpdate(bool armingSwitchIsOn);

bool isCalibrating(void);
bool areSensorsCalibrating(void);
float getFlightTime(void);
float getArmTime(void);

Expand Down
10 changes: 10 additions & 0 deletions src/main/sensors/compass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/sensors/compass.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ bool compassInit(void);
void compassUpdate(timeUs_t currentTimeUs);
bool compassIsReady(void);
bool compassIsHealthy(void);
bool compassIsCalibrationComplete(void);

#endif
2 changes: 1 addition & 1 deletion src/main/telemetry/mavlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void mavlinkSendHUDAndHeartbeat(void)
mavSystemState = MAV_STATE_ACTIVE;
}
}
else if (isCalibrating()) {
else if (areSensorsCalibrating()) {
mavSystemState = MAV_STATE_CALIBRATING;
}
else {
Expand Down