From 9799e4f745f11422891550ffb871c229424fb987 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 5 Jul 2021 16:45:19 -0700 Subject: [PATCH] Added local af gain and wf length to the preferences. --- audiohandler.h | 1 + rigcommander.cpp | 3 ++- wfmain.cpp | 24 +++++++++++++++++++++--- wfmain.h | 3 +++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/audiohandler.h b/audiohandler.h index 36993a5..6c4c4df 100644 --- a/audiohandler.h +++ b/audiohandler.h @@ -67,6 +67,7 @@ struct audioSetup { QAudioDeviceInfo port; #endif quint8 resampleQuality; + unsigned char localAFgain; }; // For QtMultimedia, use a native QIODevice diff --git a/rigcommander.cpp b/rigcommander.cpp index ec2acf9..6eac210 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -133,7 +133,8 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud connect(ptty, SIGNAL(haveSerialPortError(QString, QString)), this, SLOT(handleSerialPortError(QString, QString))); connect(this, SIGNAL(getMoreDebug()), ptty, SLOT(debugThis())); - emit haveAfGain(255); + + emit haveAfGain(rxSetup.localAFgain); } // data from the comm port to the program: diff --git a/wfmain.cpp b/wfmain.cpp index fca3152..b8721d0 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -877,6 +877,9 @@ void wfmain::setUIToPrefs() ui->drawPeakChk->setChecked(prefs.drawPeaks); on_drawPeakChk_clicked(prefs.drawPeaks); drawPeaks = prefs.drawPeaks; + + ui->wfLengthSlider->setValue(prefs.wflength); + prepareWf(prefs.wflength); } void wfmain::setAudioDevicesUI() @@ -1148,6 +1151,8 @@ void wfmain::setDefPrefs() defPrefs.enableRigCtlD = false; defPrefs.rigCtlPort = 4533; defPrefs.virtualSerialPort = QString("none"); + defPrefs.localAFgain = 255; + defPrefs.wflength = 160; udpDefPrefs.ipAddress = QString(""); udpDefPrefs.controlLANPort = 50001; @@ -1170,6 +1175,7 @@ void wfmain::loadSettings() prefs.useDarkMode = settings->value("UseDarkMode", defPrefs.useDarkMode).toBool(); prefs.useSystemTheme = settings->value("UseSystemTheme", defPrefs.useSystemTheme).toBool(); prefs.drawPeaks = settings->value("DrawPeaks", defPrefs.drawPeaks).toBool(); + prefs.wflength = (unsigned int) settings->value("WFLength", defPrefs.wflength).toInt(); prefs.stylesheetPath = settings->value("StylesheetPath", defPrefs.stylesheetPath).toString(); ui->splitter->restoreState(settings->value("splitter").toByteArray()); @@ -1253,7 +1259,8 @@ void wfmain::loadSettings() ui->vspCombo->setCurrentIndex(ui->vspCombo->count()-1); } - + prefs.localAFgain = (unsigned char) settings->value("localAFgain", defPrefs.localAFgain).toUInt(); + rxSetup.localAFgain = prefs.localAFgain; settings->endGroup(); // Misc. user settings (enable PTT, draw peaks, etc) @@ -1462,6 +1469,7 @@ void wfmain::saveSettings() settings->setValue("splitter", ui->splitter->saveState()); settings->setValue("windowGeometry", saveGeometry()); settings->setValue("windowState", saveState()); + settings->setValue("WFLength", prefs.wflength); settings->endGroup(); // Radio and Comms: C-IV addr, port to use @@ -1470,6 +1478,7 @@ void wfmain::saveSettings() settings->setValue("SerialPortRadio", prefs.serialPortRadio); settings->setValue("SerialPortBaud", prefs.serialPortBaud); settings->setValue("VirtualSerialPort", prefs.virtualSerialPort); + settings->setValue("localAFgain", prefs.localAFgain); settings->endGroup(); // Misc. user settings (enable PTT, draw peaks, etc) @@ -2820,14 +2829,17 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) } ui->scopeBWCombo->blockSignals(false); - setBandButtons(); ui->tuneEnableChk->setEnabled(rigCaps.hasATU); ui->tuneNowBtn->setEnabled(rigCaps.hasATU); ui->connectBtn->setText("Disconnect"); // We must be connected now. - prepareWf(); + prepareWf(ui->wfLengthSlider->value()); + if(usingLAN) + { + ui->afGainSlider->setValue(prefs.localAFgain); + } // Adding these here because clearly at this point we have valid // rig comms. In the future, we should establish comms and then // do all the initial grabs. For now, this hack of adding them here and there: @@ -3853,6 +3865,11 @@ void wfmain::on_rfGainSlider_valueChanged(int value) void wfmain::on_afGainSlider_valueChanged(int value) { issueCmdUniquePriority(cmdSetAfGain, (unsigned char)value); + if(usingLAN) + { + rxSetup.localAFgain = (unsigned char)(value); + prefs.localAFgain = (unsigned char)(value); + } } void wfmain::receiveRfGain(unsigned char level) @@ -4946,6 +4963,7 @@ void wfmain::on_baudRateCombo_activated(int index) void wfmain::on_wfLengthSlider_valueChanged(int value) { + prefs.wflength = (unsigned int)(value); prepareWf(value); } diff --git a/wfmain.h b/wfmain.h index 3c3af1e..2dab814 100644 --- a/wfmain.h +++ b/wfmain.h @@ -666,6 +666,9 @@ private: quint16 rigCtlPort; colors colorScheme; QString virtualSerialPort; + unsigned char localAFgain; + unsigned int wflength; + // plot scheme } prefs; preferences defPrefs;