Trainer function can now replace the channels values instead of to the sticks positions (#6561)
This commit is contained in:
@@ -165,11 +165,13 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
|
||||
|
||||
case FUNC_TRAINER:
|
||||
{
|
||||
uint8_t mask = 0x0f;
|
||||
if (CFN_CH_INDEX(cfn) > 0) {
|
||||
mask = (1<<(CFN_CH_INDEX(cfn)-1));
|
||||
}
|
||||
newActiveFunctions |= mask;
|
||||
uint8_t param = CFN_CH_INDEX(cfn);
|
||||
if (param == 0)
|
||||
newActiveFunctions |= 0x0F;
|
||||
else if (param <= NUM_STICKS)
|
||||
newActiveFunctions |= (1 << (param-1));
|
||||
else if (param == NUM_STICKS + 1)
|
||||
newActiveFunctions |= (1 << FUNCTION_TRAINER_CHANNELS);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
else
|
||||
#endif
|
||||
if (func == FUNC_TRAINER) {
|
||||
maxParam = 4;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
||||
maxParam = NUM_STICKS + 1;
|
||||
uint8_t param = CFN_CH_INDEX(cfn);
|
||||
if (param == NUM_STICKS + 1)
|
||||
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, "Chans", attr);
|
||||
else
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_CH_INDEX(cfn) == 0 ? 0 : MIXSRC_Rud + CFN_CH_INDEX(cfn) - 1, attr);
|
||||
}
|
||||
#if defined(GVARS)
|
||||
else if (func == FUNC_ADJUST_GVAR) {
|
||||
|
||||
@@ -214,8 +214,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
else
|
||||
#endif
|
||||
if (func == FUNC_TRAINER) {
|
||||
maxParam = NUM_STICKS;
|
||||
drawSource(lcdNextPos, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
||||
maxParam = NUM_STICKS + 1;
|
||||
uint8_t param = CFN_CH_INDEX(cfn);
|
||||
if (param == NUM_STICKS + 1)
|
||||
lcdDrawText(lcdNextPos, y, "Chans", attr);
|
||||
else
|
||||
drawSource(lcdNextPos, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
||||
}
|
||||
#if defined(GVARS)
|
||||
else if (func == FUNC_ADJUST_GVAR) {
|
||||
|
||||
@@ -215,8 +215,12 @@ bool menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
else
|
||||
#endif
|
||||
if (func == FUNC_TRAINER) {
|
||||
maxParam = 4;
|
||||
drawSource(MODEL_SPECIAL_FUNC_2ND_COLUMN_EXT, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
||||
maxParam = NUM_STICKS + 1;
|
||||
uint8_t param = CFN_CH_INDEX(cfn);
|
||||
if (param == NUM_STICKS + 1)
|
||||
lcdDrawText(MODEL_SPECIAL_FUNC_2ND_COLUMN_EXT, y, "Chans", attr);
|
||||
else
|
||||
drawSource(MODEL_SPECIAL_FUNC_2ND_COLUMN_EXT, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
||||
}
|
||||
#if defined(GVARS)
|
||||
else if (func == FUNC_ADJUST_GVAR) {
|
||||
|
||||
+19
-13
@@ -224,6 +224,17 @@ void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx, int16_t ovwrValue
|
||||
// rescaled from -262144 to 262144
|
||||
int16_t applyLimits(uint8_t channel, int32_t value)
|
||||
{
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) {
|
||||
// safety channel available for channel check
|
||||
return calc100toRESX(safetyCh[channel]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (isFunctionActive(FUNCTION_TRAINER_CHANNELS) && IS_TRAINER_INPUT_VALID()) {
|
||||
return ppmInput[channel];
|
||||
}
|
||||
|
||||
LimitData * lim = limitAddress(channel);
|
||||
|
||||
if (lim->curve) {
|
||||
@@ -277,17 +288,12 @@ int16_t applyLimits(uint8_t channel, int32_t value)
|
||||
ofs += tmp; // ofs can to added directly because already recalculated,
|
||||
}
|
||||
|
||||
if (ofs > lim_p) ofs = lim_p;
|
||||
if (ofs < lim_n) ofs = lim_n;
|
||||
|
||||
if (lim->revert) ofs = -ofs; // finally do the reverse.
|
||||
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) {
|
||||
// safety channel available for channel check
|
||||
ofs = calc100toRESX(safetyCh[channel]);
|
||||
}
|
||||
#endif
|
||||
if (ofs > lim_p)
|
||||
ofs = lim_p;
|
||||
if (ofs < lim_n)
|
||||
ofs = lim_n;
|
||||
if (lim->revert)
|
||||
ofs = -ofs; // finally do the reverse.
|
||||
|
||||
return ofs;
|
||||
}
|
||||
@@ -467,12 +473,12 @@ void evalInputs(uint8_t mode)
|
||||
v = 0;
|
||||
}
|
||||
|
||||
if (mode <= e_perout_mode_inactive_flight_mode && isFunctionActive(FUNCTION_TRAINER+ch) && IS_TRAINER_INPUT_VALID()) {
|
||||
if (mode <= e_perout_mode_inactive_flight_mode && isFunctionActive(FUNCTION_TRAINER_STICK1+ch) && IS_TRAINER_INPUT_VALID()) {
|
||||
// trainer mode
|
||||
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
||||
if (td->mode) {
|
||||
uint8_t chStud = td->srcChn;
|
||||
int32_t vStud = (ppmInput[chStud]- g_eeGeneral.trainer.calib[chStud]);
|
||||
int32_t vStud = (ppmInput[chStud] - g_eeGeneral.trainer.calib[chStud]);
|
||||
vStud *= td->studWeight;
|
||||
vStud /= 50;
|
||||
switch (td->mode) {
|
||||
|
||||
+3
-2
@@ -909,8 +909,9 @@ uint8_t lswFamily(uint8_t func);
|
||||
int16_t lswTimerValue(delayval_t val);
|
||||
|
||||
enum FunctionsActive {
|
||||
FUNCTION_TRAINER,
|
||||
FUNCTION_INSTANT_TRIM = FUNCTION_TRAINER+4,
|
||||
FUNCTION_TRAINER_STICK1,
|
||||
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + NUM_STICKS,
|
||||
FUNCTION_INSTANT_TRIM,
|
||||
FUNCTION_VARIO,
|
||||
FUNCTION_BACKLIGHT,
|
||||
#if defined(SDCARD)
|
||||
|
||||
Reference in New Issue
Block a user