From a2a54c187727d7df68daeb2b0ae27d956b940ba7 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Sun, 14 Nov 2021 17:06:00 +0000 Subject: [PATCH] Update fc_msp_box.c --- src/main/fc/fc_msp_box.c | 77 ++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/src/main/fc/fc_msp_box.c b/src/main/fc/fc_msp_box.c index a56b81715..34404a6fe 100644 --- a/src/main/fc/fc_msp_box.c +++ b/src/main/fc/fc_msp_box.c @@ -185,57 +185,64 @@ void initActiveBoxIds(void) activeBoxIds[activeBoxIdCount++] = BOXHEADINGHOLD; - if (sensors(SENSOR_ACC) || sensors(SENSOR_MAG)) { - activeBoxIds[activeBoxIdCount++] = BOXHEADFREE; - activeBoxIds[activeBoxIdCount++] = BOXHEADADJ; - } - - if (STATE(ALTITUDE_CONTROL)) { + if (STATE(MULTIROTOR)) { + if ((sensors(SENSOR_ACC) || sensors(SENSOR_MAG))) { + activeBoxIds[activeBoxIdCount++] = BOXHEADFREE; + activeBoxIds[activeBoxIdCount++] = BOXHEADADJ; + } + if (sensors(SENSOR_BARO) && sensors(SENSOR_RANGEFINDER) && sensors(SENSOR_OPFLOW)) { + activeBoxIds[activeBoxIdCount++] = BOXSURFACE; + } activeBoxIds[activeBoxIdCount++] = BOXFPVANGLEMIX; } //Camstab mode is enabled always activeBoxIds[activeBoxIdCount++] = BOXCAMSTAB; + bool readyAltControl = false; + if (STATE(ALTITUDE_CONTROL) && sensors(SENSOR_BARO)) { + activeBoxIds[activeBoxIdCount++] = BOXNAVALTHOLD; + readyAltControl = true; #ifdef USE_GPS - if (STATE(ALTITUDE_CONTROL) && (sensors(SENSOR_BARO) || (feature(FEATURE_GPS) && (STATE(AIRPLANE) || positionEstimationConfig()->use_gps_no_baro)))) { + } else if ((feature(FEATURE_GPS) && STATE(AIRPLANE) && positionEstimationConfig()->use_gps_no_baro)) { activeBoxIds[activeBoxIdCount++] = BOXNAVALTHOLD; - activeBoxIds[activeBoxIdCount++] = BOXSURFACE; + readyAltControl = true; } - const bool navReadyMultirotor = STATE(MULTIROTOR) && (getHwCompassStatus() != HW_SENSOR_NONE) && sensors(SENSOR_ACC) && feature(FEATURE_GPS); - const bool navReadyOther = !STATE(MULTIROTOR) && sensors(SENSOR_ACC) && feature(FEATURE_GPS); - const bool navFlowDeadReckoning = sensors(SENSOR_OPFLOW) && sensors(SENSOR_ACC) && positionEstimationConfig()->allow_dead_reckoning; - if (navFlowDeadReckoning || navReadyMultirotor || navReadyOther) { - if (!STATE(ROVER) && !STATE(BOAT)) { - activeBoxIds[activeBoxIdCount++] = BOXNAVPOSHOLD; - } - if (STATE(AIRPLANE)) { - activeBoxIds[activeBoxIdCount++] = BOXLOITERDIRCHN; + if (readyAltControl) { + const bool navReadyMultirotor = STATE(MULTIROTOR) && (getHwCompassStatus() != HW_SENSOR_NONE) && sensors(SENSOR_ACC) && feature(FEATURE_GPS); + const bool navReadyOther = !STATE(MULTIROTOR) && sensors(SENSOR_ACC) && feature(FEATURE_GPS); + const bool navFlowDeadReckoning = sensors(SENSOR_OPFLOW) && sensors(SENSOR_ACC) && positionEstimationConfig()->allow_dead_reckoning; + if (navFlowDeadReckoning || navReadyMultirotor || navReadyOther) { + if (!STATE(ROVER) && !STATE(BOAT)) { + activeBoxIds[activeBoxIdCount++] = BOXNAVPOSHOLD; + } + if (STATE(AIRPLANE)) { + activeBoxIds[activeBoxIdCount++] = BOXLOITERDIRCHN; + } } - } - if (navReadyMultirotor || navReadyOther) { - activeBoxIds[activeBoxIdCount++] = BOXNAVRTH; - activeBoxIds[activeBoxIdCount++] = BOXNAVWP; - activeBoxIds[activeBoxIdCount++] = BOXHOMERESET; - activeBoxIds[activeBoxIdCount++] = BOXGCSNAV; - activeBoxIds[activeBoxIdCount++] = BOXPLANWPMISSION; - - if (STATE(AIRPLANE)) { - activeBoxIds[activeBoxIdCount++] = BOXNAVCOURSEHOLD; - activeBoxIds[activeBoxIdCount++] = BOXNAVCRUISE; - activeBoxIds[activeBoxIdCount++] = BOXSOARING; + if (navReadyMultirotor || navReadyOther) { + activeBoxIds[activeBoxIdCount++] = BOXNAVRTH; + activeBoxIds[activeBoxIdCount++] = BOXNAVWP; + activeBoxIds[activeBoxIdCount++] = BOXHOMERESET; + activeBoxIds[activeBoxIdCount++] = BOXGCSNAV; + activeBoxIds[activeBoxIdCount++] = BOXPLANWPMISSION; + + if (STATE(AIRPLANE)) { + activeBoxIds[activeBoxIdCount++] = BOXNAVCOURSEHOLD; + activeBoxIds[activeBoxIdCount++] = BOXNAVCRUISE; + activeBoxIds[activeBoxIdCount++] = BOXSOARING; + } } - } #ifdef USE_MR_BRAKING_MODE - if (mixerConfig()->platformType == PLATFORM_MULTIROTOR) { - activeBoxIds[activeBoxIdCount++] = BOXBRAKING; - } -#endif - + if (mixerConfig()->platformType == PLATFORM_MULTIROTOR) { + activeBoxIds[activeBoxIdCount++] = BOXBRAKING; + } #endif +#endif // GPS + } if (STATE(AIRPLANE) || STATE(ROVER) || STATE(BOAT)) { activeBoxIds[activeBoxIdCount++] = BOXMANUAL; -- 2.11.4.GIT