diff --git a/companion/src/constants.h b/companion/src/constants.h index fdabacbc4..d2d32a745 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -38,7 +38,7 @@ #define CPN_MAX_MODULES 2 #define CPN_MAX_STICKS Board::STICK_AXIS_COUNT #define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT -#define CPN_MAX_KNOBS 4 +#define CPN_MAX_KNOBS 8 #define CPN_MAX_SLIDERS 4 #define CPN_MAX_POTS (CPN_MAX_KNOBS + CPN_MAX_SLIDERS) #define CPN_MAX_CYC 3 diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index 2187a98fb..f753b354e 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -270,9 +270,19 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability) return 2; else if (IS_TARANIS_X9E(board)) return 4; + else if (IS_HORUS_X10(board)) + return 5; + else if (IS_HORUS_X12S(board)) + return 3; else return 3; + case PotsStorage: + if (IS_HORUS(board)) + return 5; + else + return getCapability(board, Pots); + case FactoryInstalledPots: if (IS_TARANIS_X9(board)) return 2; @@ -287,8 +297,14 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability) else return 0; + case SlidersStorage: + if (IS_HORUS_X10(board)) + return 4; + else + return getCapability(board, Sliders); + case MouseAnalogs: - if (IS_HORUS_X12S(board)) + if (IS_HORUS(board)) return 2; else return 0; @@ -321,10 +337,12 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability) return 6; else if (IS_TARANIS_XLITE(board)) return 6; + else if (IS_TARANIS(board)) + return 8; else if (board == Board::BOARD_TARANIS_X9DP_2019) return 9; - else if (IS_HORUS_OR_TARANIS(board)) - return 8; + else if (IS_HORUS(board)) + return 10; else return 7; @@ -450,6 +468,8 @@ const QString Boards::getAnalogInputName(Board::Type board, int index) "S1", "6P", "S2", + "EX1", + "EX2", "LS", "RS" }; diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index efb1b2be1..1533107c3 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -114,8 +114,10 @@ namespace Board { enum Capability { Sticks, Pots, + PotsStorage, FactoryInstalledPots, Sliders, + SlidersStorage, MouseAnalogs, GyroAnalogs, MaxAnalogs, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b4ec24d5b..72e1b8d9d 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -29,25 +29,42 @@ using namespace Board; #define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256) -#define MAX_SLIDERS(board) (IS_HORUS_X10(board) ? 4 : (Boards::getCapability(board, Board::Sliders))) //TODO need to be remove when x10 eeprom gets fixed -#define MAX_MOUSE_ANALOGS(board) (IS_HORUS_X10(board) ? 2 : (Boards::getCapability(board, Board::MouseAnalogs))) //TODO need to be remove when x10 eeprom gets fixed #define MAX_GYRO_ANALOGS(board, version) (version >= 219 ? Boards::getCapability(board, Board::GyroAnalogs) : 0) inline int MAX_SWITCHES(Board::Type board, int version) { if (version <= 218 && IS_TARANIS_X7(board)) return 6; - if (version <= 218 && IS_TARANIS_X9D(board)) + if (version <= 218 && (IS_TARANIS_X9D(board) || IS_HORUS(board))) return 8; return Boards::getCapability(board, Board::Switches); } +#define MAX_KNOBS(board, version) (IS_HORUS(board) ? 8 : 4) + +inline int MAX_POTS(Board::Type board, int version) +{ + if (version <= 218 && IS_HORUS(board)) + return 3; + return Boards::getCapability(board, Board::Pots); +} + +inline int MAX_POTS_STORAGE(Board::Type board, int version) +{ + if (version <= 218 && IS_HORUS(board)) + return 3; + return Boards::getCapability(board, Board::PotsStorage); +} + // bitsize of swconfig_t / 2 (see radio/src/datastructs.h) inline int MAX_SWITCH_SLOTS(Board::Type board, int version) { if (IS_TARANIS_X9E(board)) return 32; + if (IS_HORUS(board)) + return 16; + if (version >= 219 && IS_TARANIS_X9D(board)) return 16; @@ -105,7 +122,7 @@ class SwitchesConversionTable: public ConversionTable { } if (IS_HORUS_OR_TARANIS(board)) { - for (int i=1; i<=Boards::getCapability(board, Board::Pots)*6; i++) { + for (int i=1; i<=MAX_POTS(board, version)*6; i++) { addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i), -val+offset); addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i), val++); } @@ -227,7 +244,7 @@ class SourcesConversionTable: public ConversionTable { } } - for (int i=0; i(this, modelData.moduleData[1].modelId)); if (HAS_LARGE_LCD(board)) { - internalField.Append(new CharField<10>(this, modelData.bitmap, true, "Model bitmap")); + if (version >= 219 && IS_HORUS(board)) + internalField.Append(new CharField<14>(this, modelData.bitmap, true, "Model bitmap")); + else + internalField.Append(new CharField<10>(this, modelData.bitmap, true, "Model bitmap")); } for (int i=0; i(this, modelData.potsWarningEnabled[i])); else internalField.Append(new SpareBitsField<1>(this)); } - for (int i=0; i < Boards::getCapability(board, Board::Pots) + MAX_SLIDERS(board); i++) { + for (int i=0; i < Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders); i++) { internalField.Append(new SignedField<8>(this, modelData.potPosition[i])); } @@ -2300,7 +2320,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type generalData(generalData), board(board), version(version), - inputsCount(CPN_MAX_STICKS + Boards::getCapability(board, Board::Pots) + MAX_SLIDERS(board) + MAX_MOUSE_ANALOGS(board)) + inputsCount(CPN_MAX_STICKS + Boards::getCapability(board, Board::PotsStorage) + Boards::getCapability(board, Board::SlidersStorage) + Boards::getCapability(board, Board::MouseAnalogs)) { qCDebug(eepromImport) << QString("OpenTxGeneralData::OpenTxGeneralData(board: %1, version:%2, variant:%3)").arg(board).arg(version).arg(variant); @@ -2311,6 +2331,10 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type internalField.Append(new UnsignedField<16>(this, generalData.variant)); for (int i=0; i(this, generalData.calibMid[i])); internalField.Append(new SignedField<16>(this, generalData.calibSpanNeg[i])); internalField.Append(new SignedField<16>(this, generalData.calibSpanPos[i])); @@ -2453,6 +2477,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type if (IS_STM32(board)) { if (version >= 218) { internalField.Append(new UnsignedField<4>(this, generalData.hw_uartMode)); + // not on Horus... for (uint8_t i=0; i<4; i++) { internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i])); } @@ -2469,19 +2494,32 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type } if (IS_HORUS(board)) { - for (int i=0; i<16; i++) { + for (int i=0; i(this, generalData.switchConfig[i])); else internalField.Append(new SpareBitsField<2>(this)); } } - for (int i=0; i<4; i++) { - if (i < Boards::getCapability(board, Board::Pots)) + for (int i=0; i(this, generalData.potConfig[i])); else internalField.Append(new SpareBitsField<2>(this)); } + if (IS_HORUS(board)) { + for (int i=0; i<8; i++) { + if (i < Boards::getCapability(board, Board::SlidersStorage)) + internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i])); + else + internalField.Append(new SpareBitsField<1>(this)); + } + } if (!IS_HORUS(board)) { internalField.Append(new UnsignedField<8>(this, generalData.backlightColor)); } @@ -2515,10 +2553,14 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type for (int i=0; i(this, generalData.stickName[i], "Stick name")); } - for (int i=0; i(this, generalData.potName[i], "Pot name")); } - for (int i=0; i(this, generalData.sliderName[i], "Slider name")); } internalField.Append(new CharField<17>(this, generalData.currModelFilename, true, "Current model filename")); @@ -2539,7 +2581,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type for (int i=0; i(this, generalData.potName[i], "Pot name")); } - for (int i=0; i(this, generalData.sliderName[i], "Slider name")); } } diff --git a/companion/src/generaledit/hardware.cpp b/companion/src/generaledit/hardware.cpp index bb482598e..f33800635 100644 --- a/companion/src/generaledit/hardware.cpp +++ b/companion/src/generaledit/hardware.cpp @@ -126,6 +126,7 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings setupPotType(1, ui->pot2Label, ui->pot2Name, ui->pot2Type); setupPotType(2, ui->pot3Label, ui->pot3Name, ui->pot3Type); setupPotType(3, ui->pot4Label, ui->pot4Name, ui->pot4Type); + setupPotType(4, ui->pot5Label, ui->pot5Name, ui->pot5Type); setupSliderType(0, ui->lsLabel, ui->lsName, ui->lsType); setupSliderType(1, ui->rsLabel, ui->rsName, ui->rsType); diff --git a/companion/src/generaledit/hardware.ui b/companion/src/generaledit/hardware.ui index 3a54521ba..c28c4584c 100644 --- a/companion/src/generaledit/hardware.ui +++ b/companion/src/generaledit/hardware.ui @@ -23,10 +23,27 @@ 6 - - + + + + + + + + + + + + - SQ + S3 + + + + + + + Rud @@ -37,36 +54,15 @@ - - - - SR - - - - - + + 3 - - - - 3 - - - - - - - LS2 - - - - - + + @@ -78,24 +74,67 @@ - - + + + + + + + + + + + + 3 - - - - SP + + + + + + + + + + - - - - SO + + + + + 0 + 10 + + + + Qt::Horizontal + + + + + + + 3 + + + + + + + 3 + + + + + + + 3 @@ -106,31 +145,122 @@ - - + + + + + + + + + + + + + + Serial Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Bluetooth + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + 3 - - - - RS + + + + + + + + + + - + + + + PPM Multiplier + + + + SB - - + + + + 3 + + + + + + + 3 + + + + + + + 3 + + + + + - PPM 2 + SM + + + + + + + 3 + + + + + + + + + + + + + + RS2 @@ -141,8 +271,41 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SQ + + + + + @@ -151,17 +314,20 @@ - - + + + + + - + @@ -190,95 +356,8 @@ - - - - 3 - - - - - - - 3 - - - - - - - 3 - - - - - - - Rud - - - - - - - -49 - - - 49 - - - - - - - PPM 3 - - - - - - - 3 - - - - - - - S1 - - - - - - - 3 - - - - - - - S2 - - - - - - - S3 - - - - - - - PPM 1 - - - - - + + @@ -296,17 +375,94 @@ - - - - Serial Port - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + 3 - + + + + PPM 1 + + + + + + + SD + + + + + + + S1 + + + + + + + SC + + + + + + + SJ + + + + + + + 3 + + + + + + + SL + + + + + + + + + + + + + + + + + Ail + + + + + + + PPM 2 + + + + + + + 3 + + + + @@ -328,217 +484,21 @@ - - + + + + 3 + + + + + - PPM Multiplier + S2 - - - - - - - - - - - - -9999 - - - 9999 - - - - - - - - - - - - - - - - - - - - Current Offset - - - - - - - PPM 4 - - - - - - - 3 - - - - - - - SA - - - - - - - Ele - - - - - - - 3 - - - - - - - 3 - - - - - - - Ail - - - - - - - 3 - - - - - - - Thr - - - - - - - 3 - - - - - - - SC - - - - - - - 3 - - - - - - - LS - - - - - - - 3 - - - - - - - - - - - - - - - - - - - - 3 - - - - - - - SD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -9999 - - - 9999 - - - - - - - Battery Offset - - - - @@ -557,310 +517,7 @@ - - - - 3 - - - - - - - SE - - - - - - - - - - - - - - - - - - - - 3 - - - - - - - SF - - - - - - - - - - - - - - - - - - - - 3 - - - - - - - SG - - - - - - - - - - - - - - - - - - - - 3 - - - - - - - SH - - - - - - - 3 - - - - - - - SI - - - - - - - 3 - - - - - - - SJ - - - - - - - 3 - - - - - - - SK - - - - - - - 3 - - - - - - - SL - - - - - - - SM - - - - - - - 3 - - - - - - - SN - - - - - - - 1 - - - 5.000000000000000 - - - 1.000000000000000 - - - - - - - 3 - - - - - - - RS2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -873,56 +530,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -933,64 +540,159 @@ - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - + + - Bluetooth - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + SA - - + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 10 + + + + Qt::Horizontal + + + + + + + 3 + + + + + + + SH + + + + + + + SP + + + + + + + 1 + + + 5.000000000000000 + + + 1.000000000000000 + + + + + + + 3 + + + + + + + 3 + + + + + + + 3 + + + + + + + 3 + + + + + + + -49 + + + 49 + + + + + + + + + + + + + + + + + + + + PPM 4 + + + + + 3 - - - - - - - - - - ADC Filter - - - - @@ -1048,7 +750,7 @@ - + @@ -1061,32 +763,343 @@ - - - - - 0 - 10 - - - - Qt::Horizontal + + + + ADC Filter - - - - - 0 - 10 - - - - Qt::Horizontal + + + + SF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + SR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SG + + + + + + + PPM 3 + + + + + + + 3 + + + + + + + SK + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + RS + + + + + + + LS + + + + + + + Battery Offset + + + + + + + SI + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -9999 + + + 9999 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -9999 + + + 9999 + + + + + + + + + + + + + + + + + + + + LS2 + + + + + + + Ele + + + + + + + 3 + + + + + + + SE + + + + + + + 3 + + + + + + + SN + + + + + + + 3 + + + + + + + 3 + + + + + + + Thr + + + + + + + Current Offset + + + + + + + SO + + + + + + + S5 + + + + + + + + + diff --git a/radio/src/storage/conversions/conversions_218_219.cpp b/radio/src/storage/conversions/conversions_218_219.cpp index 985d434aa..618d52887 100644 --- a/radio/src/storage/conversions/conversions_218_219.cpp +++ b/radio/src/storage/conversions/conversions_218_219.cpp @@ -342,22 +342,30 @@ void convertRadioData_218_to_219(RadioData & settings) #endif #if defined(PCBHORUS) + // 2 new pots from X10: + // - copy btw. 'chkSum' and 'auxSerialMode' (excl.) memcpy(&settings.chkSum, &oldSettings.chkSum, offsetof(RadioData, auxSerialMode) - offsetof(RadioData, chkSum)); + // - move calibration data memcpy(&settings.calib[NUM_STICKS + 5], &oldSettings.calib[NUM_STICKS + 3], sizeof(CalibData) * (STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS)); memclear(&settings.calib[NUM_STICKS + 3], sizeof(CalibData) * 2); + // move fields after custom functions settings.auxSerialMode = oldSettings.auxSerialMode; settings.switchConfig = oldSettings.switchConfig; settings.potsConfig = oldSettings.potsConfig; settings.slidersConfig = oldSettings.slidersConfig; + // 2 new switches memcpy(&settings.switchNames[0], &oldSettings.switchNames[0], 8 * LEN_SWITCH_NAME); memclear(&settings.switchNames[8], 2 * LEN_SWITCH_NAME); + // 2 new pots for X10 + // - split 'anaNames' (sticks + 3 old pots, 2 new pots, other old analogs) memcpy(&settings.anaNames[0], &oldSettings.anaNames[0], (NUM_STICKS + 3) * LEN_ANA_NAME); memclear(&settings.anaNames[NUM_STICKS + 3], 2 * LEN_SWITCH_NAME); memcpy(&settings.anaNames[NUM_STICKS + 5], &oldSettings.anaNames[NUM_STICKS + 3], STORAGE_NUM_SLIDERS * LEN_ANA_NAME); + // - copy rest of RadioData struct memcpy(&settings.currModelFilename[0], &oldSettings.currModelFilename[0], sizeof(RadioData_v218) - offsetof(RadioData_v218, currModelFilename[0])); #endif