kopia lustrzana https://github.com/PianetaRadio/CatRadio
rodzic
f4ea500269
commit
69d3995653
|
@ -8,6 +8,7 @@ CatRadio
|
|||
+ High SWR indicator
|
||||
+ Meter peak hold indicator
|
||||
+ Debug mode
|
||||
* Updated serial port configuration
|
||||
* Bug fix: NR level
|
||||
* Bug fix: Repeater shift
|
||||
* Bug fix: Power status
|
||||
|
|
104
dialogconfig.cpp
104
dialogconfig.cpp
|
@ -105,6 +105,7 @@ DialogConfig::DialogConfig(QWidget *parent) :
|
|||
ui->comboBox_comPort->setCurrentText(rigCom.rigPort);
|
||||
ui->comboBox_serialSpeed->setCurrentText(QString::number(rigCom.serialSpeed));
|
||||
if (rigCom.civAddr) ui->lineEdit_civAddr->setText(QString::number(rigCom.civAddr,16));
|
||||
setDialogSerialConfig(rigCom.serialDataBits, rigCom.serialParity, rigCom.serialStopBits, rigCom.serialHandshake);
|
||||
}
|
||||
ui->spinBox_RefreshRate->setValue(rigCom.rigRefresh);
|
||||
ui->checkBox_fullPoll->setChecked(rigCom.fullPoll);
|
||||
|
@ -117,6 +118,63 @@ DialogConfig::~DialogConfig()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int DialogConfig::findRigModel(QString rigModel)
|
||||
{
|
||||
QRegularExpression regexp("[0-9]+");
|
||||
QRegularExpressionMatch rigNumber = regexp.match(rigModel);
|
||||
return rigNumber.captured(0).toInt();
|
||||
}
|
||||
|
||||
|
||||
void DialogConfig::setDialogSerialConfig(int dataBits, int parity, int stopBits, int handshake)
|
||||
{
|
||||
switch (dataBits)
|
||||
{
|
||||
case 7: ui->radioButton_dataBits7->setChecked(true); break;
|
||||
case 8: ui->radioButton_dataBits8->setChecked(true); break;
|
||||
}
|
||||
|
||||
switch (parity)
|
||||
{
|
||||
case 0: ui->radioButton_parityNone->setChecked(true); break;
|
||||
case 1: ui->radioButton_parityOdd->setChecked(true); break;
|
||||
case 2: ui->radioButton_parityEven->setChecked(true); break;
|
||||
}
|
||||
|
||||
switch (stopBits)
|
||||
{
|
||||
case 1: ui->radioButton_stopBits1->setChecked(true); break;
|
||||
case 2: ui->radioButton_stopBits2->setChecked(true); break;
|
||||
}
|
||||
|
||||
switch (handshake)
|
||||
{
|
||||
case 0: ui->radioButton_handshakeNone->setChecked(true); break;
|
||||
case 1: ui->radioButton_handshakeXonXoff->setChecked(true); break;
|
||||
case 2: ui->radioButton_handshakeHardware->setChecked(true); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DialogConfig::setRigSerialConfigFromDialog()
|
||||
{
|
||||
if (ui->radioButton_dataBits7->isChecked()) rigCom.serialDataBits = 7;
|
||||
else rigCom.serialDataBits = 8;
|
||||
|
||||
if (ui->radioButton_parityOdd->isChecked()) rigCom.serialParity = RIG_PARITY_ODD;
|
||||
else if (ui->radioButton_parityEven->isChecked()) rigCom.serialParity = RIG_PARITY_EVEN;
|
||||
else rigCom.serialParity = RIG_PARITY_NONE;
|
||||
|
||||
if (ui->radioButton_stopBits1->isChecked()) rigCom.serialStopBits = 1;
|
||||
else rigCom.serialStopBits = 2;
|
||||
|
||||
if (ui->radioButton_handshakeXonXoff->isChecked()) rigCom.serialHandshake = RIG_HANDSHAKE_XONXOFF;
|
||||
else if (ui->radioButton_handshakeHardware->isChecked()) rigCom.serialHandshake = RIG_HANDSHAKE_HARDWARE;
|
||||
else rigCom.serialHandshake = RIG_HANDSHAKE_NONE;
|
||||
}
|
||||
|
||||
|
||||
void DialogConfig::on_buttonBox_accepted()
|
||||
{
|
||||
bool civAddrConv;
|
||||
|
@ -134,9 +192,10 @@ void DialogConfig::on_buttonBox_accepted()
|
|||
else
|
||||
{
|
||||
QString rigModel = ui->comboBox_rigModel->currentText();
|
||||
QRegularExpression regexp("[0-9]+");
|
||||
QRegularExpressionMatch rigNumber = regexp.match(rigModel);
|
||||
rigCom.rigModel = rigNumber.captured(0).toInt();
|
||||
//QRegularExpression regexp("[0-9]+");
|
||||
//QRegularExpressionMatch rigNumber = regexp.match(rigModel);
|
||||
//rigCom.rigModel = rigNumber.captured(0).toInt();
|
||||
rigCom.rigModel = findRigModel(rigModel);
|
||||
|
||||
if (ui->checkBox_netRigctl->isChecked()) //TCP port
|
||||
{
|
||||
|
@ -159,6 +218,7 @@ void DialogConfig::on_buttonBox_accepted()
|
|||
rigCom.rigPort = ui->comboBox_comPort->currentText();
|
||||
rigCom.serialSpeed = ui->comboBox_serialSpeed->currentText().toInt();
|
||||
rigCom.civAddr = ui->lineEdit_civAddr->text().toInt(&civAddrConv,16);
|
||||
setRigSerialConfigFromDialog();
|
||||
|
||||
if (rigCom.rigPort == "" && rigCom.rigModel != 1 && rigCom.rigModel != 6)
|
||||
{
|
||||
|
@ -183,6 +243,10 @@ void DialogConfig::on_buttonBox_accepted()
|
|||
configFile.setValue("rigPort", rigCom.rigPort);
|
||||
configFile.setValue("serialSpeed", ui->comboBox_serialSpeed->currentText());
|
||||
configFile.setValue("civAddress", ui->lineEdit_civAddr->text().toInt(&civAddrConv,16));
|
||||
configFile.setValue("serialDataBits", rigCom.serialDataBits);
|
||||
configFile.setValue("serialParity", rigCom.serialParity);
|
||||
configFile.setValue("serialStopBits", rigCom.serialStopBits);
|
||||
configFile.setValue("serialHandshake", rigCom.serialHandshake);
|
||||
configFile.setValue("netRigctl", ui->checkBox_netRigctl->isChecked());
|
||||
configFile.setValue("rigRefresh", ui->spinBox_RefreshRate->value());
|
||||
configFile.setValue("fullPolling", ui->checkBox_fullPoll->isChecked());
|
||||
|
@ -232,11 +296,43 @@ void DialogConfig::on_checkBox_netRigctl_toggled(bool checked)
|
|||
|
||||
void DialogConfig::on_comboBox_rigModel_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 2 || index == 3 || index == 4)
|
||||
int currentRig = 0;
|
||||
RIG *rig;
|
||||
|
||||
if (index)
|
||||
{
|
||||
QString rigModel = ui->comboBox_rigModel->currentText();
|
||||
currentRig = findRigModel(rigModel);
|
||||
}
|
||||
|
||||
if (currentRig)
|
||||
{
|
||||
rig = rig_init(currentRig);
|
||||
if (rig->caps->port_type == RIG_PORT_SERIAL)
|
||||
{
|
||||
ui->checkBox_netRigctl->setChecked(false);
|
||||
ui->tabWidget_Config->setCurrentIndex(0);
|
||||
setDialogSerialConfig(rig->caps->serial_data_bits, rig->caps->serial_parity, rig->caps->serial_stop_bits, rig->caps->serial_handshake);
|
||||
//qDebug() << rig->caps->serial_data_bits << rig->caps->serial_parity << rig->caps->serial_stop_bits << rig->caps->serial_handshake;
|
||||
}
|
||||
else if (rig->caps->port_type == RIG_PORT_NETWORK)
|
||||
{
|
||||
ui->checkBox_netRigctl->setChecked(true);
|
||||
ui->tabWidget_Config->setCurrentIndex(1);
|
||||
}
|
||||
else if (rig->caps->port_type == RIG_PORT_NONE)
|
||||
{
|
||||
ui->checkBox_netRigctl->setChecked(false);
|
||||
ui->tabWidget_Config->setCurrentIndex(0);
|
||||
ui->comboBox_comPort->clear();
|
||||
}
|
||||
}
|
||||
|
||||
//if (index == 2 || index == 3 || index == 4)
|
||||
//{
|
||||
// ui->checkBox_netRigctl->setChecked(true);
|
||||
// ui->tabWidget_Config->setCurrentIndex(1);
|
||||
//}
|
||||
}
|
||||
|
||||
void DialogConfig::on_comboBox_comPort_currentIndexChanged(int index)
|
||||
|
|
|
@ -45,6 +45,10 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::DialogConfig *ui;
|
||||
|
||||
int findRigModel(QString rigModel); //Find hamlib rig model from the rig selected in the comboBox_rigModel
|
||||
void setDialogSerialConfig(int dataBits, int parity, int stopBits, int handshake); //Set the serial port configuration on the dialog
|
||||
void setRigSerialConfigFromDialog(); //Set the rigConf serial config from dialog serial settings
|
||||
};
|
||||
|
||||
int printRigList(const struct rig_caps *rigCaps, void *data); //Retrives rig list from Hamlib and write to file
|
||||
|
|
162
dialogconfig.ui
162
dialogconfig.ui
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>390</width>
|
||||
<height>378</height>
|
||||
<height>700</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -118,6 +118,124 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_serialDataBits">
|
||||
<property name="title">
|
||||
<string>Data Bits</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_dataBits7">
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_dataBits8">
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_serialStopBits">
|
||||
<property name="title">
|
||||
<string>Stop Bits</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_stopBits1">
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_stopBits2">
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_serialHandshake">
|
||||
<property name="title">
|
||||
<string>Handshake</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_handshakeXonXoff">
|
||||
<property name="text">
|
||||
<string>XON/XOFF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="radioButton_handshakeHardware">
|
||||
<property name="text">
|
||||
<string>Hardware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_handshakeNone">
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_serialParity">
|
||||
<property name="title">
|
||||
<string>Parity</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_parityOdd">
|
||||
<property name="text">
|
||||
<string>Odd</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="radioButton_parityEven">
|
||||
<property name="text">
|
||||
<string>Even</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_parityNone">
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_tcp">
|
||||
|
@ -215,16 +333,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_autoPowerOn">
|
||||
<property name="toolTip">
|
||||
<string>Auto power-on on startup</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto power ON</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_autoConnect">
|
||||
<property name="toolTip">
|
||||
|
@ -235,6 +343,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_autoPowerOn">
|
||||
<property name="toolTip">
|
||||
<string>Auto power-on on startup</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto power ON</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -251,11 +369,25 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>comboBox_rigModel</tabstop>
|
||||
<tabstop>tabWidget_Config</tabstop>
|
||||
<tabstop>comboBox_comPort</tabstop>
|
||||
<tabstop>comboBox_serialSpeed</tabstop>
|
||||
<tabstop>lineEdit_civAddr</tabstop>
|
||||
<tabstop>radioButton_dataBits7</tabstop>
|
||||
<tabstop>radioButton_dataBits8</tabstop>
|
||||
<tabstop>radioButton_parityNone</tabstop>
|
||||
<tabstop>radioButton_parityOdd</tabstop>
|
||||
<tabstop>radioButton_parityEven</tabstop>
|
||||
<tabstop>radioButton_stopBits1</tabstop>
|
||||
<tabstop>radioButton_stopBits2</tabstop>
|
||||
<tabstop>radioButton_handshakeNone</tabstop>
|
||||
<tabstop>radioButton_handshakeXonXoff</tabstop>
|
||||
<tabstop>radioButton_handshakeHardware</tabstop>
|
||||
<tabstop>spinBox_RefreshRate</tabstop>
|
||||
<tabstop>checkBox_fullPoll</tabstop>
|
||||
<tabstop>checkBox_autoConnect</tabstop>
|
||||
<tabstop>checkBox_autoPowerOn</tabstop>
|
||||
<tabstop>checkBox_netRigctl</tabstop>
|
||||
<tabstop>lineEdit_ip</tabstop>
|
||||
</tabstops>
|
||||
|
@ -268,8 +400,8 @@
|
|||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>259</x>
|
||||
<y>324</y>
|
||||
<x>270</x>
|
||||
<y>688</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
|
@ -284,8 +416,8 @@
|
|||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>327</x>
|
||||
<y>324</y>
|
||||
<x>338</x>
|
||||
<y>688</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
|
|
|
@ -106,10 +106,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
//* Load settings from catradio.ini
|
||||
QSettings configFile(QString("catradio.ini"), QSettings::IniFormat);
|
||||
rigCom.rigModel = configFile.value("rigModel", 0).toInt();
|
||||
rigCom.rigModel = configFile.value("rigModel", 0).toUInt();
|
||||
rigCom.rigPort = configFile.value("rigPort").toString();
|
||||
rigCom.serialSpeed = configFile.value("serialSpeed", 9600).toInt();
|
||||
rigCom.serialSpeed = configFile.value("serialSpeed", 9600).toUInt();
|
||||
rigCom.civAddr = configFile.value("civAddress", 0).toInt();
|
||||
rigCom.serialDataBits = configFile.value("serialDataBits", 8).toUInt();
|
||||
rigCom.serialParity = configFile.value("serialParity", 0).toUInt();
|
||||
rigCom.serialStopBits = configFile.value("serialStopBits", 2).toUInt();
|
||||
rigCom.serialHandshake = configFile.value("serialHandshake", 0).toUInt();
|
||||
rigCom.netRigctl = configFile.value("netRigctl", false).toBool();
|
||||
rigCom.rigRefresh = configFile.value("rigRefresh", 100).toInt();
|
||||
rigCom.fullPoll = configFile.value("fullPolling", true).toBool();
|
||||
|
|
|
@ -30,6 +30,10 @@ typedef struct {
|
|||
unsigned rigModel; //Hamlib rig model
|
||||
QString rigPort; //COM port or IP address
|
||||
unsigned serialSpeed; //Serial port baud rate
|
||||
unsigned serialDataBits; //Serial port data bit
|
||||
unsigned serialParity; //Serial port parity (serial_parity_e RIG_PARITY_NONE = 0, RIG_PARITY_ODD, RIG_PARITY_EVEN)
|
||||
unsigned serialStopBits;
|
||||
unsigned serialHandshake; //Serial port handshake (serial_handshake_e RIG_HANDSHAKE_NONE = 0, RIG_HANDSHAKE_XONXOFF, RIG_HANDSHAKE_HARDWARE)
|
||||
int civAddr; //CI-V address (decimal, Icom radio)
|
||||
bool netRigctl; //TCP NET Rigctl
|
||||
unsigned rigRefresh; //GUI refresh interval (ms)
|
||||
|
|
Ładowanie…
Reference in New Issue