Porównaj commity

...

3 Commity

Autor SHA1 Wiadomość Data
PianetaRadio f4ea500269
Auto connect
#41
2024-02-26 19:30:25 +01:00
PianetaRadio 778761a1a8
Default value for NET connection 2024-02-25 21:31:50 +01:00
PianetaRadio 0ae620b732
Code optimization
Use has_get/set_func instead of rig cap
2024-02-25 20:52:04 +01:00
6 zmienionych plików z 120 dodań i 47 usunięć

Wyświetl plik

@ -2,7 +2,8 @@ CatRadio
(+ New, * Updated, - Removed)
1.4.0 - 2023-mm-dd
1.4.0 - 2024-mm-dd
+ Auto Connect option
+ Auto Power-on option
+ High SWR indicator
+ Meter peak hold indicator

Wyświetl plik

@ -1,6 +1,6 @@
/**
** This file is part of the CatRadio project.
** Copyright 2022 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
** Copyright 2022-2024 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -108,6 +108,7 @@ DialogConfig::DialogConfig(QWidget *parent) :
}
ui->spinBox_RefreshRate->setValue(rigCom.rigRefresh);
ui->checkBox_fullPoll->setChecked(rigCom.fullPoll);
ui->checkBox_autoConnect->setChecked(rigCom.autoConnect);
ui->checkBox_autoPowerOn->setChecked(rigCom.autoPowerOn);
}
@ -173,6 +174,7 @@ void DialogConfig::on_buttonBox_accepted()
rigCom.rigRefresh = ui->spinBox_RefreshRate->value();
rigCom.fullPoll = ui->checkBox_fullPoll->isChecked();
rigCom.autoConnect = ui->checkBox_autoConnect->isChecked();
rigCom.autoPowerOn = ui->checkBox_autoPowerOn->isChecked();
//* Save settings in catradio.ini
@ -184,16 +186,27 @@ void DialogConfig::on_buttonBox_accepted()
configFile.setValue("netRigctl", ui->checkBox_netRigctl->isChecked());
configFile.setValue("rigRefresh", ui->spinBox_RefreshRate->value());
configFile.setValue("fullPolling", ui->checkBox_fullPoll->isChecked());
configFile.setValue("autoConnect", ui->checkBox_autoConnect->isChecked());
configFile.setValue("autoPowerOn", ui->checkBox_autoPowerOn->isChecked());
}
int printRigList(const struct rig_caps *rigCaps, void *data) //Load rig list from hamlib and save into file rig.lst
#ifdef RIGCAPS_NOT_CONST //rig_caps is no longer constant starting from hamlib v.4.6
int printRigList(struct rig_caps *rigCaps, void *data) //Load rig list from hamlib and save into file rig.lst
{
if (data) return 0;
QTextStream stream(&rigFile);
stream << rigCaps->rig_model << " " << rigCaps->mfg_name << " " << rigCaps->model_name << "\n";
return 1;
}
#else
int printRigList(const struct rig_caps *rigCaps, void *data)
{
if (data) return 0;
QTextStream stream(&rigFile);
stream << rigCaps->rig_model << " " << rigCaps->mfg_name << " " << rigCaps->model_name << "\n";
return 1;
}
#endif
bool createRigFile()
{

Wyświetl plik

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>385</width>
<height>338</height>
<width>390</width>
<height>378</height>
</rect>
</property>
<property name="windowTitle">
@ -145,7 +145,10 @@
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_ip">
<property name="toolTip">
<string>e.g. 127.0.0.1:4532</string>
<string>rigctld ip:port</string>
</property>
<property name="text">
<string>127.0.0.1:4532</string>
</property>
</widget>
</item>
@ -212,10 +215,23 @@
</property>
</widget>
</item>
<item row="1" column="0">
<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>
<string>Auto power ON</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_autoConnect">
<property name="toolTip">
<string>Auto connect on startup</string>
</property>
<property name="text">
<string>Auto connect</string>
</property>
</widget>
</item>

Wyświetl plik

@ -1,6 +1,6 @@
/**
** This file is part of the CatRadio project.
** Copyright 2022 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
** Copyright 2022-2024 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent)
rigCom.netRigctl = configFile.value("netRigctl", false).toBool();
rigCom.rigRefresh = configFile.value("rigRefresh", 100).toInt();
rigCom.fullPoll = configFile.value("fullPolling", true).toBool();
rigCom.autoConnect = configFile.value("autoConnect", false).toBool();
rigCom.autoPowerOn = configFile.value("autoPowerOn", false).toBool();
guiConf.vfoDisplayMode = configFile.value("vfoDisplayMode", 0).toInt();
guiConf.darkTheme = configFile.value("darkTheme", false).toBool();
@ -184,6 +185,8 @@ MainWindow::MainWindow(QWidget *parent)
//VFO
ui->lineEdit_vfoMain->setValue(0);
ui->lineEdit_vfoSub->setValue(0);
if (rigCom.autoConnect) ui->pushButton_Connect->toggle(); //Auto connect
}
MainWindow::~MainWindow()
@ -217,8 +220,8 @@ MainWindow::~MainWindow()
void MainWindow::guiInit()
{
//* Power on/off cap
//if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_POWERSTAT)==0)
if (my_rig->caps->set_powerstat == NULL)
if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_POWERSTAT)==0)
//if (my_rig->caps->set_powerstat == NULL)
{
ui->pushButton_Power->setDisabled(true); //Power pushbutton disabled
rigCap.onoff = 0;
@ -230,8 +233,8 @@ void MainWindow::guiInit()
}
//* PTT cap
//if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_PTT)==0)
if (my_rig->caps->set_ptt == NULL)
if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_PTT)==0)
//if (my_rig->caps->set_ptt == NULL)
{
ui->pushButton_PTT->setDisabled(true); //PTT pushbutton disabled
rigCap.ptt = 0;
@ -268,16 +271,24 @@ void MainWindow::guiInit()
guiCmd.bwidthList = 1; //Command to populate BW combobox in guiUpdate()
}
//* ANT comboBox
ui->comboBox_Ant->clear();
if (!rig_has_set_func(my_rig, RIG_FUNCTION_SET_ANT)) ui->comboBox_Ant->setEnabled(false);
//* AGC level comboBox
ui->comboBox_AGC->clear();
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < my_rig->caps->agc_level_count; i++) ui->comboBox_AGC->addItem(rig_stragclevel(my_rig->caps->agc_levels[i]));
if (i==0) //Print all levels if list is not specified
if (!rig_has_set_level(my_rig, RIG_LEVEL_AGC)) ui->comboBox_AGC->setEnabled(false);
else
{
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_OFF));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_AUTO));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_FAST));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_MEDIUM));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_SLOW));
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < my_rig->state.agc_level_count; i++) ui->comboBox_AGC->addItem(rig_stragclevel(my_rig->state.agc_levels[i]));
if (i==0) //Print all levels if list is not specified
{
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_OFF));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_AUTO));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_FAST));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_MEDIUM));
ui->comboBox_AGC->addItem(rig_stragclevel(RIG_AGC_SLOW));
}
}
//* Meters & Sub-meter comboBox
@ -296,6 +307,7 @@ void MainWindow::guiInit()
//* Attenuator comboBox
ui->comboBox_Att->clear();
if (!rig_has_set_level(my_rig, RIG_LEVEL_ATT)) ui->comboBox_Att->setEnabled(false);
ui->comboBox_Att->addItem("0");
for (i = 0; i < HAMLIB_MAXDBLSTSIZ && my_rig->state.attenuator[i] != 0; i++)
{
@ -304,6 +316,7 @@ void MainWindow::guiInit()
//* Preamp comboBox
ui->comboBox_Preamp->clear();
if (!rig_has_set_level(my_rig, RIG_LEVEL_PREAMP)) ui->comboBox_Preamp->setEnabled(false);
ui->comboBox_Preamp->addItem("0");
for (i = 0; i < HAMLIB_MAXDBLSTSIZ && my_rig->state.preamp[i] != 0; i++)
{
@ -519,6 +532,7 @@ void MainWindow::guiUpdate()
{
for (i=0; i<HAMLIB_FRQRANGESIZ; i++) //Tx range list
{
//qDebug()<<rigGet.freqMain<<my_rig->state.tx_range_list[i].startf<<my_rig->state.tx_range_list[i].endf;
if (rigGet.freqMain >= my_rig->state.tx_range_list[i].startf && rigGet.freqMain <= my_rig->state.tx_range_list[i].endf) break;
}
rigGet.rangeListTxIndex = i;
@ -537,7 +551,8 @@ void MainWindow::guiUpdate()
if (guiCmd.antList)
{
ui->comboBox_Ant->clear();
if (my_rig->state.tx_range_list[rigGet.rangeListRxIndex].ant == RIG_ANT_NONE) ui->comboBox_Ant->addItem("NONE"); //RIG_ANT_NONE
if (!rig_has_get_func(my_rig, RIG_FUNCTION_GET_ANT)) ui->comboBox_Ant->addItem("");
else if (my_rig->state.tx_range_list[rigGet.rangeListRxIndex].ant == RIG_ANT_NONE) ui->comboBox_Ant->addItem("NONE"); //RIG_ANT_NONE
else for (i=0; i < RIG_ANT_MAX; i++)
{
if (my_rig->state.tx_range_list[rigGet.rangeListRxIndex].ant & (1UL << i))
@ -804,7 +819,7 @@ void MainWindow::on_pushButton_Connect_toggled(bool checked)
rigCom.connected = 1;
guiInit();
connectMsg = "Connected to ";
connectMsg.append(my_rig->caps->model_name);
connectMsg.append(my_rig->state.model_name);
if (rigCap.onoff == 0 || rigGet.onoff == RIG_POWER_ON || rigGet.onoff == RIG_POWER_UNKNOWN)
{
freq_t retfreq;

Wyświetl plik

@ -90,7 +90,8 @@ RIG *RigDaemon::rigConnect(int *retcode)
if (*retcode != RIG_OK) return nullptr; //Rig not connected
else //Rig connected
{
if (my_rig->caps->get_powerstat != NULL) rig_get_powerstat(my_rig, &rigGet.onoff);
if (rig_has_get_func(my_rig, RIG_FUNCTION_GET_POWERSTAT)) rig_get_powerstat(my_rig, &rigGet.onoff);
//if (my_rig->caps->get_powerstat != NULL) rig_get_powerstat(my_rig, &rigGet.onoff);
else rigGet.onoff = RIG_POWER_UNKNOWN;
return my_rig;
}
@ -225,7 +226,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* VFO Exchange
if (rigCmd.vfoXchange)
{
if (my_rig->caps->vfo_ops & RIG_OP_XCHG)
if (my_rig->state.vfo_ops & RIG_OP_XCHG)
{
mode_t tempMode = rigGet.mode;
retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_XCHG);
@ -237,7 +238,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
}
}
else if (my_rig->caps->vfo_ops & RIG_OP_TOGGLE)
else if (my_rig->state.vfo_ops & RIG_OP_TOGGLE)
{
freq_t tempFreq = rigGet.freqMain;
mode_t tempMode = rigGet.mode;
@ -256,7 +257,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* VFO Copy
if (rigCmd.vfoCopy)
{
if (my_rig->caps->vfo_ops & RIG_OP_CPY)
if (my_rig->state.vfo_ops & RIG_OP_CPY)
{
retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_CPY);
if (retcode == RIG_OK)
@ -285,7 +286,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* Band Up
if (rigCmd.bandUp)
{
if (my_rig->caps->vfo_ops & RIG_OP_BAND_UP)
if (my_rig->state.vfo_ops & RIG_OP_BAND_UP)
{
retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_BAND_UP);
if (retcode == RIG_OK) indexCmd = 21;
@ -296,7 +297,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* Band Down
if (rigCmd.bandDown)
{
if (my_rig->caps->vfo_ops & RIG_OP_BAND_DOWN)
if (my_rig->state.vfo_ops & RIG_OP_BAND_DOWN)
{
retcode = rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_BAND_DOWN);
if (retcode == RIG_OK) indexCmd = 21;
@ -323,7 +324,7 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* Tune
if (rigCmd.tune)
{
if (my_rig->caps->vfo_ops & RIG_OP_TUNE) rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_TUNE);
if (my_rig->state.vfo_ops & RIG_OP_TUNE) rig_vfo_op(my_rig, RIG_VFO_CURR, RIG_OP_TUNE);
rigCmd.tune = 0;
}
@ -541,7 +542,8 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* Repeater shift
if (rigCmd.rptShift)
{
if (my_rig->caps->set_rptr_shift)
if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_RPTR_SHIFT))
//if (my_rig->caps->set_rptr_shift)
{
retcode = rig_set_rptr_shift(my_rig, RIG_VFO_CURR, rigSet.rptShift);
if (retcode == RIG_OK) rigGet.rptShift = rigSet.rptShift;
@ -551,7 +553,8 @@ void RigDaemon::rigUpdate(RIG *my_rig)
//* Repeater offset
if (rigCmd.rptOffset)
{
if (my_rig->caps->set_rptr_offs)
if (rig_has_set_func(my_rig, RIG_FUNCTION_SET_RPTR_OFFS))
//if (my_rig->caps->set_rptr_offs)
{
retcode = rig_set_rptr_offs(my_rig, RIG_VFO_CURR, rigSet.rptOffset);
if (retcode == RIG_OK) rigGet.rptOffset = rigSet.rptOffset;
@ -651,55 +654,79 @@ void RigDaemon::rigUpdate(RIG *my_rig)
if ((indexCmd == 3 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_TUNER, &rigGet.tuner);
//* Antenna
if ((indexCmd == 4 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0) rig_get_ant(my_rig, RIG_VFO_CURR, RIG_ANT_CURR, &retvalue, &rigGet.ant, &rigGet.antTx, &rigGet.antRx);
if ((indexCmd == 4 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
if (rig_has_get_func(my_rig, RIG_FUNCTION_GET_ANT)) rig_get_ant(my_rig, RIG_VFO_CURR, RIG_ANT_CURR, &retvalue, &rigGet.ant, &rigGet.antTx, &rigGet.antRx);
}
//* AGC
if ((indexCmd == 5 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, &retvalue);
rigGet.agc = levelagcvalue(retvalue.i);
if (rig_has_get_level(my_rig, RIG_LEVEL_AGC))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, &retvalue);
rigGet.agc = levelagcvalue(retvalue.i);
}
}
//* Attenuator
if ((indexCmd == 6 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_ATT, &retvalue);
rigGet.att = retvalue.i;
if (rig_has_get_level(my_rig, RIG_LEVEL_ATT))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_ATT, &retvalue);
rigGet.att = retvalue.i;
}
}
//* Preamp
if ((indexCmd == 7 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, &retvalue);
rigGet.pre = retvalue.i;
if (rig_has_get_level(my_rig, RIG_LEVEL_PREAMP))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_PREAMP, &retvalue);
rigGet.pre = retvalue.i;
}
}
//* RF power
if ((indexCmd == 8 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &retvalue);
rigGet.rfPower = retvalue.f;
if (rig_has_get_level(my_rig, RIG_LEVEL_RFPOWER))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &retvalue);
rigGet.rfPower = retvalue.f;
}
}
//* RF gain
if ((indexCmd == 9 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RF, &retvalue);
rigGet.rfGain = retvalue.f;
if (rig_has_get_level(my_rig, RIG_LEVEL_RF))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RF, &retvalue);
rigGet.rfGain = retvalue.f;
}
}
//* AF gain
if ((indexCmd == 10 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, &retvalue);
rigGet.afGain = retvalue.f;
if (rig_has_get_level(my_rig, RIG_LEVEL_AF))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, &retvalue);
rigGet.afGain = retvalue.f;
}
}
//* Squelch
if ((indexCmd == 11 && !rigGet.ptt && rigCom.fullPoll) || indexCmd == 0)
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, &retvalue);
rigGet.squelch = retvalue.f;
if (rig_has_get_level(my_rig, RIG_LEVEL_SQL))
{
rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, &retvalue);
rigGet.squelch = retvalue.f;
}
}
//* MIC

Wyświetl plik

@ -1,6 +1,6 @@
/**
** This file is part of the CatRadio project.
** Copyright 2022 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
** Copyright 2022-2024 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -35,6 +35,7 @@ typedef struct {
unsigned rigRefresh; //GUI refresh interval (ms)
int connected; //connected flag
bool fullPoll; //full polling flag
bool autoConnect; //Auto-connect flag
bool autoPowerOn; //Auto Power ON flag
} rigConnect;