diff --git a/plugins/feature/simpleptt/simplepttgui.cpp b/plugins/feature/simpleptt/simplepttgui.cpp index 8694cec0e..ab1323ab3 100644 --- a/plugins/feature/simpleptt/simplepttgui.cpp +++ b/plugins/feature/simpleptt/simplepttgui.cpp @@ -16,6 +16,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include #include "feature/featureuiset.h" #include "gui/basicfeaturesettingsdialog.h" @@ -226,6 +227,18 @@ void SimplePTTGUI::displaySettings() ui->voxLevel->setValue(m_settings.m_voxLevel); ui->voxLevelText->setText(tr("%1").arg(m_settings.m_voxLevel)); ui->voxHold->setValue(m_settings.m_voxHold); + ui->commandRxTxEnable->setChecked(m_settings.m_rx2txCommandEnable); + ui->commandTxRxEnable->setChecked(m_settings.m_tx2rxCommandEnable); + ui->gpioRxTxControlEnable->setChecked(m_settings.m_rx2txGPIOEnable); + ui->gpioTxRxControlEnable->setChecked(m_settings.m_tx2rxGPIOEnable); + ui->gpioTxControl->setChecked(m_settings.m_gpioControl == SimplePTTSettings::GPIOTx); + ui->gpioRxControl->setChecked(m_settings.m_gpioControl == SimplePTTSettings::GPIORx); + ui->gpioRxTxMask->setText(QString("%1").arg((m_settings.m_rx2txGPIOMask % 256), 2, 16, QChar('0')).toUpper()); + ui->gpioRxTxValue->setText(QString("%1").arg((m_settings.m_rx2txGPIOValues % 256), 2, 16, QChar('0')).toUpper()); + ui->gpioTxRxMask->setText(QString("%1").arg((m_settings.m_tx2rxGPIOMask % 256), 2, 16, QChar('0')).toUpper()); + ui->gpioTxRxValue->setText(QString("%1").arg((m_settings.m_tx2rxGPIOValues % 256), 2, 16, QChar('0')).toUpper()); + ui->commandRxTx->setText(m_settings.m_rx2txCommand); + ui->commandTxRx->setText(m_settings.m_tx2rxCommand); blockApplySettings(false); } @@ -442,6 +455,155 @@ void SimplePTTGUI::on_voxHold_valueChanged(int value) applySettings(); } +void SimplePTTGUI::on_commandRxTxEnable_toggled(bool checked) +{ + m_settings.m_rx2txCommandEnable = checked; + m_settingsKeys.append("rx2txCommandEnable"); + applySettings(); +} + +void SimplePTTGUI::on_commandTxRxEnable_toggled(bool checked) +{ + m_settings.m_tx2rxCommandEnable = checked; + m_settingsKeys.append("tx2rxCommandEnable"); + applySettings(); +} + +void SimplePTTGUI::on_commandRxTxFileDialog_clicked() +{ + QString commandFileName = ui->commandRxTx->text(); + QFileInfo commandFileInfo(commandFileName); + QString commandFolderName = commandFileInfo.baseName(); + QFileInfo commandDirInfo(commandFolderName); + QString dirStr; + + if (commandFileInfo.exists()) { + dirStr = commandFileName; + } else if (commandDirInfo.exists()) { + dirStr = commandFolderName; + } else { + dirStr = "."; + } + + QString fileName = QFileDialog::getOpenFileName( + this, + tr("Select command"), + dirStr, + tr("All (*);;Python (*.py);;Shell (*.sh *.bat);;Binary (*.bin *.exe)"), 0, QFileDialog::DontUseNativeDialog); + + if (fileName != "") + { + ui->commandRxTx->setText(fileName); + m_settings.m_rx2txCommand = fileName; + m_settingsKeys.append("rx2txCommand"); + applySettings(); + } +} + +void SimplePTTGUI::on_commandTxRxFileDialog_clicked() +{ + QString commandFileName = ui->commandTxRx->text(); + QFileInfo commandFileInfo(commandFileName); + QString commandFolderName = commandFileInfo.baseName(); + QFileInfo commandDirInfo(commandFolderName); + QString dirStr; + + if (commandFileInfo.exists()) { + dirStr = commandFileName; + } else if (commandDirInfo.exists()) { + dirStr = commandFolderName; + } else { + dirStr = "."; + } + + QString fileName = QFileDialog::getOpenFileName( + this, + tr("Select command"), + dirStr, + tr("All (*);;Python (*.py);;Shell (*.sh *.bat);;Binary (*.bin *.exe)"), 0, QFileDialog::DontUseNativeDialog); + + if (fileName != "") + { + ui->commandTxRx->setText(fileName); + m_settings.m_tx2rxCommand = fileName; + m_settingsKeys.append("tx2rxCommand"); + applySettings(); + } +} + +void SimplePTTGUI::on_gpioRxTxControlEnable_toggled(bool checked) +{ + m_settings.m_rx2txGPIOEnable = checked; + m_settingsKeys.append("rx2txGPIOEnable"); + applySettings(); +} + +void SimplePTTGUI::on_gpioTxRxControlEnable_toggled(bool checked) +{ + m_settings.m_tx2rxGPIOEnable = checked; + m_settingsKeys.append("tx2rxGPIOEnable"); + applySettings(); +} + +void SimplePTTGUI::on_gpioRxTxMask_editingFinished() +{ + bool ok; + int mask = ui->gpioRxTxMask->text().toInt(&ok, 16); + + if (ok) + { + m_settings.m_rx2txGPIOMask = mask; + m_settingsKeys.append("rx2txGPIOMask"); + applySettings(); + } +} + +void SimplePTTGUI::on_gpioRxTxValue_editingFinished() +{ + bool ok; + int values = ui->gpioRxTxValue->text().toInt(&ok, 16); + + if (ok) + { + m_settings.m_rx2txGPIOValues = values; + m_settingsKeys.append("rx2txGPIOValues"); + applySettings(); + } +} + +void SimplePTTGUI::on_gpioTxRxMask_editingFinished() +{ + bool ok; + int mask = ui->gpioTxRxMask->text().toInt(&ok, 16); + + if (ok) + { + m_settings.m_tx2rxGPIOMask = mask; + m_settingsKeys.append("tx2rxGPIOMask"); + applySettings(); + } +} + +void SimplePTTGUI::on_gpioTxRxValue_editingFinished() +{ + bool ok; + int values = ui->gpioTxRxValue->text().toInt(&ok, 16); + + if (ok) + { + m_settings.m_tx2rxGPIOValues = values; + m_settingsKeys.append("tx2rxGPIOValues"); + applySettings(); + } +} + +void SimplePTTGUI::on_gpioControl_clicked() +{ + m_settings.m_gpioControl = ui->gpioRxControl->isChecked() ? SimplePTTSettings::GPIORx : SimplePTTSettings::GPIOTx; + m_settingsKeys.append("gpioControl"); + applySettings(); +} + void SimplePTTGUI::updateStatus() { int state = m_simplePTT->getState(); @@ -528,4 +690,16 @@ void SimplePTTGUI::makeUIConnections() QObject::connect(ui->voxEnable, &QCheckBox::clicked, this, &SimplePTTGUI::on_voxEnable_clicked); QObject::connect(ui->voxLevel, &QDial::valueChanged, this, &SimplePTTGUI::on_voxLevel_valueChanged); QObject::connect(ui->voxHold, qOverload(&QSpinBox::valueChanged), this, &SimplePTTGUI::on_voxHold_valueChanged); + QObject::connect(ui->commandRxTxEnable, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_commandRxTxEnable_toggled); + QObject::connect(ui->commandTxRxEnable, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_commandTxRxEnable_toggled); + QObject::connect(ui->commandRxTxFileDialog, &QPushButton::clicked, this, &SimplePTTGUI::on_commandRxTxFileDialog_clicked); + QObject::connect(ui->commandTxRxFileDialog, &QPushButton::clicked, this, &SimplePTTGUI::on_commandTxRxFileDialog_clicked); + QObject::connect(ui->gpioRxTxControlEnable, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_gpioRxTxControlEnable_toggled); + QObject::connect(ui->gpioTxRxControlEnable, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_gpioTxRxControlEnable_toggled); + QObject::connect(ui->gpioRxTxMask, &QLineEdit::editingFinished, this, &SimplePTTGUI::on_gpioRxTxMask_editingFinished); + QObject::connect(ui->gpioRxTxValue, &QLineEdit::editingFinished, this, &SimplePTTGUI::on_gpioRxTxValue_editingFinished); + QObject::connect(ui->gpioTxRxMask, &QLineEdit::editingFinished, this, &SimplePTTGUI::on_gpioTxRxMask_editingFinished); + QObject::connect(ui->gpioTxRxValue, &QLineEdit::editingFinished, this, &SimplePTTGUI::on_gpioTxRxValue_editingFinished); + QObject::connect(ui->gpioRxControl, &QRadioButton::clicked, this, &SimplePTTGUI::on_gpioControl_clicked); + QObject::connect(ui->gpioTxControl, &QRadioButton::clicked, this, &SimplePTTGUI::on_gpioControl_clicked); } diff --git a/plugins/feature/simpleptt/simplepttgui.h b/plugins/feature/simpleptt/simplepttgui.h index c59b99892..abe54264a 100644 --- a/plugins/feature/simpleptt/simplepttgui.h +++ b/plugins/feature/simpleptt/simplepttgui.h @@ -91,6 +91,18 @@ private slots: void on_voxEnable_clicked(bool checked); void on_voxLevel_valueChanged(int value); void on_voxHold_valueChanged(int value); + void on_commandRxTxEnable_toggled(bool checked); + void on_commandTxRxEnable_toggled(bool checked); + void on_commandRxTxFileDialog_clicked(); + void on_commandTxRxFileDialog_clicked(); + void on_gpioRxTxControlEnable_toggled(bool checked); + void on_gpioTxRxControlEnable_toggled(bool checked); + void on_gpioRxTxMask_editingFinished(); + void on_gpioRxTxValue_editingFinished(); + void on_gpioTxRxMask_editingFinished(); + void on_gpioTxRxValue_editingFinished(); + void on_gpioControl_clicked(); + void updateStatus(); void audioSelect(const QPoint& p); }; diff --git a/plugins/feature/simpleptt/simplepttgui.ui b/plugins/feature/simpleptt/simplepttgui.ui index c00b1df61..9299f655b 100644 --- a/plugins/feature/simpleptt/simplepttgui.ui +++ b/plugins/feature/simpleptt/simplepttgui.ui @@ -448,6 +448,9 @@ + + Enable/Disable Rx to Tx command + Rx-Tx Cmd @@ -495,6 +498,9 @@ + + Enable/Disable Tx to Rx command + Tx-Rx Cmd @@ -541,7 +547,10 @@ - + + + Enable/Disable Rx to Tx GPIO + Rx-Tx GPIO @@ -565,6 +574,9 @@ 16777215 + + Rx to Tx GPIO mask (1 byte hex) + HH @@ -588,6 +600,9 @@ 16777215 + + Rx to Tx GPIO value (1 byte hex) + HH @@ -622,6 +637,9 @@ + + Enable/Disable Tx to Rx GPIO + Tx-Rx GPIO @@ -629,6 +647,9 @@ + + Tx to Rx GPIO mask (1 byte hex) + Mask @@ -653,7 +674,7 @@ - + Tx to Rx GPIO value (1 byte hex) Val diff --git a/plugins/feature/simpleptt/simplepttsettings.cpp b/plugins/feature/simpleptt/simplepttsettings.cpp index 0281e33db..40202865f 100644 --- a/plugins/feature/simpleptt/simplepttsettings.cpp +++ b/plugins/feature/simpleptt/simplepttsettings.cpp @@ -214,21 +214,33 @@ void SimplePTTSettings::applySettings(const QStringList& settingsKeys, const Sim if (settingsKeys.contains("gpioControl")) { m_gpioControl = settings.m_gpioControl; } + if (settingsKeys.contains("rx2txGPIOEnable")) { + m_rx2txGPIOMask = settings.m_rx2txGPIOEnable; + } if (settingsKeys.contains("rx2txGPIOMask")) { m_rx2txGPIOMask = settings.m_rx2txGPIOMask; } if (settingsKeys.contains("rx2txGPIOValues")) { m_rx2txGPIOValues = settings.m_rx2txGPIOValues; } + if (settingsKeys.contains("rx2txCommandEnable")) { + m_rx2txCommand = settings.m_rx2txCommandEnable; + } if (settingsKeys.contains("rx2txCommand")) { m_rx2txCommand = settings.m_rx2txCommand; } + if (settingsKeys.contains("tx2rxGPIOEnable")) { + m_tx2rxGPIOMask = settings.m_tx2rxGPIOEnable; + } if (settingsKeys.contains("tx2rxGPIOMask")) { m_tx2rxGPIOMask = settings.m_tx2rxGPIOMask; } if (settingsKeys.contains("tx2rxGPIOValues")) { m_tx2rxGPIOValues = settings.m_tx2rxGPIOValues; } + if (settingsKeys.contains("tx2rxCommandEnable")) { + m_tx2rxCommand = settings.m_tx2rxCommandEnable; + } if (settingsKeys.contains("tx2rxCommand")) { m_tx2rxCommand = settings.m_tx2rxCommand; } @@ -283,21 +295,33 @@ QString SimplePTTSettings::getDebugString(const QStringList& settingsKeys, bool if (settingsKeys.contains("gpioControl") || force) { ostr << " m_gpioControl: " << m_gpioControl; } + if (settingsKeys.contains("rx2txGPIOEnable") || force) { + ostr << " m_rx2txGPIOEnable: " << m_rx2txGPIOEnable; + } if (settingsKeys.contains("rx2txGPIOMask") || force) { ostr << " m_rx2txGPIOMask: " << m_rx2txGPIOMask; } if (settingsKeys.contains("rx2txGPIOValues") || force) { ostr << " m_rx2txGPIOValues: " << m_rx2txGPIOValues; } + if (settingsKeys.contains("rx2txCommandEnable") || force) { + ostr << " m_rx2txCommandEnable: " << m_rx2txCommandEnable; + } if (settingsKeys.contains("rx2txCommand") || force) { ostr << " m_rx2txCommand: " << m_rx2txCommand.toStdString(); } + if (settingsKeys.contains("tx2rxGPIOEnable") || force) { + ostr << " m_tx2rxGPIOEnable: " << m_tx2rxGPIOEnable; + } if (settingsKeys.contains("tx2rxGPIOMask") || force) { ostr << " m_tx2rxGPIOMask: " << m_tx2rxGPIOMask; } if (settingsKeys.contains("tx2rxGPIOValues") || force) { ostr << " m_tx2rxGPIOValues: " << m_tx2rxGPIOValues; } + if (settingsKeys.contains("tx2rxCommandEnable") || force) { + ostr << " m_tx2rxCommandEnable: " << m_tx2rxCommandEnable; + } if (settingsKeys.contains("tx2rxCommand") || force) { ostr << " m_tx2rxCommand: " << m_tx2rxCommand.toStdString(); }