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:
|
case FUNC_TRAINER:
|
||||||
{
|
{
|
||||||
uint8_t mask = 0x0f;
|
uint8_t param = CFN_CH_INDEX(cfn);
|
||||||
if (CFN_CH_INDEX(cfn) > 0) {
|
if (param == 0)
|
||||||
mask = (1<<(CFN_CH_INDEX(cfn)-1));
|
newActiveFunctions |= 0x0F;
|
||||||
}
|
else if (param <= NUM_STICKS)
|
||||||
newActiveFunctions |= mask;
|
newActiveFunctions |= (1 << (param-1));
|
||||||
|
else if (param == NUM_STICKS + 1)
|
||||||
|
newActiveFunctions |= (1 << FUNCTION_TRAINER_CHANNELS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,8 +222,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (func == FUNC_TRAINER) {
|
if (func == FUNC_TRAINER) {
|
||||||
maxParam = 4;
|
maxParam = NUM_STICKS + 1;
|
||||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
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)
|
#if defined(GVARS)
|
||||||
else if (func == FUNC_ADJUST_GVAR) {
|
else if (func == FUNC_ADJUST_GVAR) {
|
||||||
|
|||||||
@@ -214,8 +214,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (func == FUNC_TRAINER) {
|
if (func == FUNC_TRAINER) {
|
||||||
maxParam = NUM_STICKS;
|
maxParam = NUM_STICKS + 1;
|
||||||
drawSource(lcdNextPos, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
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)
|
#if defined(GVARS)
|
||||||
else if (func == FUNC_ADJUST_GVAR) {
|
else if (func == FUNC_ADJUST_GVAR) {
|
||||||
|
|||||||
@@ -215,8 +215,12 @@ bool menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (func == FUNC_TRAINER) {
|
if (func == FUNC_TRAINER) {
|
||||||
maxParam = 4;
|
maxParam = NUM_STICKS + 1;
|
||||||
drawSource(MODEL_SPECIAL_FUNC_2ND_COLUMN_EXT, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr);
|
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)
|
#if defined(GVARS)
|
||||||
else if (func == FUNC_ADJUST_GVAR) {
|
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
|
// rescaled from -262144 to 262144
|
||||||
int16_t applyLimits(uint8_t channel, int32_t value)
|
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);
|
LimitData * lim = limitAddress(channel);
|
||||||
|
|
||||||
if (lim->curve) {
|
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,
|
ofs += tmp; // ofs can to added directly because already recalculated,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ofs > lim_p) ofs = lim_p;
|
if (ofs > lim_p)
|
||||||
if (ofs < lim_n) ofs = lim_n;
|
ofs = lim_p;
|
||||||
|
if (ofs < lim_n)
|
||||||
if (lim->revert) ofs = -ofs; // finally do the reverse.
|
ofs = lim_n;
|
||||||
|
if (lim->revert)
|
||||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
ofs = -ofs; // finally do the reverse.
|
||||||
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) {
|
|
||||||
// safety channel available for channel check
|
|
||||||
ofs = calc100toRESX(safetyCh[channel]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ofs;
|
return ofs;
|
||||||
}
|
}
|
||||||
@@ -467,12 +473,12 @@ void evalInputs(uint8_t mode)
|
|||||||
v = 0;
|
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
|
// trainer mode
|
||||||
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
|
||||||
if (td->mode) {
|
if (td->mode) {
|
||||||
uint8_t chStud = td->srcChn;
|
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 *= td->studWeight;
|
||||||
vStud /= 50;
|
vStud /= 50;
|
||||||
switch (td->mode) {
|
switch (td->mode) {
|
||||||
|
|||||||
+3
-2
@@ -909,8 +909,9 @@ uint8_t lswFamily(uint8_t func);
|
|||||||
int16_t lswTimerValue(delayval_t val);
|
int16_t lswTimerValue(delayval_t val);
|
||||||
|
|
||||||
enum FunctionsActive {
|
enum FunctionsActive {
|
||||||
FUNCTION_TRAINER,
|
FUNCTION_TRAINER_STICK1,
|
||||||
FUNCTION_INSTANT_TRIM = FUNCTION_TRAINER+4,
|
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + NUM_STICKS,
|
||||||
|
FUNCTION_INSTANT_TRIM,
|
||||||
FUNCTION_VARIO,
|
FUNCTION_VARIO,
|
||||||
FUNCTION_BACKLIGHT,
|
FUNCTION_BACKLIGHT,
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
|
|||||||
Reference in New Issue
Block a user