mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 01:05:21 +03:00
Merge pull request #1066 from martinbudden/inav_pg14_mixerConfig
Added mixerConfig parameter group
This commit is contained in:
commit
a966135eb5
10 changed files with 39 additions and 42 deletions
|
@ -65,8 +65,6 @@
|
|||
#define navConfigMutable(x) (&masterConfig.navConfig)
|
||||
#define armingConfig(x) (&masterConfig.armingConfig)
|
||||
#define armingConfigMutable(x) (&masterConfig.armingConfig)
|
||||
#define mixerConfig(x) (&masterConfig.mixerConfig)
|
||||
#define mixerConfigMutable(x) (&masterConfig.mixerConfig)
|
||||
#define serialConfig(x) (&masterConfig.serialConfig)
|
||||
#define serialConfigMutable(x) (&masterConfig.serialConfig)
|
||||
#define telemetryConfig(x) (&masterConfig.telemetryConfig)
|
||||
|
@ -139,9 +137,6 @@ typedef struct master_s {
|
|||
|
||||
armingConfig_t armingConfig;
|
||||
|
||||
// mixer-related configuration
|
||||
mixerConfig_t mixerConfig;
|
||||
|
||||
serialConfig_t serialConfig;
|
||||
#ifdef TELEMETRY
|
||||
telemetryConfig_t telemetryConfig;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
//#define PG_TRANSPONDER_CONFIG 17
|
||||
//#define PG_SYSTEM_CONFIG 18
|
||||
//#define PG_FEATURE_CONFIG 19
|
||||
//#define PG_MIXER_CONFIG 20
|
||||
#define PG_MIXER_CONFIG 20
|
||||
//#define PG_SERVO_MIXER 21
|
||||
//#define PG_IMU_CONFIG 22
|
||||
//#define PG_PROFILE_SELECTION 23
|
||||
|
|
|
@ -324,12 +324,6 @@ void resetRcControlsConfig(rcControlsConfig_t *rcControlsConfig)
|
|||
rcControlsConfig->alt_hold_deadband = 50;
|
||||
}
|
||||
|
||||
static void resetMixerConfig(mixerConfig_t *mixerConfig)
|
||||
{
|
||||
mixerConfig->yaw_motor_direction = 1;
|
||||
mixerConfig->yaw_jump_prevention_limit = 200;
|
||||
}
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
static void resetServoMixerConfig(servoMixerConfig_t *servoMixerConfig)
|
||||
{
|
||||
|
@ -385,7 +379,6 @@ void createDefaultConfig(master_t *config)
|
|||
memset(config, 0, sizeof(master_t));
|
||||
|
||||
config->version = EEPROM_CONF_VERSION;
|
||||
config->mixerConfig.mixerMode = MIXER_QUADX;
|
||||
|
||||
uint32_t *featuresPtr = &config->enabledFeatures;
|
||||
intFeatureClearAll(featuresPtr);
|
||||
|
@ -424,7 +417,6 @@ void createDefaultConfig(master_t *config)
|
|||
config->armingConfig.disarm_kill_switch = 1;
|
||||
config->armingConfig.auto_disarm_delay = 5;
|
||||
|
||||
resetMixerConfig(&config->mixerConfig);
|
||||
#ifdef USE_SERVOS
|
||||
resetServoMixerConfig(&config->servoMixerConfig);
|
||||
resetServoConfig(&config->servoConfig);
|
||||
|
@ -632,7 +624,7 @@ static void activateConfig(void)
|
|||
setAccelerationCalibrationValues();
|
||||
setAccelerationFilter();
|
||||
|
||||
mixerUseConfigs(&masterConfig.flight3DConfig, &masterConfig.mixerConfig);
|
||||
mixerUseConfigs(&masterConfig.flight3DConfig);
|
||||
#ifdef USE_SERVOS
|
||||
servosUseConfigs(&masterConfig.servoMixerConfig, masterConfig.servoConf);
|
||||
#endif
|
||||
|
|
|
@ -607,6 +607,10 @@ static const clivalue_t valueTable[] = {
|
|||
{ "current_meter_offset", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 3300 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, currentMeterOffset) },
|
||||
{ "multiwii_current_meter_output", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, multiwiiCurrentMeterOutput) },
|
||||
{ "current_meter_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_CURRENT_SENSOR }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, currentMeterType) },
|
||||
|
||||
// PG_MIXER_CONFIG
|
||||
{ "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, .config.minmax = { -1, 1 }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, yaw_motor_direction) },
|
||||
{ "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, .config.minmax = { YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, yaw_jump_prevention_limit) },
|
||||
};
|
||||
|
||||
#else
|
||||
|
@ -760,8 +764,6 @@ const clivalue_t valueTable[] = {
|
|||
|
||||
{ "throttle_tilt_comp_str", VAR_UINT8 | MASTER_VALUE, &masterConfig.throttle_tilt_compensation_strength, .config.minmax = { 0, 100 }, },
|
||||
|
||||
{ "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &mixerConfig()->yaw_motor_direction, .config.minmax = { -1, 1 } },
|
||||
{ "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, &mixerConfig()->yaw_jump_prevention_limit, .config.minmax = { YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH } },
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
{ "flaperon_throw_offset", VAR_INT16 | MASTER_VALUE, &masterConfig.flaperon_throw_offset, .config.minmax = { FLAPERON_THROW_MIN, FLAPERON_THROW_MAX} },
|
||||
|
@ -1097,6 +1099,7 @@ static boardAlignment_t boardAlignmentCopy;
|
|||
static gimbalConfig_t gimbalConfigCopy;
|
||||
#endif
|
||||
static motorMixer_t customMotorMixerCopy[MAX_SUPPORTED_MOTORS];
|
||||
static mixerConfig_t mixerConfigCopy;
|
||||
|
||||
static void backupConfigs(void)
|
||||
{
|
||||
|
@ -1127,6 +1130,7 @@ static void backupConfigs(void)
|
|||
for (int ii = 0; ii < MAX_SUPPORTED_MOTORS; ++ii) {
|
||||
customMotorMixerCopy[ii] = *customMotorMixer(ii);
|
||||
}
|
||||
mixerConfigCopy = *mixerConfig();
|
||||
}
|
||||
|
||||
static void restoreConfigs(void)
|
||||
|
@ -1157,6 +1161,7 @@ static void restoreConfigs(void)
|
|||
for (int ii = 0; ii < MAX_SUPPORTED_MOTORS; ++ii) {
|
||||
*customMotorMixerMutable(ii) = customMotorMixerCopy[ii];
|
||||
}
|
||||
*mixerConfigMutable() = mixerConfigCopy;
|
||||
}
|
||||
|
||||
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
||||
|
@ -2855,7 +2860,7 @@ static void cliMixer(char *cmdline)
|
|||
len = strlen(cmdline);
|
||||
|
||||
if (len == 0) {
|
||||
cliPrintf("Mixer: %s\r\n", mixerNames[mixerConfig()->mixerMode - 1]);
|
||||
cliPrintf("Mixer: %s\r\n", mixerNames[mixerConfigMutable()->mixerMode - 1]);
|
||||
return;
|
||||
} else if (strncasecmp(cmdline, "list", len) == 0) {
|
||||
cliPrint("Available mixers: ");
|
||||
|
@ -2874,7 +2879,7 @@ static void cliMixer(char *cmdline)
|
|||
return;
|
||||
}
|
||||
if (strncasecmp(cmdline, mixerNames[i], len) == 0) {
|
||||
mixerConfig()->mixerMode = i + 1;
|
||||
mixerConfigMutable()->mixerMode = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3346,10 +3351,10 @@ static void printConfig(char *cmdline, bool doDiff)
|
|||
|
||||
#ifndef USE_QUAD_MIXER_ONLY
|
||||
cliPrintHashLine("mixer");
|
||||
const bool equalsDefault = masterConfig.mixerConfig.mixerMode == defaultConfig.mixerConfig.mixerMode;
|
||||
const bool equalsDefault = mixerConfigCopy.mixerMode == mixerConfig()->mixerMode;
|
||||
const char *formatMixer = "mixer %s\r\n";
|
||||
cliDefaultPrintf(dumpMask, equalsDefault, formatMixer, mixerNames[defaultConfig.mixerConfig.mixerMode - 1]);
|
||||
cliDumpPrintf(dumpMask, equalsDefault, formatMixer, mixerNames[masterConfig.mixerConfig.mixerMode - 1]);
|
||||
cliDefaultPrintf(dumpMask, equalsDefault, formatMixer, mixerNames[mixerConfig()->mixerMode - 1]);
|
||||
cliDumpPrintf(dumpMask, equalsDefault, formatMixer, mixerNames[mixerConfig()->mixerMode - 1]);
|
||||
|
||||
cliDumpPrintf(dumpMask, customMotorMixer(0)->throttle == 0.0f, "\r\nmmix reset\r\n\r\n");
|
||||
|
||||
|
|
|
@ -68,9 +68,16 @@ int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
|
|||
|
||||
bool motorLimitReached = false;
|
||||
|
||||
mixerConfig_t *mixerConfig;
|
||||
static flight3DConfig_t *flight3DConfig;
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(mixerConfig_t, mixerConfig, PG_MIXER_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig,
|
||||
.mixerMode = MIXER_QUADX,
|
||||
.yaw_motor_direction = 1,
|
||||
.yaw_jump_prevention_limit = 200
|
||||
);
|
||||
|
||||
static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS];
|
||||
|
||||
PG_REGISTER_ARR(motorMixer_t, MAX_SUPPORTED_MOTORS, customMotorMixer, PG_MOTOR_MIXER, 0);
|
||||
|
@ -263,11 +270,9 @@ const mixer_t mixers[] = {
|
|||
#endif // USE_QUAD_MIXER_ONLY
|
||||
|
||||
void mixerUseConfigs(
|
||||
flight3DConfig_t *flight3DConfigToUse,
|
||||
mixerConfig_t *mixerConfigToUse)
|
||||
flight3DConfig_t *flight3DConfigToUse)
|
||||
{
|
||||
flight3DConfig = flight3DConfigToUse;
|
||||
mixerConfig = mixerConfigToUse;
|
||||
}
|
||||
|
||||
bool isMixerEnabled(mixerMode_e mixerMode)
|
||||
|
@ -394,9 +399,9 @@ void mixTable(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (motorCount >= 4 && mixerConfig->yaw_jump_prevention_limit < YAW_JUMP_PREVENTION_LIMIT_HIGH) {
|
||||
if (motorCount >= 4 && mixerConfig()->yaw_jump_prevention_limit < YAW_JUMP_PREVENTION_LIMIT_HIGH) {
|
||||
// prevent "yaw jump" during yaw correction
|
||||
axisPID[YAW] = constrain(axisPID[YAW], -mixerConfig->yaw_jump_prevention_limit - ABS(rcCommand[YAW]), mixerConfig->yaw_jump_prevention_limit + ABS(rcCommand[YAW]));
|
||||
axisPID[YAW] = constrain(axisPID[YAW], -mixerConfig()->yaw_jump_prevention_limit - ABS(rcCommand[YAW]), mixerConfig()->yaw_jump_prevention_limit + ABS(rcCommand[YAW]));
|
||||
}
|
||||
|
||||
// Initial mixer concept by bdoiron74 reused and optimized for Air Mode
|
||||
|
@ -409,7 +414,7 @@ void mixTable(void)
|
|||
rpyMix[i] =
|
||||
axisPID[PITCH] * currentMixer[i].pitch +
|
||||
axisPID[ROLL] * currentMixer[i].roll +
|
||||
-mixerConfig->yaw_motor_direction * axisPID[YAW] * currentMixer[i].yaw;
|
||||
-mixerConfig()->yaw_motor_direction * axisPID[YAW] * currentMixer[i].yaw;
|
||||
|
||||
if (rpyMix[i] > rpyMixMax) rpyMixMax = rpyMix[i];
|
||||
if (rpyMix[i] < rpyMixMin) rpyMixMin = rpyMix[i];
|
||||
|
|
|
@ -97,6 +97,8 @@ typedef struct mixerConfig_s {
|
|||
uint16_t yaw_jump_prevention_limit; // make limit configurable (original fixed value was 100)
|
||||
} mixerConfig_t;
|
||||
|
||||
PG_DECLARE(mixerConfig_t, mixerConfig);
|
||||
|
||||
typedef struct flight3DConfig_s {
|
||||
uint16_t deadband3d_low; // min 3d value
|
||||
uint16_t deadband3d_high; // max 3d value
|
||||
|
@ -110,10 +112,8 @@ extern int16_t motor[MAX_SUPPORTED_MOTORS];
|
|||
extern int16_t motor_disarmed[MAX_SUPPORTED_MOTORS];
|
||||
extern bool motorLimitReached;
|
||||
|
||||
struct motorConfig_s;
|
||||
void mixerUseConfigs(
|
||||
flight3DConfig_t *flight3DConfigToUse,
|
||||
mixerConfig_t *mixerConfigToUse);
|
||||
flight3DConfig_t *flight3DConfigToUse);
|
||||
|
||||
void writeAllMotors(int16_t mc);
|
||||
void mixerLoadMix(int index, motorMixer_t *customMixers);
|
||||
|
|
|
@ -102,6 +102,14 @@ static const servoMixer_t servoMixerTri[] = {
|
|||
{ SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0, 0, 100 },
|
||||
};
|
||||
|
||||
// Custom mixer configuration
|
||||
typedef struct mixerRules_s {
|
||||
uint8_t servoRuleCount;
|
||||
uint8_t minServoIndex;
|
||||
uint8_t maxServoIndex;
|
||||
const servoMixer_t *rule;
|
||||
} mixerRules_t;
|
||||
|
||||
const mixerRules_t servoMixers[] = {
|
||||
{ 0, 0, 0, NULL }, // entry 0
|
||||
{ COUNT_SERVO_RULES(servoMixerTri), SERVO_RUDDER, SERVO_RUDDER, servoMixerTri }, // MULTITYPE_TRI
|
||||
|
|
|
@ -96,14 +96,6 @@ typedef struct servoMixer_s {
|
|||
#define MAX_SERVO_SPEED UINT8_MAX
|
||||
#define MAX_SERVO_BOXES 3
|
||||
|
||||
// Custom mixer configuration
|
||||
typedef struct mixerRules_s {
|
||||
uint8_t servoRuleCount;
|
||||
uint8_t minServoIndex;
|
||||
uint8_t maxServoIndex;
|
||||
const servoMixer_t *rule;
|
||||
} mixerRules_t;
|
||||
|
||||
typedef struct servoParam_s {
|
||||
int16_t min; // servo min
|
||||
int16_t max; // servo max
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
|
||||
void targetConfiguration(master_t *config)
|
||||
{
|
||||
config->mixerConfig.mixerMode = MIXER_HEX6X;
|
||||
mixerConfigMutable()->mixerMode = MIXER_HEX6X;
|
||||
rxConfigMutable()->serialrx_provider = 2;
|
||||
featureSet(FEATURE_RX_SERIAL);
|
||||
config->serialConfig.portConfigs[2].functionMask = FUNCTION_RX_SERIAL;
|
||||
|
|
|
@ -90,7 +90,7 @@ void targetConfiguration(master_t *config)
|
|||
featureSet(FEATURE_FAILSAFE);
|
||||
|
||||
config->serialConfig.portConfigs[0].functionMask = FUNCTION_MSP;
|
||||
if(featureConfigured(FEATURE_RX_SERIAL)) {
|
||||
if (featureConfigured(FEATURE_RX_SERIAL)) {
|
||||
config->serialConfig.portConfigs[2].functionMask = FUNCTION_RX_SERIAL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue