mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
SimplePTT GPIO and commands: GUI implementation
This commit is contained in:
parent
aa911e9026
commit
c50c9753f6
@ -16,6 +16,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#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<int>(&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);
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -448,6 +448,9 @@
|
||||
<layout class="QHBoxLayout" name="commandRxTxLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="commandRxTxEnable">
|
||||
<property name="toolTip">
|
||||
<string>Enable/Disable Rx to Tx command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rx-Tx Cmd</string>
|
||||
</property>
|
||||
@ -495,6 +498,9 @@
|
||||
<layout class="QHBoxLayout" name="commandTxRxLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="commandTxRxEnable">
|
||||
<property name="toolTip">
|
||||
<string>Enable/Disable Tx to Rx command</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tx-Rx Cmd</string>
|
||||
</property>
|
||||
@ -541,7 +547,10 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="gpioRxTxLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="gpioRxControlEnable">
|
||||
<widget class="ButtonSwitch" name="gpioRxTxControlEnable">
|
||||
<property name="toolTip">
|
||||
<string>Enable/Disable Rx to Tx GPIO</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rx-Tx GPIO</string>
|
||||
</property>
|
||||
@ -565,6 +574,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rx to Tx GPIO mask (1 byte hex)</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string>HH</string>
|
||||
</property>
|
||||
@ -588,6 +600,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rx to Tx GPIO value (1 byte hex)</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string>HH</string>
|
||||
</property>
|
||||
@ -622,6 +637,9 @@
|
||||
<layout class="QHBoxLayout" name="gpioTxRxLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="gpioTxRxControlEnable">
|
||||
<property name="toolTip">
|
||||
<string>Enable/Disable Tx to Rx GPIO</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tx-Rx GPIO</string>
|
||||
</property>
|
||||
@ -629,6 +647,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="gpioTxRxMaskLabel">
|
||||
<property name="toolTip">
|
||||
<string>Tx to Rx GPIO mask (1 byte hex)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mask</string>
|
||||
</property>
|
||||
@ -653,7 +674,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="gpioTxRxValueLabel">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
<string>Tx to Rx GPIO value (1 byte hex)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Val</string>
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user