1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-14 20:10:15 +03:00

add mode to swtich mixer profile

This commit is contained in:
shota 2023-07-01 13:01:37 +09:00
parent 2fb9601dd6
commit 1839a458d2
4 changed files with 27 additions and 13 deletions

View file

@ -349,6 +349,11 @@ void initActiveBoxIds(void)
ADD_ACTIVE_BOX(BOXTURTLE);
}
#endif
#if (MAX_MIXER_PROFILE_COUNT > 1)
ADD_ACTIVE_BOX(BOXMIXERPROFILE);
ADD_ACTIVE_BOX(BOXMIXERTRANSITION);
#endif
}
#define IS_ENABLED(mask) ((mask) == 0 ? 0 : 1)
@ -415,7 +420,10 @@ void packBoxModeFlags(boxBitmask_t * mspBoxModeFlags)
#ifdef USE_MULTI_MISSION
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCHANGEMISSION)), BOXCHANGEMISSION);
#endif
#if (MAX_MIXER_PROFILE_COUNT > 1)
CHECK_ACTIVE_BOX(IS_ENABLED(currentMixerProfileIndex));
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXMIXERTRANSITION)));
#endif
memset(mspBoxModeFlags, 0, sizeof(boxBitmask_t));
for (uint32_t i = 0; i < activeBoxIdCount; i++) {
if (activeBoxes[activeBoxIds[i]]) {

View file

@ -67,13 +67,9 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance)
}
}
void loadMixerConfig(void) {
void mixerConfigInit(void){
currentMixerProfileIndex=getConfigMixerProfile();
currentMixerConfig=*mixerConfig();
}
void mixerConfigInit(void){
loadMixerConfig();
servosInit();
mixerUpdateStateFlags();
mixerInit();
@ -134,25 +130,32 @@ static int computeServoCountByMixerProfileIndex(int index)
}
}
void outputProfileUpdateTask(timeUs_t currentTimeUs) {
UNUSED(currentTimeUs);
outputProfileHotSwitch((int) IS_RC_MODE_ACTIVE(BOXMIXERPROFILE));
}
//switch mixerprofile without reboot
bool OutputProfileHotSwitch(int profile_index)
bool outputProfileHotSwitch(int profile_index)
{
static bool allow_hot_switch = true;
// does not work with timerHardwareOverride,need to set mixerConfig()->outputMode == OUTPUT_MODE_AUTO
LOG_INFO(PWM, "OutputProfileHotSwitch");
// LOG_INFO(PWM, "OutputProfileHotSwitch");
if (!allow_hot_switch)
{
return false;
}
if (currentMixerProfileIndex == profile_index)
{
return false;
}
if (profile_index < 0 || profile_index >= MAX_MIXER_PROFILE_COUNT)
{ // sanity check
LOG_INFO(PWM, "invalid mixer profile index");
return false;
}
if (currentMixerProfileIndex == profile_index)
{
return false;
}
if (areSensorsCalibrating()) {//it seems like switching before sensors calibration complete will cause pid stops to respond, especially in D,TODO
return false;
}

View file

@ -44,5 +44,6 @@ static inline const mixerProfile_t* mixerProfiles_CopyArray_by_index(int _index)
#define mixerMotorMixersByIndex(index) (&(mixerProfiles(index)->MotorMixers))
#define mixerServoMixersByIndex(index) (&(mixerProfiles(index)->ServoMixers))
bool OutputProfileHotSwitch(int profile_index);
bool outputProfileHotSwitch(int profile_index);
void mixerConfigInit(void);
void outputProfileUpdateTask(timeUs_t currentTimeUs);

View file

@ -26,8 +26,10 @@
#include "programming/logic_condition.h"
#include "programming/pid.h"
#include "flight/mixer_profile.h"
void programmingFrameworkUpdateTask(timeUs_t currentTimeUs) {
programmingPidUpdateTask(currentTimeUs);
outputProfileUpdateTask(currentTimeUs);
logicConditionUpdateTask(currentTimeUs);
}