Companion support for EXT3 EXT4 and FlySky gimbals

This commit is contained in:
elecpower
2021-12-31 10:53:10 +01:00
committed by Raphael Coeffic
parent f6329895a8
commit 23c84633da
13 changed files with 51 additions and 22 deletions
+2 -3
View File
@@ -38,15 +38,14 @@
#define CPN_MAX_MODULES 2 #define CPN_MAX_MODULES 2
#define CPN_MAX_STICKS Board::STICK_AXIS_COUNT #define CPN_MAX_STICKS Board::STICK_AXIS_COUNT
#define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT #define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT
#define CPN_MAX_KNOBS 8 #define CPN_MAX_POTS 8
#define CPN_MAX_SLIDERS 4 #define CPN_MAX_SLIDERS 4
#define CPN_MAX_POTS (CPN_MAX_KNOBS + CPN_MAX_SLIDERS)
#define CPN_MAX_CYC 3 #define CPN_MAX_CYC 3
#define CPN_MAX_SWITCHES 32 #define CPN_MAX_SWITCHES 32
#define CPN_MAX_FUNCTION_SWITCHES 6 #define CPN_MAX_FUNCTION_SWITCHES 6
#define CPN_MAX_MOUSE_ANALOGS 2 #define CPN_MAX_MOUSE_ANALOGS 2
#define CPN_MAX_GYRO_ANALOGS 2 #define CPN_MAX_GYRO_ANALOGS 2
#define CPN_MAX_ANALOGS (CPN_MAX_STICKS + CPN_MAX_POTS + CPN_MAX_MOUSE_ANALOGS + CPN_MAX_GYRO_ANALOGS) #define CPN_MAX_ANALOGS (CPN_MAX_STICKS + CPN_MAX_POTS + CPN_MAX_SLIDERS + CPN_MAX_MOUSE_ANALOGS + CPN_MAX_GYRO_ANALOGS)
#define CPN_STR_APP_NAME QCoreApplication::translate("Companion", "EdgeTX Companion") #define CPN_STR_APP_NAME QCoreApplication::translate("Companion", "EdgeTX Companion")
#define CPN_STR_TTL_INFO QCoreApplication::translate("Companion", "Information") // shared Title Case words, eg. for a window title or section heading #define CPN_STR_TTL_INFO QCoreApplication::translate("Companion", "Information") // shared Title Case words, eg. for a window title or section heading
+3 -3
View File
@@ -374,7 +374,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
else if (IS_TARANIS_X9E(board)) else if (IS_TARANIS_X9E(board))
return 4; return 4;
else if (IS_HORUS_X10(board) || IS_FAMILY_T16(board)) else if (IS_HORUS_X10(board) || IS_FAMILY_T16(board))
return 5; return 7;
else if (IS_HORUS_X12S(board)) else if (IS_HORUS_X12S(board))
return 3; return 3;
else if (IS_FLYSKY_NV14(board)) else if (IS_FLYSKY_NV14(board))
@@ -570,8 +570,8 @@ StringTagMappingTable Boards::getAnalogNamesLookupTable(Board::Type board)
{"S2", "S2"}, {"S2", "S2"},
{"EX1", "EXT1"}, {"EX1", "EXT1"},
{"EX2", "EXT2"}, {"EX2", "EXT2"},
// {"EX3", "EXT3"}, {"EX3", "EXT3"},
// {"EX4", "EXT4"}, {"EX4", "EXT4"},
{"LS", "LS"}, {"LS", "LS"},
{"RS", "RS"}, {"RS", "RS"},
}); });
@@ -41,9 +41,8 @@ const YamlLookupTable switchConfigLut = {
}; };
const YamlLookupTable potsLut = { const YamlLookupTable potsLut = {
{0, "S1"}, {1, "6POS"}, {2, "S2"}, {3, "EXT1"}, {4, "EXT2"}, {0, "S1"}, {1, "6POS"}, {2, "S2"},
// { 5, "EXT3" }, {3, "EXT1"}, {4, "EXT2"}, {5, "EXT3"}, {6, "EXT4"},
// { 6, "EXT4" },
}; };
const YamlLookupTable potConfigLut = { const YamlLookupTable potConfigLut = {
@@ -79,7 +79,7 @@ typedef YamlKnobConfig<CPN_MAX_SWITCHES, switchesLut, switchConfigLut>
// name: // name:
extern const YamlLookupTable potsLut; extern const YamlLookupTable potsLut;
extern const YamlLookupTable potConfigLut; extern const YamlLookupTable potConfigLut;
typedef YamlKnobConfig<CPN_MAX_KNOBS, potsLut, potConfigLut> YamlPotConfig; typedef YamlKnobConfig<CPN_MAX_POTS, potsLut, potConfigLut> YamlPotConfig;
// S1: // S1:
// type: with_detent // type: with_detent
+2 -1
View File
@@ -167,7 +167,8 @@ enum Capability {
TopBarZones, TopBarZones,
FunctionSwitches, FunctionSwitches,
Has, Has,
HasModelsList HasModelsList,
HasFlySkyGimbals
}; };
class EEPROMInterface class EEPROMInterface
+6 -2
View File
@@ -54,14 +54,18 @@ bool GeneralSettings::switchSourceAllowedTaranis(int index) const
bool GeneralSettings::isPotAvailable(int index) const bool GeneralSettings::isPotAvailable(int index) const
{ {
if (index < 0 || index > Boards::getCapability(getCurrentBoard(), Board::Pots)) int numPots = Boards::getCapability(getCurrentBoard(), Board::Pots);
if (getCurrentFirmware()->getCapability(HasFlySkyGimbals))
numPots -= 2;
if (index < 0 || index >= numPots)
return false; return false;
return potConfig[index] != Board::POT_NONE; return potConfig[index] != Board::POT_NONE;
} }
bool GeneralSettings::isSliderAvailable(int index) const bool GeneralSettings::isSliderAvailable(int index) const
{ {
if (index < 0 || index > Boards::getCapability(getCurrentBoard(), Board::Sliders)) if (index < 0 || index >= Boards::getCapability(getCurrentBoard(), Board::Sliders))
return false; return false;
return sliderConfig[index] != Board::SLIDER_NONE; return sliderConfig[index] != Board::SLIDER_NONE;
} }
+2 -2
View File
@@ -231,8 +231,8 @@ class GeneralSettings {
char switchName[CPN_MAX_SWITCHES][HARDWARE_NAME_LEN + 1]; char switchName[CPN_MAX_SWITCHES][HARDWARE_NAME_LEN + 1];
unsigned int switchConfig[CPN_MAX_SWITCHES]; unsigned int switchConfig[CPN_MAX_SWITCHES];
char stickName[CPN_MAX_STICKS][HARDWARE_NAME_LEN + 1]; char stickName[CPN_MAX_STICKS][HARDWARE_NAME_LEN + 1];
char potName[CPN_MAX_KNOBS][HARDWARE_NAME_LEN + 1]; char potName[CPN_MAX_POTS][HARDWARE_NAME_LEN + 1];
unsigned int potConfig[CPN_MAX_KNOBS]; unsigned int potConfig[CPN_MAX_POTS];
char sliderName[CPN_MAX_SLIDERS][HARDWARE_NAME_LEN + 1]; char sliderName[CPN_MAX_SLIDERS][HARDWARE_NAME_LEN + 1];
unsigned int sliderConfig[CPN_MAX_SLIDERS]; unsigned int sliderConfig[CPN_MAX_SLIDERS];
+2 -2
View File
@@ -145,8 +145,8 @@ class ModelData {
unsigned int switchWarningEnable; unsigned int switchWarningEnable;
unsigned int thrTrimSwitch; unsigned int thrTrimSwitch;
unsigned int potsWarningMode; unsigned int potsWarningMode;
bool potsWarnEnabled[CPN_MAX_POTS]; bool potsWarnEnabled[CPN_MAX_POTS + CPN_MAX_SLIDERS];
int potsWarnPosition[CPN_MAX_POTS]; int potsWarnPosition[CPN_MAX_POTS + CPN_MAX_SLIDERS];
bool displayChecklist; bool displayChecklist;
GVarData gvarData[CPN_MAX_GVARS]; GVarData gvarData[CPN_MAX_GVARS];
@@ -79,6 +79,8 @@ inline int MAX_POTS(Board::Type board, int version)
{ {
if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board)) if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board))
return 3; return 3;
if (version <= 220 && (IS_HORUS_X10(board) || IS_FAMILY_T16(board)))
return 5;
if (IS_FAMILY_T12(board)) if (IS_FAMILY_T12(board))
return 2; return 2;
return Boards::getCapability(board, Board::Pots); return Boards::getCapability(board, Board::Pots);
@@ -95,7 +97,7 @@ inline int MAX_POTS_STORAGE(Board::Type board, int version)
{ {
if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board)) if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board))
return 3; return 3;
if (version >= 219 && IS_FAMILY_HORUS_OR_T16(board)) if (version <= 220 && IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board))
return 5; return 5;
if (IS_FAMILY_T12(board)) if (IS_FAMILY_T12(board))
return 2; return 2;
@@ -105,6 +107,8 @@ inline int MAX_POTS_STORAGE(Board::Type board, int version)
inline int MAX_POTS_SOURCES(Board::Type board, int version) inline int MAX_POTS_SOURCES(Board::Type board, int version)
{ {
if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board)) if (version <= 218 && IS_FAMILY_HORUS_OR_T16(board))
return 3;
if (version <= 220 && (IS_HORUS_X10(board) || IS_FAMILY_T16(board)))
return 5; return 5;
if (IS_FAMILY_T12(board)) if (IS_FAMILY_T12(board))
return 2; return 2;
@@ -340,6 +344,8 @@ class SourcesConversionTable: public ConversionTable {
int offset = 0; int offset = 0;
if (version <= 218 && IS_HORUS_X10(board) && i >= CPN_MAX_STICKS + MAX_POTS_STORAGE(board, version)) if (version <= 218 && IS_HORUS_X10(board) && i >= CPN_MAX_STICKS + MAX_POTS_STORAGE(board, version))
offset += 2; offset += 2;
if (version <= 220 && (IS_HORUS_X10(board) || IS_FAMILY_T16(board)) && i >= CPN_MAX_STICKS + MAX_POTS_STORAGE(board, version))
offset += 2;
addConversion(RawSource(SOURCE_TYPE_STICK, i + offset), val++); addConversion(RawSource(SOURCE_TYPE_STICK, i + offset), val++);
} }
@@ -2947,6 +2953,9 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
if (version <= 218 && IS_HORUS_X10(board) && (i == CPN_MAX_STICKS + 3)) { if (version <= 218 && IS_HORUS_X10(board) && (i == CPN_MAX_STICKS + 3)) {
input += 2; input += 2;
} }
if (version <= 220 && IS_FAMILY_HORUS_OR_T16(board) && (i == CPN_MAX_STICKS + 5)) { // make room for EXT3 and EXT4
input += 2;
}
internalField.Append(new SignedField<16>(this, generalData.calibMid[input])); internalField.Append(new SignedField<16>(this, generalData.calibMid[input]));
internalField.Append(new SignedField<16>(this, generalData.calibSpanNeg[input])); internalField.Append(new SignedField<16>(this, generalData.calibSpanNeg[input]));
internalField.Append(new SignedField<16>(this, generalData.calibSpanPos[input])); internalField.Append(new SignedField<16>(this, generalData.calibSpanPos[input]));
@@ -761,6 +761,8 @@ int OpenTxFirmware::getCapability(::Capability capability)
return IS_JUMPER_TPRO(board) ? 6 : 0; return IS_JUMPER_TPRO(board) ? 6 : 0;
case HasModelsList: case HasModelsList:
return IS_FAMILY_HORUS_OR_T16(board); return IS_FAMILY_HORUS_OR_T16(board);
case HasFlySkyGimbals:
return (IS_RADIOMASTER_TX16S(board) && id.contains("flyskygimbals"));
default: default:
return 0; return 0;
} }
@@ -982,6 +984,12 @@ EepromLoadErrors OpenTxEepromInterface::checkVersion(unsigned int version)
// ALL: TimerData countdownStart invert value // ALL: TimerData countdownStart invert value
// ALL: convert more fields from zchar to normal string // ALL: convert more fields from zchar to normal string
// COLORLCD: change CustomScreenData and TopBarPersistentData // COLORLCD: change CustomScreenData and TopBarPersistentData
return OLD_VERSION;
case 221:
// ALL: YAML storage
// X10PCB: add pots EXT3 and EXT4 (conversion required as shifts slider settings in multiple fields)
// RM TX16S: add Flysky gimbals firmware build option and repurpose EXT3 and EXT4 if selected
break; break;
default: default:
@@ -1444,6 +1452,7 @@ void registerOpenTxFirmwares()
static const Firmware::Option opt_internal_gps("internalgps", Firmware::tr("Support internal GPS")); static const Firmware::Option opt_internal_gps("internalgps", Firmware::tr("Support internal GPS"));
firmware->addOptionsGroup({opt_bt, opt_internal_gps}); firmware->addOptionsGroup({opt_bt, opt_internal_gps});
firmware->addOption("externalaccessmod", Firmware::tr("Support hardware mod: R9M ACCESS")); firmware->addOption("externalaccessmod", Firmware::tr("Support hardware mod: R9M ACCESS"));
firmware->addOption("flyskygimbals", Firmware::tr("Support hardware mod: FlySky Paladin EV Gimbals"));
registerOpenTxFirmware(firmware); registerOpenTxFirmware(firmware);
/* Jumper T18 board */ /* Jumper T18 board */
+9 -2
View File
@@ -25,15 +25,22 @@
CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralPanel(parent, generalSettings, firmware) GeneralPanel(parent, generalSettings, firmware)
{ {
int rows = Boards::getCapability(getCurrentBoard(), Board::MaxAnalogs); Board::Type board = getCurrentBoard();
int rows = Boards::getCapability(board, Board::MaxAnalogs);
QStringList headerLabels; QStringList headerLabels;
headerLabels << "" << tr("Negative span") << tr("Mid value") << tr("Positive span"); headerLabels << "" << tr("Negative span") << tr("Mid value") << tr("Positive span");
TableLayout * tableLayout = new TableLayout(this, rows, headerLabels); TableLayout * tableLayout = new TableLayout(this, rows, headerLabels);
for (int i = 0; i < rows; i++) { for (int i = 0, row = 0; i < rows; i++) {
int col = 0; int col = 0;
if (firmware->getCapability(HasFlySkyGimbals) &&
i >= (Boards::getCapability(board, Board::Sticks) + 5) &&
i < (Boards::getCapability(board, Board::Sticks) + 7))
continue;
row++;
QLabel * label = new QLabel(this); QLabel * label = new QLabel(this);
label->setText(firmware->getAnalogInputName(i)); label->setText(firmware->getAnalogInputName(i));
tableLayout->addWidget(i, col++, label); tableLayout->addWidget(i, col++, label);
+2 -1
View File
@@ -64,7 +64,8 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
} }
count = Boards::getCapability(board, Board::Pots); count = Boards::getCapability(board, Board::Pots);
if (count) { count -= firmware->getCapability(HasFlySkyGimbals) ? 2 : 0;
if (count > 0) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
addPot(i, row); addPot(i, row);
} }
+1 -1
View File
@@ -103,7 +103,7 @@ void joystickDialog::populateSourceCombo(QComboBox * cb)
for (i=0; i < Board::STICK_AXIS_COUNT; ++i) { for (i=0; i < Board::STICK_AXIS_COUNT; ++i) {
cb->addItem(Boards::getAxisName(i) % tr(" Stick"), i); cb->addItem(Boards::getAxisName(i) % tr(" Stick"), i);
} }
for (; i < Board::STICK_AXIS_COUNT + CPN_MAX_POTS; ++i) { for (; i < Board::STICK_AXIS_COUNT + CPN_MAX_POTS + CPN_MAX_SLIDERS; ++i) {
cb->addItem(tr("Knob/Slider %1").arg(i - Board::STICK_AXIS_COUNT + 1), i); cb->addItem(tr("Knob/Slider %1").arg(i - Board::STICK_AXIS_COUNT + 1), i);
} }
} }