Remove useServos from core_t since it's only needed for initial startup

and by the mixer.  main.c now asks the mixer if it needs to use servos
and the mixer decides this in mixerInit().  Main already has a
dependency on the mixer.  This allows future commits to further clean up
core_t which is still a source of dependency problems.
This commit is contained in:
Dominic Clifton 2014-04-18 21:15:50 +01:00
parent 7b079ca297
commit 94c0f87c45
4 changed files with 15 additions and 6 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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