1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

CopyTrimsToOffset function added - #1323

This commit is contained in:
bsongis 2014-06-19 23:52:50 +02:00
parent b1f44d7101
commit 6908509d79
15 changed files with 43 additions and 3 deletions

View file

@ -3054,13 +3054,11 @@ void copySticksToOffset(uint8_t ch)
{
pauseMixerCalculations();
int32_t zero = (int32_t)channelOutputs[ch];
int32_t old = chans[ch];
evalFlightModeMixes(e_perout_mode_nosticks+e_perout_mode_notrainer, 0);
int32_t val = chans[ch];
LimitData *ld = limitAddress(ch);
limit_min_max_t lim = LIMIT_MIN(ld);
TRACE("%d vs %d chan=%d vs %d - lim=%d", zero, channelOutputs[ch], val, old, lim);
if (val < 0) {
val = -val;
lim = LIMIT_MIN(ld);
@ -3075,6 +3073,31 @@ void copySticksToOffset(uint8_t ch)
eeDirty(EE_MODEL);
}
void copyTrimsToOffset(uint8_t ch)
{
int16_t zero;
pauseMixerCalculations();
evalFlightModeMixes(e_perout_mode_noinput, 0); // do output loop - zero input sticks and trims
zero = applyLimits(ch, chans[ch]);
evalFlightModeMixes(e_perout_mode_noinput-e_perout_mode_notrims, 0); // do output loop - only trims
int16_t output = applyLimits(ch, chans[ch]) - zero;
int16_t v = g_model.limitData[ch].offset;
if (g_model.limitData[ch].revert) output = -output;
#if defined(CPUARM)
v += (output * 125) / 128;
#else
v += output;
#endif
g_model.limitData[ch].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire
resumeMixerCalculations();
eeDirty(EE_MODEL);
}
void moveTrimsToOffsets() // copy state of 3 primary to subtrim
{
int16_t zeros[NUM_CHNOUT];