Companion support for software serial power
This commit is contained in:
@@ -214,9 +214,10 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
|
||||
Node serialPort;
|
||||
for (int i = 0; i < GeneralSettings::SP_COUNT; i++) {
|
||||
if (rhs.serialPort[i] != UART_MODE_NONE) {
|
||||
if (rhs.serialPort[i] != GeneralSettings::AUX_SERIAL_OFF) {
|
||||
Node mode = uartModeLut << rhs.serialPort[i];
|
||||
serialPort[LookupValue(serialPortLut, i)]["mode"] = mode;
|
||||
serialPort[LookupValue(serialPortLut, i)]["power"] = (int)rhs.serialPower[i];
|
||||
}
|
||||
}
|
||||
if (serialPort && serialPort.IsMap())
|
||||
@@ -421,13 +422,17 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
YAML::Node port_nr = port.first >> serialPortLut;
|
||||
if (port_nr) {
|
||||
int p = port_nr.as<int>();
|
||||
if (p >= 0 && p < GeneralSettings::SP_COUNT && port.second.IsMap())
|
||||
if (p >= 0 && p < GeneralSettings::SP_COUNT && port.second.IsMap()) {
|
||||
port.second["mode"] >> uartModeLut >> rhs.serialPort[p];
|
||||
int pwr = port.second["power"].as<int>();
|
||||
if (pwr >= 0 && pwr <= 1)
|
||||
port.second["power"] >> rhs.serialPower[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
node["antennaMode"] >> antennaModeLut >> rhs.antennaMode;
|
||||
node["backlightColor"] >> rhs.backlightColor;
|
||||
node["pwrOnSpeed"] >> rhs.pwrOnSpeed;
|
||||
|
||||
@@ -168,7 +168,8 @@ enum Capability {
|
||||
TopBarZones,
|
||||
HasModelsList,
|
||||
HasFlySkyGimbals,
|
||||
RotaryEncoderNavigation
|
||||
RotaryEncoderNavigation,
|
||||
HasSoftwareSerialPower
|
||||
};
|
||||
|
||||
class EEPROMInterface
|
||||
|
||||
@@ -243,6 +243,7 @@ class GeneralSettings {
|
||||
unsigned int mavbaud;
|
||||
unsigned int switchUnlockStates;
|
||||
unsigned int serialPort[SP_COUNT];
|
||||
bool serialPower[SP_COUNT];
|
||||
int antennaMode;
|
||||
unsigned int backlightColor;
|
||||
CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||
|
||||
@@ -772,6 +772,8 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
IS_TARANIS_X9LITE(board) || IS_RADIOMASTER_TX12(board) ||
|
||||
IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX16S(board) ||
|
||||
IS_JUMPER_T18(board));
|
||||
case HasSoftwareSerialPower:
|
||||
return IS_RADIOMASTER_TX16S(board);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -219,32 +219,46 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
|
||||
ExclusiveComboGroup *exclGroup = new ExclusiveComboGroup(
|
||||
this, [=](const QVariant &value) { return value == 0; });
|
||||
|
||||
addSection(tr("Serial port"), row);
|
||||
|
||||
if (firmware->getCapability(HasAuxSerialMode)) {
|
||||
QString lbl = "Serial Port";
|
||||
if (IS_RADIOMASTER_TX16S(board))
|
||||
lbl.append(" (TTL)");
|
||||
QString lbl = "AUX1";
|
||||
addLabel(tr("%1").arg(lbl), row, 0);
|
||||
AutoComboBox *serialPortMode = new AutoComboBox(this);
|
||||
serialPortMode->setModel(editorItemModels->getItemModel(auxmodelid));
|
||||
serialPortMode->setField(generalSettings.serialPort[GeneralSettings::SP_AUX1]);
|
||||
exclGroup->addCombo(serialPortMode);
|
||||
addParams(row, serialPortMode);
|
||||
|
||||
AutoCheckBox *serialPortPower = new AutoCheckBox(this);
|
||||
serialPortPower->setField(generalSettings.serialPower[GeneralSettings::SP_AUX1], this);
|
||||
serialPortPower->setText(tr("Power"));
|
||||
|
||||
addParams(row, serialPortMode, serialPortPower);
|
||||
|
||||
if (!firmware->getCapability(HasSoftwareSerialPower))
|
||||
serialPortPower->setVisible(false);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasAux2SerialMode)) {
|
||||
QString lbl = "Serial Port 2";
|
||||
if (IS_RADIOMASTER_TX16S(board))
|
||||
lbl.append(" (TTL)");
|
||||
QString lbl = "AUX2";
|
||||
addLabel(tr("%1").arg(lbl), row, 0);
|
||||
AutoComboBox *serialPortMode = new AutoComboBox(this);
|
||||
serialPortMode->setModel(editorItemModels->getItemModel(auxmodelid));
|
||||
serialPortMode->setField(generalSettings.serialPort[GeneralSettings::SP_AUX2]);
|
||||
exclGroup->addCombo(serialPortMode);
|
||||
addParams(row, serialPortMode);
|
||||
|
||||
AutoCheckBox *serialPortPower = new AutoCheckBox(this);
|
||||
serialPortPower->setField(generalSettings.serialPower[GeneralSettings::SP_AUX2], this);
|
||||
serialPortPower->setText(tr("Power"));
|
||||
|
||||
addParams(row, serialPortMode, serialPortPower);
|
||||
|
||||
if (!firmware->getCapability(HasSoftwareSerialPower))
|
||||
serialPortPower->setVisible(false);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasVCPSerialMode)) {
|
||||
addLabel(tr("Serial Port VCP"), row, 0);
|
||||
addLabel(tr("VCP"), row, 0);
|
||||
AutoComboBox *serialPortMode = new AutoComboBox(this);
|
||||
serialPortMode->setModel(editorItemModels->getItemModel(vcpmodelid));
|
||||
serialPortMode->setField(generalSettings.serialPort[GeneralSettings::SP_VCP]);
|
||||
|
||||
Reference in New Issue
Block a user