mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Preparation for conversion to parameter groups 10
This commit is contained in:
parent
ba6f3a0046
commit
90c8ed5e3e
14 changed files with 63 additions and 70 deletions
|
@ -38,11 +38,11 @@
|
|||
#include "rx/rx.h"
|
||||
|
||||
#include "io/gimbal.h"
|
||||
#include "io/servos.h"
|
||||
|
||||
#include "flight/imu.h"
|
||||
#include "flight/mixer.h"
|
||||
#include "flight/pid.h"
|
||||
#include "flight/imu.h"
|
||||
#include "flight/servos.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/rc_controls.h"
|
||||
|
@ -52,8 +52,6 @@
|
|||
|
||||
extern mixerMode_e currentMixerMode;
|
||||
|
||||
static servoMixerConfig_t *servoMixerConfig;
|
||||
|
||||
static uint8_t servoRuleCount = 0;
|
||||
static servoMixer_t currentServoMixer[MAX_SERVO_RULES];
|
||||
int16_t servo[MAX_SUPPORTED_SERVOS];
|
||||
|
@ -113,6 +111,12 @@ static const servoMixer_t servoMixerGimbal[] = {
|
|||
};
|
||||
|
||||
|
||||
// Custom mixer configuration
|
||||
typedef struct mixerRules_s {
|
||||
uint8_t servoRuleCount;
|
||||
const servoMixer_t *rule;
|
||||
} mixerRules_t;
|
||||
|
||||
const mixerRules_t servoMixers[] = {
|
||||
{ 0, NULL }, // entry 0
|
||||
{ COUNT_SERVO_RULES(servoMixerTri), servoMixerTri }, // MULTITYPE_TRI
|
||||
|
@ -145,9 +149,8 @@ const mixerRules_t servoMixers[] = {
|
|||
|
||||
static const servoMixer_t *customServoMixers;
|
||||
|
||||
void servoUseConfigs(servoMixerConfig_t *servoMixerConfigToUse, servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse)
|
||||
void servoUseConfigs(servoParam_t *servoParamsToUse, struct channelForwardingConfig_s *channelForwardingConfigToUse)
|
||||
{
|
||||
servoMixerConfig = servoMixerConfigToUse;
|
||||
servoConf = servoParamsToUse;
|
||||
channelForwardingConfig = channelForwardingConfigToUse;
|
||||
}
|
||||
|
@ -267,10 +270,15 @@ static void updateGimbalServos(uint8_t firstServoIndex)
|
|||
pwmWriteServo(firstServoIndex + 1, servo[SERVO_GIMBAL_ROLL]);
|
||||
}
|
||||
|
||||
static void servoTable(void);
|
||||
static void filterServos(void);
|
||||
|
||||
void writeServos(void)
|
||||
{
|
||||
uint8_t servoIndex = 0;
|
||||
servoTable();
|
||||
filterServos();
|
||||
|
||||
uint8_t servoIndex = 0;
|
||||
switch (currentMixerMode) {
|
||||
case MIXER_BICOPTER:
|
||||
pwmWriteServo(servoIndex++, servo[SERVO_BICOPTER_LEFT]);
|
||||
|
@ -279,7 +287,7 @@ void writeServos(void)
|
|||
|
||||
case MIXER_TRI:
|
||||
case MIXER_CUSTOM_TRI:
|
||||
if (servoMixerConfig()->tri_unarmed_servo) {
|
||||
if (servoConfig()->tri_unarmed_servo) {
|
||||
// if unarmed flag set, we always move servo
|
||||
pwmWriteServo(servoIndex++, servo[SERVO_RUDDER]);
|
||||
} else {
|
||||
|
@ -409,7 +417,7 @@ STATIC_UNIT_TESTED void servoMixer(void)
|
|||
}
|
||||
|
||||
|
||||
void servoTable(void)
|
||||
static void servoTable(void)
|
||||
{
|
||||
// airplane / servo mixes
|
||||
switch (currentMixerMode) {
|
||||
|
@ -464,7 +472,7 @@ bool isMixerUsingServos(void)
|
|||
return useServo;
|
||||
}
|
||||
|
||||
void filterServos(void)
|
||||
static void filterServos(void)
|
||||
{
|
||||
static int16_t servoIdx;
|
||||
static bool servoFilterIsSet;
|
||||
|
@ -474,10 +482,10 @@ void filterServos(void)
|
|||
uint32_t startTime = micros();
|
||||
#endif
|
||||
|
||||
if (servoMixerConfig()->servo_lowpass_enable) {
|
||||
if (servoConfig()->servo_lowpass_freq) {
|
||||
for (servoIdx = 0; servoIdx < MAX_SUPPORTED_SERVOS; servoIdx++) {
|
||||
if (!servoFilterIsSet) {
|
||||
biquadFilterInitLPF(&servoFilter[servoIdx], servoMixerConfig()->servo_lowpass_freq, targetPidLooptime);
|
||||
biquadFilterInitLPF(&servoFilter[servoIdx], servoConfig()->servo_lowpass_freq, targetPidLooptime);
|
||||
servoFilterIsSet = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue