1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00

Remove some unnecessary checks for mixer mode; Update state flags when mixer mode is changed

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2017-01-30 01:30:31 +10:00
parent 73a5459828
commit bbacaa7705
5 changed files with 29 additions and 25 deletions

View file

@ -273,14 +273,12 @@ static void initActiveBoxIds(void)
if (feature(FEATURE_SERVO_TILT))
activeBoxIds[activeBoxIdCount++] = BOXCAMSTAB;
bool isFixedWing = mixerConfig()->mixerMode == MIXER_FLYING_WING || mixerConfig()->mixerMode == MIXER_AIRPLANE || mixerConfig()->mixerMode == MIXER_CUSTOM_AIRPLANE;
#ifdef GPS
if (sensors(SENSOR_BARO) || (isFixedWing && feature(FEATURE_GPS))) {
if (sensors(SENSOR_BARO) || (STATE(FIXED_WING) && feature(FEATURE_GPS))) {
activeBoxIds[activeBoxIdCount++] = BOXNAVALTHOLD;
activeBoxIds[activeBoxIdCount++] = BOXSURFACE;
}
if ((feature(FEATURE_GPS) && sensors(SENSOR_MAG) && sensors(SENSOR_ACC)) || (isFixedWing && sensors(SENSOR_ACC) && feature(FEATURE_GPS))) {
if ((feature(FEATURE_GPS) && sensors(SENSOR_MAG) && sensors(SENSOR_ACC)) || (STATE(FIXED_WING) && sensors(SENSOR_ACC) && feature(FEATURE_GPS))) {
activeBoxIds[activeBoxIdCount++] = BOXNAVPOSHOLD;
activeBoxIds[activeBoxIdCount++] = BOXNAVRTH;
activeBoxIds[activeBoxIdCount++] = BOXNAVWP;
@ -289,7 +287,7 @@ static void initActiveBoxIds(void)
}
#endif
if (isFixedWing) {
if (STATE(FIXED_WING)) {
activeBoxIds[activeBoxIdCount++] = BOXPASSTHRU;
activeBoxIds[activeBoxIdCount++] = BOXNAVLAUNCH;
activeBoxIds[activeBoxIdCount++] = BOXAUTOTRIM;
@ -300,7 +298,7 @@ static void initActiveBoxIds(void)
* FLAPERON mode active only in case of airplane and custom airplane. Activating on
* flying wing can cause bad thing
*/
if (mixerConfig()->mixerMode == MIXER_AIRPLANE || mixerConfig()->mixerMode == MIXER_CUSTOM_AIRPLANE) {
if (STATE(FLAPERON_AVAILABLE)) {
activeBoxIds[activeBoxIdCount++] = BOXFLAPERON;
}
#endif
@ -1845,6 +1843,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
#ifndef USE_QUAD_MIXER_ONLY
case MSP_SET_MIXER:
mixerConfigMutable()->mixerMode = sbufReadU8(src);
mixerUpdateStateFlags(); // Required for correct preset functionality
break;
#endif