1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Fixing gimbal_flags not working when feature SERVO_TILT was enabled. This was done by properly calculating servo offset instead of depending on enabled features/mixers.

This commit is contained in:
dongie 2014-06-11 15:10:17 +09:00
parent ab87a99238
commit 2fef9d5fa9
6 changed files with 33 additions and 8 deletions

View file

@ -1,3 +1,7 @@
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#include "board.h" #include "board.h"
/* /*
@ -361,7 +365,8 @@ bool pwmInit(drv_pwm_config_t *init)
} }
if (init->extraServos && !init->airplane) { if (init->extraServos && !init->airplane) {
// remap PWM5..8 as servos when used in extended servo mode // remap PWM5..8 as servos when used in extended servo mode.
// condition for airplane because airPPM already has these as servos
if (port >= PWM5 && port <= PWM8) if (port >= PWM5 && port <= PWM8)
mask = TYPE_S; mask = TYPE_S;
} }
@ -390,6 +395,10 @@ bool pwmInit(drv_pwm_config_t *init)
pwmWritePtr = pwmWriteStandard; pwmWritePtr = pwmWriteStandard;
if (init->motorPwmRate > 500) if (init->motorPwmRate > 500)
pwmWritePtr = pwmWriteBrushed; pwmWritePtr = pwmWriteBrushed;
// set return values in init struct
init->numServos = numServos;
return false; return false;
} }

View file

@ -1,3 +1,7 @@
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#pragma once #pragma once
#define MAX_MOTORS 12 #define MAX_MOTORS 12
@ -22,6 +26,9 @@ typedef struct drv_pwm_config_t {
// some higher value (used by 3d mode), or 0, for brushed pwm drivers. // some higher value (used by 3d mode), or 0, for brushed pwm drivers.
uint16_t servoCenterPulse; uint16_t servoCenterPulse;
uint16_t failsafeThreshold; uint16_t failsafeThreshold;
// OUT parameters, filled by driver
uint8_t numServos;
} drv_pwm_config_t; } drv_pwm_config_t;
// This indexes into the read-only hardware definition structure in drv_pwm.c, as well as into pwmPorts[] structure with dynamic data. // This indexes into the read-only hardware definition structure in drv_pwm.c, as well as into pwmPorts[] structure with dynamic data.

View file

@ -1,3 +1,7 @@
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#include "board.h" #include "board.h"
#include "mw.h" #include "mw.h"
@ -126,6 +130,7 @@ int main(void)
} }
pwmInit(&pwm_params); pwmInit(&pwm_params);
core.numServos = pwm_params.numServos;
// configure PWM/CPPM read function and max number of channels. spektrum or sbus below will override both of these, if enabled // configure PWM/CPPM read function and max number of channels. spektrum or sbus below will override both of these, if enabled
for (i = 0; i < RC_CHANS; i++) for (i = 0; i < RC_CHANS; i++)

View file

@ -1,3 +1,7 @@
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#include "board.h" #include "board.h"
#include "mw.h" #include "mw.h"
@ -468,13 +472,10 @@ void mixTable(void)
// forward AUX1-4 to servo outputs (not constrained) // forward AUX1-4 to servo outputs (not constrained)
if (cfg.gimbal_flags & GIMBAL_FORWARDAUX) { if (cfg.gimbal_flags & GIMBAL_FORWARDAUX) {
int offset = 0; int offset = core.numServos - 4;
// offset servos based off number already used in mixer types // offset servos based off number already used in mixer types
// airplane and servo_tilt together can't be used // airplane and servo_tilt together can't be used
if (mcfg.mixerConfiguration == MULTITYPE_AIRPLANE || mcfg.mixerConfiguration == MULTITYPE_FLYING_WING) // calculate offset by taking 4 from core.numServos
offset = 4;
else if (mixers[mcfg.mixerConfiguration].useServo)
offset = 2;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
pwmWriteServo(i + offset, rcData[AUX1 + i]); pwmWriteServo(i + offset, rcData[AUX1 + i]);
} }

View file

@ -1,3 +1,7 @@
/*
* This file is part of baseflight
* Licensed under GPL V3 or modified DCL - see https://github.com/multiwii/baseflight/blob/master/README.md
*/
#include "board.h" #include "board.h"
#include "mw.h" #include "mw.h"
@ -97,8 +101,6 @@ void annexCode(void)
static int64_t mAhdrawnRaw = 0; static int64_t mAhdrawnRaw = 0;
static int32_t vbatCycleTime = 0; static int32_t vbatCycleTime = 0;
int i;
// PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value // PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value
if (rcData[THROTTLE] < cfg.tpa_breakpoint) { if (rcData[THROTTLE] < cfg.tpa_breakpoint) {
prop2 = 100; prop2 = 100;

View file

@ -311,6 +311,7 @@ typedef struct core_t {
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. 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.
uint8_t numRCChannels; // number of rc channels as reported by current input driver uint8_t numRCChannels; // number of rc channels as reported by current input driver
bool useServo; // feature SERVO_TILT or wing/airplane mixers will enable this bool useServo; // feature SERVO_TILT or wing/airplane mixers will enable this
uint8_t numServos; // how many total hardware servos we have. used by mixer
} core_t; } core_t;
typedef struct flags_t { typedef struct flags_t {