diff --git a/src/flight_mixer.c b/src/flight_mixer.c index b1105aed4..603959d20 100755 --- a/src/flight_mixer.c +++ b/src/flight_mixer.c @@ -12,6 +12,8 @@ int16_t motor[MAX_MOTORS]; int16_t motor_disarmed[MAX_MOTORS]; int16_t servo[MAX_SERVOS] = { 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500 }; +static int useServo; + static motorMixer_t currentMixer[MAX_MOTORS]; static const motorMixer_t mixerTri[] = { @@ -189,10 +191,10 @@ void mixerInit(void) int i; // enable servos for mixes that require them. note, this shifts motor counts. - core.useServo = mixers[mcfg.mixerConfiguration].useServo; + useServo = mixers[mcfg.mixerConfiguration].useServo; // if we want camstab/trig, that also enables servos, even if mixer doesn't if (feature(FEATURE_SERVO_TILT)) - core.useServo = 1; + useServo = 1; if (mcfg.mixerConfiguration == MULTITYPE_CUSTOM) { // load custom mixer into currentMixer @@ -266,7 +268,7 @@ static void updateGimbalServos(void) void writeServos(void) { - if (!core.useServo) + if (!useServo) return; switch (mcfg.mixerConfiguration) { @@ -521,3 +523,8 @@ void mixTable(void) } } } + +bool isMixerUsingServos(void) +{ + return useServo; +} diff --git a/src/flight_mixer.h b/src/flight_mixer.h index d5c1919bc..8398c084f 100644 --- a/src/flight_mixer.h +++ b/src/flight_mixer.h @@ -52,3 +52,5 @@ typedef struct servoParam_t { int8_t rate; // range [-100;+100] ; can be used to ajust a rate 0-100% and a direction int8_t forwardFromChannel; // RX channel index, 0 based. See CHANNEL_FORWARDING_DISABLED } servoParam_t; + +bool isMixerUsingServos(void); diff --git a/src/main.c b/src/main.c index 971470331..a12b05ef4 100755 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ #include "board.h" #include "flight_common.h" +#include "flight_mixer.h" #include "mw.h" #include "gps_common.h" @@ -44,7 +45,7 @@ int main(void) // We have these sensors; SENSORS_SET defined in board.h depending on hardware platform sensorsSet(SENSORS_SET); - mixerInit(); // this will set core.useServo var depending on mixer type + mixerInit(); // when using airplane/wing mixer, servo/motor outputs are remapped if (mcfg.mixerConfiguration == MULTITYPE_AIRPLANE || mcfg.mixerConfiguration == MULTITYPE_FLYING_WING) pwm_params.airplane = true; @@ -54,7 +55,7 @@ int main(void) pwm_params.useSoftSerial = feature(FEATURE_SOFTSERIAL); pwm_params.usePPM = feature(FEATURE_PPM); pwm_params.enableInput = !feature(FEATURE_SERIALRX); // disable inputs if using spektrum - pwm_params.useServos = core.useServo; + pwm_params.useServos = isMixerUsingServos(); pwm_params.extraServos = cfg.gimbal_flags & GIMBAL_FORWARDAUX; pwm_params.motorPwmRate = mcfg.motor_pwm_rate; pwm_params.servoPwmRate = mcfg.servo_pwm_rate; diff --git a/src/runtime_config.h b/src/runtime_config.h index 347b80b58..d9bfb9483 100644 --- a/src/runtime_config.h +++ b/src/runtime_config.h @@ -54,7 +54,6 @@ typedef struct core_t { serialPort_t *telemport; serialPort_t *rcvrport; uint8_t mpu6050_scale; // es/non-es variance between MPU6050 sensors, half my boards are mpu6000ES, need this to be dynamic. automatically set by mpu6050 driver. - bool useServo; // feature SERVO_TILT or wing/airplane mixers will enable this } core_t; typedef void (* pidControllerFuncPtr)(void); // pid controller function prototype