diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 1b117f56d..20173bfcd 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -971,12 +971,13 @@ class InputField: public TransformedField { { if (IS_TARANIS(board) && version >= 216) { internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0)); - internalField.Append(new UnsignedField<16>(expo.scale)); + internalField.Append(new UnsignedField<16>(expo.scale, "Scale")); internalField.Append(new UnsignedField<8>(expo.chn, "Channel")); internalField.Append(new SwitchField<8>(expo.swtch, board, version)); internalField.Append(new UnsignedField<16>(expo.phases)); internalField.Append(new SignedField<8>(_weight, "Weight")); - internalField.Append(new SignedField<8>(expo.carryTrim)); + internalField.Append(new SignedField<6>(expo.carryTrim, "CarryTrim")); + internalField.Append(new UnsignedField<2>(expo.mode, "Mode")); internalField.Append(new ZCharField<8>(expo.name)); internalField.Append(new SignedField<8>(expo.offset, "Offset")); internalField.Append(new CurveReferenceField(expo.curve, board, version)); @@ -1047,10 +1048,6 @@ class InputField: public TransformedField { expo.srcRaw = RawSource(SOURCE_TYPE_STICK, expo.chn); } } - else { - if (expo.srcRaw.type != SOURCE_TYPE_NONE) - expo.mode = 3; - } } expo.weight = smallGvarToC9x(_weight); diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 7b04620ff..6dff103c2 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -46,8 +46,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i } if (GetEepromInterface()->getCapability(VirtualInputs)) { - ui->sideLabel->hide(); - ui->sideCB->hide(); ui->inputName->setMaxLength(4); populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY); ui->sourceCB->removeItem(0); diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 6096c8cdf..e828c52cc 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -98,12 +98,11 @@ void InputsPanel::update() str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); } } - else { - switch (md->mode) { - case (1): str += " <-"; break; - case (2): str += " ->"; break; - default: str += " "; break; - }; + + switch (md->mode) { + case (1): str += " <-"; break; + case (2): str += " ->"; break; + default: str += " "; break; } str += " " + tr("Weight(%1)").arg(getGVarString(md->weight)); diff --git a/radio/src/Makefile b/radio/src/Makefile index b4c7f048f..b7ecaef64 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -994,8 +994,10 @@ ifeq ($(HELI), YES) endif ifeq ($(TEMPLATES), YES) - CPPDEFS += -DTEMPLATES - CPPSRC += templates.cpp + ifneq ($(PCB), TARANIS) + CPPDEFS += -DTEMPLATES + CPPSRC += templates.cpp + endif endif ifeq ($(PXX), YES) diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 49b17acd4..4059a8f25 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -501,6 +501,7 @@ void ConvertModel_215_to_216(ModelData &model) } g_model.expoData[i].srcRaw = MIXSRC_Rud+chn; g_model.expoData[i].chn = chn; + g_model.expoData[i].mode = oldModel.expoData[i].mode; g_model.expoData[i].swtch = ConvertSwitch_215_to_216(oldModel.expoData[i].swtch); g_model.expoData[i].phases = oldModel.expoData[i].phases; g_model.expoData[i].weight = oldModel.expoData[i].weight; @@ -536,6 +537,7 @@ void ConvertModel_215_to_216(ModelData &model) expo->chn = i; expo->weight = 100; expo->curve.type = CURVE_REF_EXPO; + expo->mode = 3; } for (int c=0; c<4; c++) { g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*(i+1)+c]); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 9f72b3232..cb9cf1a4a 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -2738,9 +2738,8 @@ void insertExpoMix(uint8_t expo, uint8_t idx) #if defined(PCBTARANIS) expo->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); expo->curve.type = CURVE_REF_EXPO; -#else - expo->mode = 3; // pos&neg #endif + expo->mode = 3; // pos&neg expo->chn = s_currCh - 1; expo->weight = 100; } @@ -2881,7 +2880,7 @@ enum ExposFields { IF_CURVES(EXPO_FIELD_CURVE) IF_FLIGHT_MODES(EXPO_FIELD_FLIGHT_PHASE) EXPO_FIELD_SWITCH, - CASE_9X(EXPO_FIELD_SIDE) + EXPO_FIELD_SIDE, CASE_PCBTARANIS(EXPO_FIELD_TRIM) EXPO_FIELD_MAX }; @@ -3015,11 +3014,9 @@ void menuModelExpoOne(uint8_t event) ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN-IF_9X(3*FW), y, ed->swtch, attr, event); break; -#if !defined(PCBTARANIS) case EXPO_FIELD_SIDE: - ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); + ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN-IF_9X(3*FW), y, STR_SIDE, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); break; -#endif #if defined(PCBTARANIS) case EXPO_FIELD_TRIM: @@ -3287,8 +3284,9 @@ static uint8_t s_copySrcCh; #define EXPO_LINE_SRC_POS 9*FW-2 #define EXPO_LINE_CURVE_POS 12*FW+4 #define EXPO_LINE_SWITCH_POS 17*FW-1 + #define EXPO_LINE_SIDE_POS 20*FW-2 #define EXPO_LINE_SELECT_POS 5*FW+2 - #define EXPO_LINE_FM_POS LCD_W-LEN_EXPOMIX_NAME*FW-MENUS_SCROLLBAR_WIDTH-FW-1 + #define EXPO_LINE_FM_POS LCD_W-LEN_EXPOMIX_NAME*FW-MENUS_SCROLLBAR_WIDTH-FW #define EXPO_LINE_NAME_POS LCD_W-LEN_EXPOMIX_NAME*FW-MENUS_SCROLLBAR_WIDTH #define MIX_LINE_WEIGHT_POS 11*FW+5 #define MIX_LINE_CURVE_POS 12*FW+4 @@ -3579,9 +3577,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch, 0); -#if !defined(PCBTARANIS) if (ed->mode!=3) lcd_putc(EXPO_LINE_SIDE_POS, y, ed->mode == 2 ? 126 : 127); -#endif #if defined(CPUARM) && LCD_W >= 212 displayFlightModes(EXPO_LINE_FM_POS, y, ed->phases); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 7908e0d6b..698783f13 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -446,15 +446,16 @@ PACK(typedef struct t_ExpoData { int8_t swtch; uint16_t phases; int8_t weight; - int8_t carryTrim; + int8_t carryTrim:6; + uint8_t mode:2; char name[LEN_EXPOMIX_NAME]; int8_t offset; CurveRef curve; uint8_t spare; }) ExpoData; #define MIN_EXPO_WEIGHT -100 -#define EXPO_VALID(ed) ((ed)->srcRaw) -#define EXPO_MODE_ENABLE(ed, v) (true) +#define EXPO_VALID(ed) ((ed)->mode) +#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2))) #elif defined(CPUARM) PACK(typedef struct t_ExpoData { uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both @@ -468,7 +469,7 @@ PACK(typedef struct t_ExpoData { }) ExpoData; #define MIN_EXPO_WEIGHT 0 #define EXPO_VALID(ed) ((ed)->mode) -#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2))) +#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2))) #elif defined(CPUM2560) || defined(CPUM2561) PACK(typedef struct t_ExpoData { uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both @@ -482,7 +483,7 @@ PACK(typedef struct t_ExpoData { }) ExpoData; #define MIN_EXPO_WEIGHT 0 #define EXPO_VALID(ed) ((ed)->mode) -#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2))) +#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2))) #else PACK(typedef struct t_ExpoData { uint8_t mode:2; // 0=end, 1=pos, 2=neg, 3=both @@ -495,7 +496,7 @@ PACK(typedef struct t_ExpoData { }) ExpoData; #define MIN_EXPO_WEIGHT 0 #define EXPO_VALID(ed) ((ed)->mode) -#define EXPO_MODE_ENABLE(ed, v) ((v<0 && (ed->mode&1)) || (v>=0 && (ed->mode&2))) +#define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2))) #endif #if defined(CPUARM) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index a0130770c..3c55f7724 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -540,6 +540,7 @@ void applyDefaultTemplate() expo->curve.type = CURVE_REF_EXPO; expo->chn = i; expo->weight = 100; + expo->mode = 3; // TODO constant for (int c=0; c<4; c++) { g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*stick_index+c]); } diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp index 1b2e59a10..07e2c9670 100644 --- a/radio/src/templates.cpp +++ b/radio/src/templates.cpp @@ -56,6 +56,10 @@ #include "opentx.h" +#if defined(PCBTARANIS) + #pragma message("Templates with virtual inputs (FrSky Taranis) are not implemented!") +#endif + MixData* setDest(uint8_t dch, uint8_t src, bool clear=false) { uint8_t i = 0; @@ -113,6 +117,7 @@ void defaultInputs() expo->curve.type = CURVE_REF_EXPO; expo->chn = i; expo->weight = 100; + expo->mode = 3; // TODO constant for (int c=0; c<4; c++) { g_model.inputNames[i][c] = char2idx(STR_VSRCRAW[1+STR_VSRCRAW[0]*stick_index+c]); } @@ -183,13 +188,10 @@ void applyTemplate(uint8_t idx) // Simple 4-Ch case TMPL_SIMPLE_4CH: defaultInputs(); -#if defined(PCBTARANIS) - #pragma message("Templates with virtual inputs (FrSky Taranis) are not implemented!") -#endif - setDest(ICC(STK_RUD), MIXSRC_Rud); - setDest(ICC(STK_ELE), MIXSRC_Ele); - setDest(ICC(STK_THR), MIXSRC_Thr); - setDest(ICC(STK_AIL), MIXSRC_Ail); + setDest(ICC(STK_RUD), TMPL_INPUT(STK_RUD)); + setDest(ICC(STK_ELE), TMPL_INPUT(STK_ELE)); + setDest(ICC(STK_THR), TMPL_INPUT(STK_THR)); + setDest(ICC(STK_AIL), TMPL_INPUT(STK_AIL)); break; // Sticky-T-Cut