mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
mixer_profile draft pr
This commit is contained in:
parent
80a3dee407
commit
cbbef19721
12 changed files with 53 additions and 11 deletions
|
@ -37,7 +37,7 @@
|
|||
#define PG_SYSTEM_CONFIG 18
|
||||
#define PG_FEATURE_CONFIG 19
|
||||
#define PG_MIXER_PROFILE 20
|
||||
#define PG_SERVO_MIXER 21
|
||||
// #define PG_SERVO_MIXER 21
|
||||
#define PG_IMU_CONFIG 22
|
||||
//#define PG_PROFILE_SELECTION 23
|
||||
#define PG_RX_CONFIG 24
|
||||
|
|
|
@ -1864,7 +1864,8 @@ static void cliServoMix(char *cmdline)
|
|||
printServoMix(DUMP_MASTER, customServoMixers(0), NULL);
|
||||
} else if (sl_strncasecmp(cmdline, "reset", 5) == 0) {
|
||||
// erase custom mixer
|
||||
pgResetCopy(customServoMixersMutable(0), PG_SERVO_MIXER);
|
||||
// pgResetCopy(customServoMixersMutable(0), PG_SERVO_MIXER);
|
||||
Reset_servoMixers(customServoMixersMutable(0));
|
||||
} else {
|
||||
enum {RULE = 0, TARGET, INPUT, RATE, SPEED, CONDITION, ARGS_COUNT};
|
||||
char *ptr = strtok_r(cmdline, " ", &saveptr);
|
||||
|
@ -3589,12 +3590,14 @@ static void printConfig(const char *cmdline, bool doDiff)
|
|||
|
||||
const int currentProfileIndexSave = getConfigProfile();
|
||||
const int currentBatteryProfileIndexSave = getConfigBatteryProfile();
|
||||
const int currentMixerProfileIndexSave = getConfigMixerProfile();
|
||||
backupConfigs();
|
||||
// reset all configs to defaults to do differencing
|
||||
resetConfigs();
|
||||
// restore the profile indices, since they should not be reset for proper comparison
|
||||
setConfigProfile(currentProfileIndexSave);
|
||||
setConfigBatteryProfile(currentBatteryProfileIndexSave);
|
||||
setConfigMixerProfile(currentMixerProfileIndexSave);
|
||||
|
||||
if (checkCommand(options, "showdefaults")) {
|
||||
dumpMask = dumpMask | SHOW_DEFAULTS; // add default values as comments for changed values
|
||||
|
@ -3622,8 +3625,8 @@ static void printConfig(const char *cmdline, bool doDiff)
|
|||
#endif
|
||||
}
|
||||
|
||||
// cliPrintHashLine("resources");
|
||||
//printResource(dumpMask, &defaultConfig);
|
||||
cliPrintHashLine("resources");
|
||||
// printResource(dumpMask, &defaultConfig);
|
||||
|
||||
// cliPrintHashLine("mixer");
|
||||
// cliDumpPrintLinef(dumpMask, primaryMotorMixer_CopyArray[0].throttle == 0.0f, "\r\nmmix reset\r\n");
|
||||
|
@ -3716,6 +3719,7 @@ static void printConfig(const char *cmdline, bool doDiff)
|
|||
// dump all profiles
|
||||
const int currentProfileIndexSave = getConfigProfile();
|
||||
const int currentBatteryProfileIndexSave = getConfigBatteryProfile();
|
||||
const int currentMixerProfileIndexSave = getConfigMixerProfile();
|
||||
for (int ii = 0; ii < MAX_PROFILE_COUNT; ++ii) {
|
||||
cliDumpProfile(ii, dumpMask);
|
||||
}
|
||||
|
@ -3727,10 +3731,11 @@ static void printConfig(const char *cmdline, bool doDiff)
|
|||
}
|
||||
setConfigProfile(currentProfileIndexSave);
|
||||
setConfigBatteryProfile(currentBatteryProfileIndexSave);
|
||||
setConfigMixerProfile(currentMixerProfileIndexSave);
|
||||
|
||||
cliPrintHashLine("restore original profile selection");
|
||||
cliPrintLinef("profile %d", currentProfileIndexSave + 1);
|
||||
cliPrintLinef("battery_profile %d", currentBatteryProfileIndexSave + 1);
|
||||
cliPrintLinef("mixer_profile %d", currentMixerProfileIndexSave + 1);
|
||||
|
||||
#ifdef USE_CLI_BATCH
|
||||
batchModeEnabled = false;
|
||||
|
|
|
@ -321,6 +321,7 @@ void readEEPROM(void)
|
|||
|
||||
setConfigProfile(getConfigProfile());
|
||||
setConfigBatteryProfile(getConfigBatteryProfile());
|
||||
setConfigMixerProfile(getConfigMixerProfile());
|
||||
|
||||
validateAndFixConfig();
|
||||
activateConfig();
|
||||
|
|
|
@ -62,12 +62,12 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance)
|
|||
// PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, primaryMotorMixer, PG_MOTOR_MIXER, 0);
|
||||
|
||||
bool OutputProfileHotSwitch(int profile_index)
|
||||
{
|
||||
{
|
||||
// does not work with timerHardwareOverride
|
||||
LOG_INFO(PWM, "OutputProfileHotSwitch");
|
||||
|
||||
//do not allow switching between multi rotor and non multi rotor
|
||||
#ifdef ENABLE_MCFW_MIXER_PROFILE_HOTSWAP
|
||||
#ifdef ENABLE_MIXER_PROFILE_MCFW_HOTSWAP
|
||||
bool MCFW_hotswap_unavailable = false;
|
||||
#else
|
||||
bool MCFW_hotswap_unavailable = true;
|
||||
|
@ -88,6 +88,7 @@ bool OutputProfileHotSwitch(int profile_index)
|
|||
LOG_INFO(PWM, "navModesEnabled");
|
||||
return false;
|
||||
}
|
||||
//TODO add check of each motor/servo is mapped before and after the switch
|
||||
|
||||
if (!setConfigMixerProfile(profile_index)){
|
||||
LOG_INFO(PWM, "failed to set config");
|
||||
|
@ -104,7 +105,7 @@ bool OutputProfileHotSwitch(int profile_index)
|
|||
pidInit();
|
||||
pidInitFilters();
|
||||
schedulePidGainsUpdate();
|
||||
navigationInit();
|
||||
// navigationInit(); //may need to initilize FW_HEADING_USE_YAW on rover or boat
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,5 +30,7 @@ static inline const mixerProfile_t* mixerProfiles_CopyArray_by_index(int _index)
|
|||
#define customServoMixers_CopyArray() (mixerProfiles_CopyArray_by_index(systemConfig()->current_mixer_profile_index)->ServoMixers)
|
||||
|
||||
#define mixerConfigByIndex(index) (&(mixerProfiles(index)->mixer_config))
|
||||
#define mixerMotorMixersByIndex(index) (&(mixerProfiles(index)->MotorMixers))
|
||||
#define mixerServoMixersByIndex(index) (&(mixerProfiles(index)->ServoMixers))
|
||||
|
||||
bool OutputProfileHotSwitch(int profile_index);
|
||||
|
|
|
@ -87,6 +87,22 @@ PG_RESET_TEMPLATE(servoConfig_t, servoConfig,
|
|||
// }
|
||||
// }
|
||||
|
||||
void Reset_servoMixers(servoMixer_t *instance)
|
||||
{
|
||||
for (int i = 0; i < MAX_SERVO_RULES; i++)
|
||||
{
|
||||
RESET_CONFIG(servoMixer_t, &instance[i],
|
||||
.targetChannel = 0,
|
||||
.inputSource = 0,
|
||||
.rate = 0,
|
||||
.speed = 0
|
||||
#ifdef USE_PROGRAMMING_FRAMEWORK
|
||||
,.conditionId = -1
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PG_REGISTER_ARRAY_WITH_RESET_FN(servoParam_t, MAX_SUPPORTED_SERVOS, servoParams, PG_SERVO_PARAMS, 3);
|
||||
|
||||
void pgResetFn_servoParams(servoParam_t *instance)
|
||||
|
|
|
@ -151,6 +151,7 @@ typedef struct servoMetadata_s {
|
|||
|
||||
extern int16_t servo[MAX_SUPPORTED_SERVOS];
|
||||
|
||||
void Reset_servoMixers(servoMixer_t* instance);
|
||||
bool isServoOutputEnabled(void);
|
||||
void setServoOutputEnabled(bool flag);
|
||||
bool isMixerUsingServos(void);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
timerHardware_t timerHardware[] = {
|
||||
DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM, 0, 0), // PPM
|
||||
#ifdef MATEKF405VTOL
|
||||
#ifdef MATEKF405VTOL//development purpose, TODO: remove it in the release
|
||||
DEF_TIM(TIM3, CH1, PC6, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1
|
||||
DEF_TIM(TIM8, CH2, PC7, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S2 UP(2,1)
|
||||
DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S3 UP(2,1)
|
||||
|
|
|
@ -197,5 +197,5 @@
|
|||
#define MAX_PWM_OUTPUT_PORTS 6
|
||||
|
||||
#ifdef MATEKF405VTOL
|
||||
#define ENABLE_MCFW_MIXER_PROFILE_HOTSWAP
|
||||
#define ENABLE_MIXER_PROFILE_MCFW_HOTSWAP
|
||||
#endif
|
|
@ -1,2 +1,3 @@
|
|||
target_stm32f405xg(MATEKF405TE)
|
||||
target_stm32f405xg(MATEKF405TE_SD)
|
||||
target_stm32f405xg(MATEKF405TE_SD_VTOL)
|
||||
|
|
|
@ -25,6 +25,18 @@
|
|||
#include "drivers/timer_def_stm32f4xx.h"
|
||||
|
||||
timerHardware_t timerHardware[] = {
|
||||
#ifdef MATEKF405TE_SD_VTOL
|
||||
//using d-shot on motors seems to have problems on s3,maybe dma related,maybe my board problem
|
||||
DEF_TIM(TIM8, CH4, PC9, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1 D(2,7,7) UP217
|
||||
DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S2 D(2,2,0) UP217
|
||||
DEF_TIM(TIM1, CH3N, PB15, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S3 D(2,6,0) UP256
|
||||
DEF_TIM(TIM1, CH1, PA8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 1), // S4 D(2,1,6) UP256
|
||||
|
||||
DEF_TIM(TIM2, CH4, PB11, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S5 D(1,7,3) UP173
|
||||
DEF_TIM(TIM2, CH3, PB10, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S6 D(1,1,3) UP173
|
||||
DEF_TIM(TIM2, CH2, PB3, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S7 D(1,6,3) UP173
|
||||
DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S8 D(1,5,3) UP173
|
||||
#else
|
||||
DEF_TIM(TIM8, CH4, PC9, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S1 D(2,7,7) UP217
|
||||
DEF_TIM(TIM8, CH3, PC8, TIM_USE_MC_MOTOR | TIM_USE_FW_MOTOR, 0, 0), // S2 D(2,2,0) UP217
|
||||
DEF_TIM(TIM1, CH3N, PB15, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S3 D(2,6,0) UP256
|
||||
|
@ -34,7 +46,7 @@ timerHardware_t timerHardware[] = {
|
|||
DEF_TIM(TIM2, CH3, PB10, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S6 D(1,1,3) UP173
|
||||
DEF_TIM(TIM2, CH2, PB3, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S7 D(1,6,3) UP173
|
||||
DEF_TIM(TIM2, CH1, PA15, TIM_USE_MC_MOTOR | TIM_USE_FW_SERVO, 0, 0), // S8 D(1,5,3) UP173
|
||||
|
||||
#endif
|
||||
DEF_TIM(TIM12, CH1, PB14, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S9 DMA NONE
|
||||
DEF_TIM(TIM13, CH1, PA6, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S10 DMA NONE
|
||||
DEF_TIM(TIM4, CH1, PB6, TIM_USE_MC_SERVO | TIM_USE_FW_SERVO, 0, 0), // S11 D(1,0,2)
|
||||
|
|
|
@ -180,3 +180,6 @@
|
|||
#define USE_DSHOT
|
||||
#define USE_ESC_SENSOR
|
||||
|
||||
#ifdef MATEKF405TE_SD_VTOL
|
||||
#define ENABLE_MIXER_PROFILE_MCFW_HOTSWAP
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue