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:
parent
2fb9601dd6
commit
1839a458d2
4 changed files with 27 additions and 13 deletions
|
@ -349,6 +349,11 @@ void initActiveBoxIds(void)
|
||||||
ADD_ACTIVE_BOX(BOXTURTLE);
|
ADD_ACTIVE_BOX(BOXTURTLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (MAX_MIXER_PROFILE_COUNT > 1)
|
||||||
|
ADD_ACTIVE_BOX(BOXMIXERPROFILE);
|
||||||
|
ADD_ACTIVE_BOX(BOXMIXERTRANSITION);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_ENABLED(mask) ((mask) == 0 ? 0 : 1)
|
#define IS_ENABLED(mask) ((mask) == 0 ? 0 : 1)
|
||||||
|
@ -415,7 +420,10 @@ void packBoxModeFlags(boxBitmask_t * mspBoxModeFlags)
|
||||||
#ifdef USE_MULTI_MISSION
|
#ifdef USE_MULTI_MISSION
|
||||||
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCHANGEMISSION)), BOXCHANGEMISSION);
|
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCHANGEMISSION)), BOXCHANGEMISSION);
|
||||||
#endif
|
#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));
|
memset(mspBoxModeFlags, 0, sizeof(boxBitmask_t));
|
||||||
for (uint32_t i = 0; i < activeBoxIdCount; i++) {
|
for (uint32_t i = 0; i < activeBoxIdCount; i++) {
|
||||||
if (activeBoxes[activeBoxIds[i]]) {
|
if (activeBoxes[activeBoxIds[i]]) {
|
||||||
|
|
|
@ -67,13 +67,9 @@ void pgResetFn_mixerProfiles(mixerProfile_t *instance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadMixerConfig(void) {
|
void mixerConfigInit(void){
|
||||||
currentMixerProfileIndex=getConfigMixerProfile();
|
currentMixerProfileIndex=getConfigMixerProfile();
|
||||||
currentMixerConfig=*mixerConfig();
|
currentMixerConfig=*mixerConfig();
|
||||||
}
|
|
||||||
|
|
||||||
void mixerConfigInit(void){
|
|
||||||
loadMixerConfig();
|
|
||||||
servosInit();
|
servosInit();
|
||||||
mixerUpdateStateFlags();
|
mixerUpdateStateFlags();
|
||||||
mixerInit();
|
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
|
//switch mixerprofile without reboot
|
||||||
bool OutputProfileHotSwitch(int profile_index)
|
bool outputProfileHotSwitch(int profile_index)
|
||||||
{
|
{
|
||||||
static bool allow_hot_switch = true;
|
static bool allow_hot_switch = true;
|
||||||
// does not work with timerHardwareOverride,need to set mixerConfig()->outputMode == OUTPUT_MODE_AUTO
|
// 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)
|
if (!allow_hot_switch)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (currentMixerProfileIndex == profile_index)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (profile_index < 0 || profile_index >= MAX_MIXER_PROFILE_COUNT)
|
if (profile_index < 0 || profile_index >= MAX_MIXER_PROFILE_COUNT)
|
||||||
{ // sanity check
|
{ // sanity check
|
||||||
LOG_INFO(PWM, "invalid mixer profile index");
|
LOG_INFO(PWM, "invalid mixer profile index");
|
||||||
return false;
|
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
|
if (areSensorsCalibrating()) {//it seems like switching before sensors calibration complete will cause pid stops to respond, especially in D,TODO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,5 +44,6 @@ static inline const mixerProfile_t* mixerProfiles_CopyArray_by_index(int _index)
|
||||||
#define mixerMotorMixersByIndex(index) (&(mixerProfiles(index)->MotorMixers))
|
#define mixerMotorMixersByIndex(index) (&(mixerProfiles(index)->MotorMixers))
|
||||||
#define mixerServoMixersByIndex(index) (&(mixerProfiles(index)->ServoMixers))
|
#define mixerServoMixersByIndex(index) (&(mixerProfiles(index)->ServoMixers))
|
||||||
|
|
||||||
bool OutputProfileHotSwitch(int profile_index);
|
bool outputProfileHotSwitch(int profile_index);
|
||||||
void mixerConfigInit(void);
|
void mixerConfigInit(void);
|
||||||
|
void outputProfileUpdateTask(timeUs_t currentTimeUs);
|
|
@ -26,8 +26,10 @@
|
||||||
|
|
||||||
#include "programming/logic_condition.h"
|
#include "programming/logic_condition.h"
|
||||||
#include "programming/pid.h"
|
#include "programming/pid.h"
|
||||||
|
#include "flight/mixer_profile.h"
|
||||||
|
|
||||||
void programmingFrameworkUpdateTask(timeUs_t currentTimeUs) {
|
void programmingFrameworkUpdateTask(timeUs_t currentTimeUs) {
|
||||||
programmingPidUpdateTask(currentTimeUs);
|
programmingPidUpdateTask(currentTimeUs);
|
||||||
|
outputProfileUpdateTask(currentTimeUs);
|
||||||
logicConditionUpdateTask(currentTimeUs);
|
logicConditionUpdateTask(currentTimeUs);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue