Trainer function can now replace the channels values instead of to the sticks positions (#6561)

This commit is contained in:
Bertrand Songis
2019-10-24 12:03:19 +02:00
committed by GitHub
parent 9831a796b7
commit 1b35f2bd35
6 changed files with 47 additions and 26 deletions
+19 -13
View File
@@ -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) {