From c28c1dbb35070a185692558ef3e84966004c8856 Mon Sep 17 00:00:00 2001 From: PianetaRadio <78976006+PianetaRadio@users.noreply.github.com> Date: Fri, 8 Apr 2022 18:04:54 +0200 Subject: [PATCH] Clarifier #10 --- CatRadio.pro.user | 2 +- ChangeLog.txt | 2 + guidata.cpp | 1 + guidata.h | 10 +++- mainwindow.cpp | 116 +++++++++++++++++++++++++++++++++++++++------- mainwindow.h | 10 ++++ mainwindow.ui | 115 +++++++++++++++++++++++++++++++++++++++++++-- rigdaemon.cpp | 77 +++++++++++++++++++++++++----- rigdata.h | 7 ++- 9 files changed, 303 insertions(+), 37 deletions(-) diff --git a/CatRadio.pro.user b/CatRadio.pro.user index 4dd1d90..c0cfc15 100644 --- a/CatRadio.pro.user +++ b/CatRadio.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/ChangeLog.txt b/ChangeLog.txt index 1c35294..a57f964 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,10 +3,12 @@ CatRadio (+ New, * Updated, - Removed) 1.2.0 - + + Clarifier RIT/XIT commands + Up/Down VFO buttons + Repeater shift offset + DCS code and squelch + COM port list in the communication config dialog + * Bug correction: IF shift slider now correctly updated 1.1.1 - 2022-03-19 * VFO operations: check rig caps before perform VFO operations diff --git a/guidata.cpp b/guidata.cpp index d700faa..b4e1199 100644 --- a/guidata.cpp +++ b/guidata.cpp @@ -20,3 +20,4 @@ #include "guidata.h" guiConfig guiConf; +guiCommand guiCmd; diff --git a/guidata.h b/guidata.h index 2fdd987..a37c30d 100644 --- a/guidata.h +++ b/guidata.h @@ -6,5 +6,13 @@ typedef struct { int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit up or down - } guiConfig; + + +typedef struct { + int bwidthList; + int antList; + int rangeList; + int tabList; + int toneList; +} guiCommand; diff --git a/mainwindow.cpp b/mainwindow.cpp index 58fa165..ea6cb62 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -45,6 +45,7 @@ extern rigSettings rigSet; extern rigCommand rigCmd; extern rigCommand rigCap; extern guiConfig guiConf; +extern guiCommand guiCmd; int retcode; //Return code from function int i; //Index @@ -80,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->verticalSlider_RFgain, &QAbstractSlider::valueChanged, ui->label_RFgainValue, QOverload::of(&QLabel::setNum)); connect(ui->verticalSlider_AFGain, &QAbstractSlider::valueChanged, ui->label_AFGainValue, QOverload::of(&QLabel::setNum)); connect(ui->verticalSlider_Squelch, &QAbstractSlider::valueChanged, ui->label_SquelchValue, QOverload::of(&QLabel::setNum)); + connect(ui->horizontalSlider_clar, &QAbstractSlider::valueChanged, ui->label_clar, QOverload::of(&QLabel::setNum)); connect(ui->horizontalSlider_IFshift, &QAbstractSlider::valueChanged, ui->label_IFshiftValue,QOverload::of(&QLabel::setNum)); //* Signal and Slot connection for vfoDisplay @@ -175,7 +177,7 @@ void MainWindow::guiInit() } } ui->comboBox_ModeSub->addItem(rig_strrmode(RIG_MODE_NONE)); //add None mode in the modeSub list, used in case mode sub vfo is not targetable - rigCmd.bwidthList = 1; //Command to populate BW combobox in guiUpdate() + guiCmd.bwidthList = 1; //Command to populate BW combobox in guiUpdate() } //* AGC level comboBox @@ -219,6 +221,10 @@ void MainWindow::guiInit() ui->comboBox_Preamp->addItem(QString::number(my_rig->state.preamp[i])); } + //* Clarifier + rigSet.rit = 1; + if (!rig_has_get_func(my_rig, RIG_FUNC_XIT)) ui->radioButton_clarXIT->setCheckable(false); + //* Tone ui->comboBox_toneType->clear(); ui->comboBox_toneType->addItem(""); //None @@ -247,9 +253,10 @@ void MainWindow::guiInit() rigCap.modeSub = 1; } - rigCmd.rangeList = 1; //update range list - rigCmd.antList = 1; //update antenna list - rigCmd.toneList = 1; //update tone list + guiCmd.rangeList = 1; //update range list + guiCmd.antList = 1; //update antenna list + guiCmd.toneList = 1; //update tone list + guiCmd.tabList = 1; //select tab } void MainWindow::guiUpdate() @@ -275,11 +282,16 @@ void MainWindow::guiUpdate() ui->comboBox_Mode->setCurrentText(rig_strrmode(rigGet.mode)); ui->comboBox_ModeSub->setCurrentText(rig_strrmode(rigGet.modeSub)); - if (rigGet.mode == RIG_MODE_CW || rigGet.mode == RIG_MODE_CWR || rigGet.mode == RIG_MODE_CWN) ui->tabWidget->setCurrentIndex(0); //CW tab - if (rigGet.mode == RIG_MODE_FM || rigGet.mode == RIG_MODE_FMN || rigGet.mode == RIG_MODE_PKTFM || rigGet.mode == RIG_MODE_PKTFMN || rigGet.mode == RIG_MODE_C4FM || rigGet.mode == RIG_MODE_DSTAR) ui->tabWidget->setCurrentIndex(1); //FM tab + if (guiCmd.tabList) + { + if (rigGet.mode == RIG_MODE_SSB || rigGet.mode == RIG_MODE_USB || rigGet.mode == RIG_MODE_LSB) ui->tabWidget->setCurrentIndex(0); //Clarifier tab + if (rigGet.mode == RIG_MODE_CW || rigGet.mode == RIG_MODE_CWR || rigGet.mode == RIG_MODE_CWN) ui->tabWidget->setCurrentIndex(1); //CW tab + if (rigGet.mode == RIG_MODE_FM || rigGet.mode == RIG_MODE_FMN || rigGet.mode == RIG_MODE_PKTFM || rigGet.mode == RIG_MODE_PKTFMN || rigGet.mode == RIG_MODE_C4FM || rigGet.mode == RIG_MODE_DSTAR) ui->tabWidget->setCurrentIndex(2); //FM tab + guiCmd.tabList = 0; + } //* BW combobox - if (rigCmd.bwidthList) + if (guiCmd.bwidthList) { ui->comboBox_BW->clear(); filter_list bwidth_list; //IF filter bandwidth per mode @@ -301,14 +313,14 @@ void MainWindow::guiUpdate() //else qDebug() << "vuoto" << rigGet.mode; } ui->comboBox_BW->model()->sort(0, Qt::DescendingOrder); - rigCmd.bwidthList = 0; + guiCmd.bwidthList = 0; } ui->comboBox_BW->setCurrentText(QString::number(rigGet.bwidth)); ui->checkBox_NAR->setChecked(rigGet.bwNarrow); //* Range list - if (rigCmd.rangeList) + if (guiCmd.rangeList) { for (i=0; i= my_rig->state.rx_range_list[i].startf && rigGet.freqMain <= my_rig->state.rx_range_list[i].endf) break; } - if (rigGet.rangeListRxIndex != i) rigCmd.antList = 1; + if (rigGet.rangeListRxIndex != i) guiCmd.antList = 1; rigGet.rangeListRxIndex = i; - rigCmd.rangeList = 0; + guiCmd.rangeList = 0; } //* Antenna list - if (rigCmd.antList) + 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 @@ -348,11 +360,11 @@ void MainWindow::guiUpdate() } } } - rigCmd.antList = 0; + guiCmd.antList = 0; } //* Tone list - if (rigCmd.toneList) + if (guiCmd.toneList) { ui->comboBox_toneFreq->clear(); @@ -374,7 +386,7 @@ void MainWindow::guiUpdate() } } - rigCmd.toneList = 0; + guiCmd.toneList = 0; } //* RF @@ -437,6 +449,20 @@ void MainWindow::guiUpdate() ui->checkBox_NR->setChecked(rigGet.noiseReduction); ui->spinBox_NR->setValue(rigGet.noiseReductionLevel); ui->checkBox_NF->setChecked(rigGet.notchFilter); + if (!ui->horizontalSlider_IFshift->isSliderDown()) ui->horizontalSlider_IFshift->setValue(rigGet.ifShift); + + //* Clarifier + ui->checkBox_clar->setChecked(rigGet.clar); + if (rigSet.xit) + { + ui->radioButton_clarXIT->setChecked(true); + if (!ui->horizontalSlider_clar->isSliderDown()) ui->horizontalSlider_clar->setValue(rigGet.xitOffset); + } + else //rigSet.rit + { + ui->radioButton_clarRIT->setChecked(true); + if (!ui->horizontalSlider_clar->isSliderDown()) ui->horizontalSlider_clar->setValue(rigGet.ritOffset); + } //* CW ui->checkBox_BKIN->setChecked(rigGet.bkin); @@ -613,6 +639,13 @@ void MainWindow::on_pushButton_Tune_clicked() rigCmd.tune = 1; } +void MainWindow::on_pushButton_clarClear_clicked() +{ + if (rigSet.rit) rigSet.ritOffset = 0; + else rigSet.xitOffset = 0; //rigSet.xit + rigCmd.clar = 1; +} + void MainWindow::on_pushButton_Band160_clicked() { set_band(160); @@ -765,6 +798,20 @@ void MainWindow::on_checkBox_NF_toggled(bool checked) } } +void MainWindow::on_checkBox_clar_toggled(bool checked) +{ + if (checked && !rigGet.clar) + { + rigSet.clar = 1; + rigCmd.clar = 1; + } + else if (!checked && rigGet.clar) + { + rigSet.clar = 0; + rigCmd.clar = 1; + } +} + void MainWindow::on_checkBox_APF_toggled(bool checked) { if (checked && !rigGet.apf) @@ -796,6 +843,26 @@ void MainWindow::on_radioButton_Tuner_toggled(bool checked) } } +void MainWindow::on_radioButton_clarRIT_toggled(bool checked) +{ + if (checked) + { + rigSet.rit = 1; + rigSet.xit = 0; + rigCmd.clar = 1; + } +} + +void MainWindow::on_radioButton_clarXIT_toggled(bool checked) +{ + if (checked) + { + rigSet.rit = 0; + rigSet.xit = 1; + rigCmd.clar = 1; + } +} + void MainWindow::on_radioButton_RPTshiftSimplex_toggled(bool checked) { if (checked) @@ -859,6 +926,7 @@ void MainWindow::on_vfoDisplayValueChanged(int value) void MainWindow::on_comboBox_Mode_activated(int index) { rigSet.mode = rig_parse_mode(ui->comboBox_Mode->itemText(index).toLatin1()); + guiCmd.tabList = 1; //update tab rigCmd.mode = 1; } @@ -913,7 +981,7 @@ void MainWindow::on_comboBox_toneType_activated(int index) else if (toneType == "DCS") rigSet.toneType = 4; else rigSet.toneType = 0; - rigCmd.toneList = 1; //update tone list + guiCmd.toneList = 1; //update tone list rigCmd.tone = 1; } @@ -1001,6 +1069,22 @@ void MainWindow::on_horizontalSlider_IFshift_valueChanged(int value) } } +void MainWindow::on_horizontalSlider_clar_valueChanged(int value) +{ + if (!rigCmd.clar) + { + if (rigSet.rit) + { + rigSet.ritOffset = value; + if (rigSet.ritOffset != rigGet.ritOffset) rigCmd.clar = 1; + } + else //rigSet.xit + { + rigSet.xitOffset = value; + if (rigSet.xitOffset != rigGet.xitOffset) rigCmd.clar = 1; + } + } +} //***** Menu ***** diff --git a/mainwindow.h b/mainwindow.h index cf77cdf..436a9de 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -162,6 +162,16 @@ private slots: void on_pushButton_right_clicked(); + void on_checkBox_clar_toggled(bool checked); + + void on_pushButton_clarClear_clicked(); + + void on_horizontalSlider_clar_valueChanged(int value); + + void on_radioButton_clarRIT_toggled(bool checked); + + void on_radioButton_clarXIT_toggled(bool checked); + private: Ui::MainWindow *ui; QTimer *timer; diff --git a/mainwindow.ui b/mainwindow.ui index 52bdff7..4a34b68 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1429,12 +1429,121 @@ 131 - - false - 0 + + + true + + + Clar + + + + + + + + Clarifier + + + + + + + RIT + + + true + + + + + + + XIT + + + + + + + Clear + + + + + + + + + 5 + + + + + PointingHandCursor + + + -10000 + + + 10000 + + + 10 + + + 100 + + + true + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 1000 + + + + + + + + 40 + 0 + + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true diff --git a/rigdaemon.cpp b/rigdaemon.cpp index 6f026f3..2e4abec 100644 --- a/rigdaemon.cpp +++ b/rigdaemon.cpp @@ -19,6 +19,7 @@ #include "rigdaemon.h" #include "rigdata.h" +#include "guidata.h" #include "rigcommand.h" #include @@ -35,6 +36,7 @@ extern rigSettings rigGet; extern rigSettings rigSet; extern rigCommand rigCmd; extern rigCommand rigCap; +extern guiCommand guiCmd; int commandPriority = 0; @@ -116,7 +118,7 @@ void RigDaemon::rigUpdate() retcode = rig_set_freq(my_rig, RIG_VFO_CURR, rigSet.freqMain); if (retcode == RIG_OK) rigGet.freqMain = rigSet.freqMain; rigCmd.freqMain = 0; - rigCmd.rangeList = 1; + guiCmd.rangeList = 1; } else if (rigCmd.freqSub && rigCap.freqSub) //VFO Sub @@ -164,7 +166,7 @@ void RigDaemon::rigUpdate() retcode = rig_set_mode(my_rig, RIG_VFO_CURR, rigSet.mode, RIG_PASSBAND_NOCHANGE); if (retcode == RIG_OK) { - rigCmd.bwidthList = 1; //Update BWidth list + guiCmd.bwidthList = 1; //Update BWidth list commandPriority = 0; //rig_get_mode(my_rig, RIG_VFO_CURR, &rigGet.mode, &rigGet.bwidth); //Get BW } @@ -217,7 +219,7 @@ void RigDaemon::rigUpdate() { if (rigCap.modeSub == 0) rigGet.modeSub = tempMode; //If mode sub VFO not targettable, use buffer commandPriority = 0; - rigCmd.bwidthList = 1; + guiCmd.bwidthList = 1; } } @@ -231,7 +233,7 @@ void RigDaemon::rigUpdate() if (rigCap.freqSub == 0) rigGet.freqSub = tempFreq; //If freq sub VFO not targettable, use buffer if (rigCap.modeSub == 0) rigGet.modeSub = tempMode; //If mode sub VFO not targettable, use buffer commandPriority = 0; - rigCmd.bwidthList = 1; + guiCmd.bwidthList = 1; } } rigCmd.vfoXchange = 0; @@ -275,7 +277,7 @@ void RigDaemon::rigUpdate() if (retcode == RIG_OK) { commandPriority = 0; - rigCmd.bwidthList = 1; + guiCmd.bwidthList = 1; } } rigCmd.bandUp = 0; @@ -290,7 +292,7 @@ void RigDaemon::rigUpdate() if (retcode == RIG_OK) { commandPriority = 0; - rigCmd.bwidthList = 1; + guiCmd.bwidthList = 1; } } rigCmd.bandDown = 0; @@ -300,7 +302,7 @@ void RigDaemon::rigUpdate() if (rigCmd.bandChange) { commandPriority = 0; - rigCmd.bwidthList = 1; + guiCmd.bwidthList = 1; } //* Tune @@ -412,6 +414,45 @@ void RigDaemon::rigUpdate() rigCmd.ifShift = 0; } + //* Clarifier + if (rigCmd.clar) + { + if (rigSet.clar != rigGet.clar) + { + if (rigSet.rit) retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, rigSet.clar); + else if (rigSet.xit) retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, rigSet.clar); + if (retcode == RIG_OK) + { + rigGet.clar = rigSet.clar; + rigGet.rit = rigSet.rit; + rigGet.xit = rigSet.xit; + } + } + + if ((rigSet.rit != rigGet.rit) && rigGet.clar) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, rigSet.rit); + if (retcode == RIG_OK) rigGet.rit = rigSet.rit; + } + if ((rigSet.xit != rigGet.xit) && rigGet.clar) + { + retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, rigSet.xit); + if (retcode == RIG_OK) rigGet.xit = rigSet.xit; + } + + if (rigSet.rit) + { + retcode = rig_set_rit(my_rig, RIG_VFO_CURR, rigSet.ritOffset); + if (retcode == RIG_OK) rigGet.ritOffset = rigSet.ritOffset; + } + else if (rigSet.xit) + { + retcode = rig_set_xit(my_rig, RIG_VFO_CURR, rigSet.xitOffset); + if (retcode == RIG_OK) rigGet.xitOffset = rigSet.xitOffset; + } + rigCmd.clar = 0; + } + //** CW //* CW break-in if (rigCmd.bkin) @@ -494,7 +535,7 @@ void RigDaemon::rigUpdate() rigGet.tone = rigSet.tone; } rigCmd.tone = 0; - rigCmd.toneList = 1; + guiCmd.toneList = 1; } } //end if (!rigGet.ptt) @@ -611,8 +652,20 @@ void RigDaemon::rigUpdate() rigGet.ifShift = retvalue.i; } + //* Clarifier + if ((commandPriority == 16 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) + { + if (rig_has_get_func(my_rig, RIG_FUNC_RIT)) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, &rigGet.rit); //RIT + if (rig_has_get_func(my_rig, RIG_FUNC_XIT)) rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, &rigGet.xit); //XIT + rigGet.clar = rigGet.rit || rigGet.xit; + //qDebug() << rigGet.clar << rigGet.rit << rigGet.xit; + if (rigSet.rit && my_rig->caps->get_rit) rig_get_rit(my_rig, RIG_VFO_CURR, &rigGet.ritOffset); + else if (rigSet.xit && my_rig->caps->get_xit) rig_get_xit(my_rig, RIG_VFO_CURR, &rigGet.xitOffset); + //else rigGet.clarOffset = rigSet.clarOffset; + } + //* CW - if ((commandPriority == 16 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=CW + if ((commandPriority == 17 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=CW { rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_FBKIN, &rigGet.bkin); //Break-in rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_APF, &rigGet.apf); //Audio Peak Filter @@ -621,7 +674,7 @@ void RigDaemon::rigUpdate() } //* FM - if ((commandPriority == 17 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=FM + if ((commandPriority == 18 && !rigGet.ptt && rigCom.fullPoll) || commandPriority == 0) //&& mode=FM { rig_get_rptr_shift(my_rig, RIG_VFO_CURR, &rigGet.rptShift); //Repeater Shift rig_get_rptr_offs(my_rig, RIG_VFO_CURR, &rigGet.rptOffset); //Repeater Offset @@ -659,11 +712,11 @@ void RigDaemon::rigUpdate() rigCmd.tone = 1; }*/ - if (rigGet.toneType != rigSet.toneType) rigCmd.toneList = 1; //update tone list + if (rigGet.toneType != rigSet.toneType) guiCmd.toneList = 1; //update tone list } commandPriority ++; - if (commandPriority == 18) commandPriority = 1; + if (commandPriority == 19) commandPriority = 1; } emit resultReady(); diff --git a/rigdata.h b/rigdata.h index a553a6a..efba46e 100644 --- a/rigdata.h +++ b/rigdata.h @@ -68,6 +68,8 @@ typedef struct { int noiseReduction, noiseReductionLevel; int notchFilter; int ifShift; + int clar, rit, xit; //Clarifier Rx or Tx + shortfreq_t ritOffset, xitOffset; //Clarifier offset (Hz) rptr_shift_t rptShift; //Repeater shift shortfreq_t rptOffset; //Repeater offset (Hz) int toneType; //0 none, 1 burst 1750, 2 CTCSS, 3 CTCSS SQL, 4 DCS @@ -79,7 +81,6 @@ typedef struct { int freqMain, freqSub; int mode, modeSub; int bwidth; - int bwidthList; int vfo; int split; int vfoXchange, vfoCopy; @@ -104,9 +105,7 @@ typedef struct { int noiseReduction, noiseReductionLevel; int notchFilter; int ifShift; + int clar; int rptShift, rptOffset; int tone; - int antList; - int rangeList; - int toneList; } rigCommand;