1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-18 22:05:10 +03:00

Issue #869 - Trim ON/OFF is back in mixer. I wonder now if we couldn't

add the possibility to hide the Virtual Inputs menu as many people won't
use it (It's now possible to select a stick in the mixer, and as soon as
the trim checkbox is ON, it will work perfectly!)
This commit is contained in:
bsongis 2014-03-27 09:46:17 +01:00
parent b3864e590b
commit 719b519650
4 changed files with 40 additions and 24 deletions

View file

@ -450,6 +450,7 @@ void ConvertModel_215_to_216(ModelData &model)
mix.destCh = oldModel.mixData[i].destCh;
mix.phases = oldModel.mixData[i].phases;
mix.mltpx = oldModel.mixData[i].mltpx;
if (oldModel.mixData[i].carryTrim == TRIM_OFF) mix.carryTrim = TRIM_OFF;
mix.weight = ConvertGVAR_215_to_216(oldModel.mixData[i].weight);
mix.swtch = ConvertSwitch_215_to_216(oldModel.mixData[i].swtch);
if (oldModel.mixData[i].curveMode==0/*differential*/) {

View file

@ -3069,7 +3069,7 @@ enum MixFields {
MIX_FIELD_SOURCE,
MIX_FIELD_WEIGHT,
MIX_FIELD_OFFSET,
CASE_9X(MIX_FIELD_TRIM)
MIX_FIELD_TRIM,
IF_CURVES(MIX_FIELD_CURVE)
IF_FLIGHT_MODES(MIX_FIELD_FLIGHT_PHASE)
MIX_FIELD_SWITCH,
@ -3114,7 +3114,7 @@ void menuModelMixOne(uint8_t event)
else
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
#else
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(0) 0, 0, 0, CASE_9X(1) CASE_PCBTARANIS(0) IF_CURVES(1) IF_FLIGHT_MODES((MAX_PHASES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/});
#endif
#if MENU_COLUMNS > 1
@ -3169,17 +3169,19 @@ void menuModelMixOne(uint8_t event)
break;
}
#if !defined(PCBTARANIS)
#if defined(PCBTARANIS)
case MIX_FIELD_TRIM:
lcd_putsColumnLeft(COLUMN_X, y, STR_TRIM);
menu_lcd_onoff(COLUMN_X+MIXES_2ND_COLUMN, y, !md2->carryTrim, attr);
if (attr) md2->carryTrim = !checkIncDecModel(event, !md2->carryTrim, 0, 1);
break;
#else
case MIX_FIELD_TRIM:
{
uint8_t not_stick = (md2->srcRaw > NUM_STICKS);
int8_t carryTrim = -md2->carryTrim;
lcd_putsColumnLeft(COLUMN_X, y, STR_TRIM);
#if LCD_W >= 212 && defined(TRANSLATIONS_FR)
lcd_putsiAtt((not_stick ? COLUMN_X+MIXES_2ND_COLUMN : COLUMN_X+11*FW-3), y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0);
#else
lcd_putsiAtt((not_stick ? COLUMN_X+MIXES_2ND_COLUMN : COLUMN_X+6*FW-3), y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0);
#endif
if (attr && m_posHorz==0 && (not_stick || editMode>0)) md2->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL);
if (!not_stick) {
lcd_puts(COLUMN_X+MIXES_2ND_COLUMN, y, STR_DREX);

View file

@ -553,7 +553,9 @@ PACK(typedef struct t_LimitData {
PACK(typedef struct t_MixData {
uint8_t destCh;
uint16_t phases;
uint8_t mltpx; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
uint8_t carryTrim:1;
uint8_t spare1:5;
int16_t weight;
int8_t swtch;
CurveRef curve;
@ -566,7 +568,7 @@ PACK(typedef struct t_MixData {
uint8_t srcRaw;
int16_t offset;
char name[LEN_EXPOMIX_NAME];
uint8_t spare;
uint8_t spare2;
}) MixData;
#else
PACK(typedef struct t_MixData {

View file

@ -38,7 +38,9 @@
// static variables used in perOut - moved here so they don't interfere with the stack
// It's also easier to initialize them here.
#if !defined(PCBTARANIS)
#if defined(PCBTARANIS)
int8_t virtualInputsTrims[NUM_INPUTS];
#else
int16_t rawAnas[NUM_INPUTS] = {0};
#endif
int16_t anas [NUM_INPUTS] = {0};
@ -1004,16 +1006,12 @@ void applyExpos(int16_t *anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS)
if (offset) v += calc100toRESX(offset);
//========== TRIMS ================
if (!(mode & e_perout_mode_notrims)) {
int8_t input_trim = ed->carryTrim;
if (input_trim < TRIM_ON)
input_trim = -input_trim - 1;
else if (input_trim == TRIM_ON && ed->srcRaw >= MIXSRC_Rud && ed->srcRaw <= MIXSRC_Ail)
input_trim = ed->srcRaw - MIXSRC_Rud;
if (ed->carryTrim < TRIM_ON)
virtualInputsTrims[cur_chn] = -ed->carryTrim - 1;
else if (ed->carryTrim == TRIM_ON && ed->srcRaw >= MIXSRC_Rud && ed->srcRaw <= MIXSRC_Ail)
virtualInputsTrims[cur_chn] = ed->srcRaw - MIXSRC_Rud;
else
input_trim = -1;
if (input_trim >= 0) v += trims[input_trim];
}
virtualInputsTrims[cur_chn] = -1;
#endif
anas[cur_chn] = v;
@ -3840,14 +3838,27 @@ void perOut(uint8_t mode, uint8_t tick10ms)
#endif
}
#if !defined(PCBTARANIS) // (because trims are taken into account by INPUTS on Taranis)
if (apply_offset_and_curve) {
#if !defined(PCBTARANIS) // OFFSET is now applied AFTER weight on Taranis
//========== OFFSET / SOURCE ===============
int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
if (offset) v += calc100toRESX_16Bits(offset);
#endif
//========== TRIMS ================
if (!(mode & e_perout_mode_notrims)) {
#if defined(PCBTARANIS)
if (!md->carryTrim) {
int8_t mix_trim;
if (stickIndex < NUM_STICKS)
mix_trim = stickIndex;
else if (md->srcRaw <= MIXSRC_LAST_INPUT)
mix_trim = virtualInputsTrims[md->srcRaw-1];
else
mix_trim = -1;
if (mix_trim >= 0) v += trims[mix_trim];
}
#else
int8_t mix_trim = md->carryTrim;
if (mix_trim < TRIM_ON)
mix_trim = -mix_trim - 1;
@ -3856,9 +3867,9 @@ void perOut(uint8_t mode, uint8_t tick10ms)
else
mix_trim = -1;
if (mix_trim >= 0) v += trims[mix_trim];
}
}
#endif
}
}
// saves 12 bytes code if done here and not together with weight; unknown reason
int16_t weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);