mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 09:45:33 +03:00
Remove some unnecessary checks for mixer mode; Update state flags when mixer mode is changed
This commit is contained in:
parent
73a5459828
commit
bbacaa7705
5 changed files with 29 additions and 25 deletions
|
@ -242,6 +242,7 @@ void init(void)
|
|||
|
||||
#ifdef USE_SERVOS
|
||||
servosInit();
|
||||
mixerUpdateStateFlags(); // This needs to be called early to allow pwm mapper to use information about FIXED_WING state
|
||||
#endif
|
||||
|
||||
drv_pwm_config_t pwm_params;
|
||||
|
@ -259,10 +260,7 @@ void init(void)
|
|||
#endif
|
||||
|
||||
// when using airplane/wing mixer, servo/motor outputs are remapped
|
||||
if (mixerConfig()->mixerMode == MIXER_AIRPLANE || mixerConfig()->mixerMode == MIXER_FLYING_WING || mixerConfig()->mixerMode == MIXER_CUSTOM_AIRPLANE)
|
||||
pwm_params.airplane = true;
|
||||
else
|
||||
pwm_params.airplane = false;
|
||||
pwm_params.airplane = STATE(FIXED_WING);
|
||||
#if defined(USE_UART2) && defined(STM32F10X)
|
||||
pwm_params.useUART2 = doesConfigurationUsePort(SERIAL_PORT_USART2);
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -304,6 +304,27 @@ bool isMixerEnabled(mixerMode_e mixerMode)
|
|||
}
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
void mixerUpdateStateFlags(void)
|
||||
{
|
||||
const mixerMode_e currentMixerMode = mixerConfig()->mixerMode;
|
||||
|
||||
// set flag that we're on something with wings
|
||||
if (currentMixerMode == MIXER_FLYING_WING ||
|
||||
currentMixerMode == MIXER_AIRPLANE ||
|
||||
currentMixerMode == MIXER_CUSTOM_AIRPLANE
|
||||
) {
|
||||
ENABLE_STATE(FIXED_WING);
|
||||
} else {
|
||||
DISABLE_STATE(FIXED_WING);
|
||||
}
|
||||
|
||||
if (currentMixerMode == MIXER_AIRPLANE || currentMixerMode == MIXER_CUSTOM_AIRPLANE) {
|
||||
ENABLE_STATE(FLAPERON_AVAILABLE);
|
||||
} else {
|
||||
DISABLE_STATE(FLAPERON_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void mixerUsePWMIOConfiguration(void)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -123,6 +123,7 @@ extern bool motorLimitReached;
|
|||
void writeAllMotors(int16_t mc);
|
||||
void mixerLoadMix(int index, motorMixer_t *customMixers);
|
||||
void mixerUsePWMIOConfiguration(void);
|
||||
void mixerUpdateStateFlags(void);
|
||||
void mixerResetDisarmedMotors(void);
|
||||
void mixTable(void);
|
||||
void writeMotors(void);
|
||||
|
|
|
@ -199,21 +199,6 @@ int servoDirection(int servoIndex, int inputSource)
|
|||
void servosInit(void)
|
||||
{
|
||||
const mixerMode_e currentMixerMode = mixerConfig()->mixerMode;
|
||||
// set flag that we're on something with wings
|
||||
if (currentMixerMode == MIXER_FLYING_WING ||
|
||||
currentMixerMode == MIXER_AIRPLANE ||
|
||||
currentMixerMode == MIXER_CUSTOM_AIRPLANE
|
||||
) {
|
||||
ENABLE_STATE(FIXED_WING);
|
||||
} else {
|
||||
DISABLE_STATE(FIXED_WING);
|
||||
}
|
||||
|
||||
if (currentMixerMode == MIXER_AIRPLANE || currentMixerMode == MIXER_CUSTOM_AIRPLANE) {
|
||||
ENABLE_STATE(FLAPERON_AVAILABLE);
|
||||
} else {
|
||||
DISABLE_STATE(FLAPERON_AVAILABLE);
|
||||
}
|
||||
|
||||
minServoIndex = servoMixers[currentMixerMode].minServoIndex;
|
||||
maxServoIndex = servoMixers[currentMixerMode].maxServoIndex;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue