1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00

Tidy of mixer and servo code

This commit is contained in:
Martin Budden 2017-05-16 20:01:14 +01:00
parent d8c4953bb5
commit 6645d43949
4 changed files with 31 additions and 31 deletions

View file

@ -25,8 +25,8 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "common/axis.h" #include "common/axis.h"
#include "common/maths.h"
#include "common/filter.h" #include "common/filter.h"
#include "common/maths.h"
#include "config/feature.h" #include "config/feature.h"
#include "config/parameter_group.h" #include "config/parameter_group.h"
@ -38,18 +38,19 @@
#include "io/motors.h" #include "io/motors.h"
#include "fc/config.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h"
#include "flight/failsafe.h"
#include "flight/imu.h"
#include "flight/mixer.h"
#include "flight/pid.h"
#include "rx/rx.h" #include "rx/rx.h"
#include "sensors/battery.h" #include "sensors/battery.h"
#include "flight/mixer.h"
#include "flight/failsafe.h"
#include "flight/pid.h"
#include "flight/imu.h"
#include "fc/config.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h"
PG_REGISTER_WITH_RESET_TEMPLATE(flight3DConfig_t, flight3DConfig, PG_MOTOR_3D_CONFIG, 0); PG_REGISTER_WITH_RESET_TEMPLATE(flight3DConfig_t, flight3DConfig, PG_MOTOR_3D_CONFIG, 0);

View file

@ -29,27 +29,27 @@
#include "common/filter.h" #include "common/filter.h"
#include "common/maths.h" #include "common/maths.h"
#include "config/config_reset.h"
#include "config/feature.h"
#include "config/parameter_group.h" #include "config/parameter_group.h"
#include "config/parameter_group_ids.h" #include "config/parameter_group_ids.h"
#include "config/config_reset.h"
#include "drivers/pwm_output.h" #include "drivers/pwm_output.h"
#include "drivers/system.h" #include "drivers/system.h"
#include "rx/rx.h" #include "fc/config.h"
#include "fc/rc_controls.h"
#include "io/gimbal.h" #include "fc/runtime_config.h"
#include "flight/imu.h" #include "flight/imu.h"
#include "flight/mixer.h" #include "flight/mixer.h"
#include "flight/pid.h" #include "flight/pid.h"
#include "flight/servos.h" #include "flight/servos.h"
#include "fc/config.h" #include "io/gimbal.h"
#include "fc/rc_controls.h"
#include "fc/runtime_config.h" #include "rx/rx.h"
#include "config/feature.h"
extern mixerMode_e currentMixerMode; extern mixerMode_e currentMixerMode;
@ -92,9 +92,10 @@ void pgResetFn_servoParams(servoParam_t *instance)
// no template required since default is zero // no template required since default is zero
PG_REGISTER(gimbalConfig_t, gimbalConfig, PG_GIMBAL_CONFIG, 0); PG_REGISTER(gimbalConfig_t, gimbalConfig, PG_GIMBAL_CONFIG, 0);
int16_t servo[MAX_SUPPORTED_SERVOS];
static uint8_t servoRuleCount = 0; static uint8_t servoRuleCount = 0;
static servoMixer_t currentServoMixer[MAX_SERVO_RULES]; static servoMixer_t currentServoMixer[MAX_SERVO_RULES];
int16_t servo[MAX_SUPPORTED_SERVOS];
static int useServo; static int useServo;
@ -103,17 +104,17 @@ static int useServo;
static const servoMixer_t servoMixerAirplane[] = { static const servoMixer_t servoMixerAirplane[] = {
{ SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 },
{ SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 },
{ SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0, 0, 100, 0 }, { SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0, 0, 100, 0 },
{ SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 }, { SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 },
{ SERVO_THROTTLE, INPUT_STABILIZED_THROTTLE, 100, 0, 0, 100, 0 }, { SERVO_THROTTLE, INPUT_STABILIZED_THROTTLE, 100, 0, 0, 100, 0 },
}; };
static const servoMixer_t servoMixerFlyingWing[] = { static const servoMixer_t servoMixerFlyingWing[] = {
{ SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0, 0, 100, 0 },
{ SERVO_FLAPPERON_1, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_1, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 },
{ SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, -100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, -100, 0, 0, 100, 0 },
{ SERVO_FLAPPERON_2, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 }, { SERVO_FLAPPERON_2, INPUT_STABILIZED_PITCH, 100, 0, 0, 100, 0 },
{ SERVO_THROTTLE, INPUT_STABILIZED_THROTTLE, 100, 0, 0, 100, 0 }, { SERVO_THROTTLE, INPUT_STABILIZED_THROTTLE, 100, 0, 0, 100, 0 },
}; };
static const servoMixer_t servoMixerBI[] = { static const servoMixer_t servoMixerBI[] = {
@ -226,7 +227,7 @@ void loadCustomServoMixer(void)
memset(currentServoMixer, 0, sizeof(currentServoMixer)); memset(currentServoMixer, 0, sizeof(currentServoMixer));
// load custom mixer into currentServoMixer // load custom mixer into currentServoMixer
for (uint8_t i = 0; i < MAX_SERVO_RULES; i++) { for (int i = 0; i < MAX_SERVO_RULES; i++) {
// check if done // check if done
if (customServoMixers(i)->rate == 0) if (customServoMixers(i)->rate == 0)
break; break;
@ -368,7 +369,6 @@ STATIC_UNIT_TESTED void servoMixer(void)
{ {
int16_t input[INPUT_SOURCE_COUNT]; // Range [-500:+500] int16_t input[INPUT_SOURCE_COUNT]; // Range [-500:+500]
static int16_t currentOutput[MAX_SERVO_RULES]; static int16_t currentOutput[MAX_SERVO_RULES];
uint8_t i;
if (FLIGHT_MODE(PASSTHRU_MODE)) { if (FLIGHT_MODE(PASSTHRU_MODE)) {
// Direct passthru from RX // Direct passthru from RX
@ -407,8 +407,9 @@ STATIC_UNIT_TESTED void servoMixer(void)
input[INPUT_RC_AUX3] = rcData[AUX3] - rxConfig()->midrc; input[INPUT_RC_AUX3] = rcData[AUX3] - rxConfig()->midrc;
input[INPUT_RC_AUX4] = rcData[AUX4] - rxConfig()->midrc; input[INPUT_RC_AUX4] = rcData[AUX4] - rxConfig()->midrc;
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
servo[i] = 0; servo[i] = 0;
}
// mix servos according to rules // mix servos according to rules
for (i = 0; i < servoRuleCount; i++) { for (i = 0; i < servoRuleCount; i++) {

View file

@ -27,9 +27,10 @@
#include "common/axis.h" #include "common/axis.h"
#include "common/filter.h" #include "common/filter.h"
#include "config/config_reset.h"
#include "config/feature.h"
#include "config/parameter_group.h" #include "config/parameter_group.h"
#include "config/parameter_group_ids.h" #include "config/parameter_group_ids.h"
#include "config/config_reset.h"
#include "drivers/accgyro/accgyro.h" #include "drivers/accgyro/accgyro.h"
#include "drivers/accgyro/accgyro_adxl345.h" #include "drivers/accgyro/accgyro_adxl345.h"
@ -61,8 +62,6 @@
#include "sensors/gyro.h" #include "sensors/gyro.h"
#include "sensors/sensors.h" #include "sensors/sensors.h"
#include "config/feature.h"
#ifdef USE_HARDWARE_REVISION_DETECTION #ifdef USE_HARDWARE_REVISION_DETECTION
#include "hardware_revision.h" #include "hardware_revision.h"
#endif #endif

View file

@ -17,9 +17,8 @@
#pragma once #pragma once
#include "config/parameter_group.h"
#include "common/axis.h" #include "common/axis.h"
#include "drivers/io_types.h" #include "config/parameter_group.h"
#include "drivers/sensor.h" #include "drivers/sensor.h"
typedef enum { typedef enum {