| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 10:07:41 +01:00
										 |  |  | // Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>               //
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "sdrplayv3gui.h"
 | 
					
						
							|  |  |  | #include "sdrplayv3input.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "device/deviceapi.h"
 | 
					
						
							|  |  |  | #include "device/deviceuiset.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ui_sdrplayv3gui.h"
 | 
					
						
							|  |  |  | #include "gui/colormapper.h"
 | 
					
						
							|  |  |  | #include "gui/glspectrum.h"
 | 
					
						
							|  |  |  | #include "gui/basicdevicesettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  | #include "gui/dialpopup.h"
 | 
					
						
							|  |  |  | #include "gui/dialogpositioner.h"
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SDRPlayV3Gui::SDRPlayV3Gui(DeviceUISet *deviceUISet, QWidget* parent) : | 
					
						
							|  |  |  |     DeviceGUI(parent), | 
					
						
							|  |  |  |     ui(new Ui::SDRPlayV3Gui), | 
					
						
							|  |  |  |     m_doApplySettings(true), | 
					
						
							|  |  |  |     m_forceSettings(true) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |     m_deviceUISet = deviceUISet; | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     setAttribute(Qt::WA_DeleteOnClose, true); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     m_sdrPlayV3Input = (SDRPlayV3Input*) m_deviceUISet->m_deviceAPI->getSampleSource(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     ui->setupUi(getContents()); | 
					
						
							| 
									
										
										
										
											2022-11-09 15:53:44 +00:00
										 |  |  |     sizeToContents(); | 
					
						
							| 
									
										
										
										
											2022-04-24 02:13:18 +02:00
										 |  |  |     getContents()->setStyleSheet("#SDRPlayV3Gui { background-color: rgb(64, 64, 64); }"); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     m_helpURL = "plugins/samplesource/sdrplayv3/readme.md"; | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->ifFrequency->clear(); | 
					
						
							|  |  |  |     for (unsigned int i = 0; i < SDRPlayV3IF::getNbIFs(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->ifFrequency->addItem(QString::number(SDRPlayV3IF::getIF(i)/1000)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-19 10:10:20 +01:00
										 |  |  |     ui->samplerate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     ui->samplerate->setValueRange(8, 2000000U, 10660000U); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->bandwidth->clear(); | 
					
						
							|  |  |  |     for (unsigned int i = 0; i < SDRPlayV3Bandwidths::getNbBandwidths(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->bandwidth->addItem(QString::number(SDRPlayV3Bandwidths::getBandwidth(i)/1000)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); | 
					
						
							|  |  |  |     connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  |     m_statusTimer.start(500); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &))); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->tuner->blockSignals(true); | 
					
						
							|  |  |  |     ui->antenna->blockSignals(true); | 
					
						
							|  |  |  |     ui->tuner->clear(); | 
					
						
							|  |  |  |     ui->antenna->clear(); | 
					
						
							|  |  |  |     switch (m_sdrPlayV3Input->getDeviceId()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     case SDRPLAY_RSP1_ID: | 
					
						
							|  |  |  |         ui->tuner->addItem("1"); | 
					
						
							|  |  |  |         ui->antenna->addItem("50Ohm"); | 
					
						
							|  |  |  |         ui->amNotch->setVisible(false); | 
					
						
							|  |  |  |         ui->biasTee->setVisible(false); | 
					
						
							|  |  |  |         ui->extRef->setVisible(false); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case SDRPLAY_RSP1A_ID: | 
					
						
							| 
									
										
										
										
											2024-02-18 19:52:34 +01:00
										 |  |  |     case SDRPLAY_RSP1B_ID: | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |         ui->tuner->addItem("1"); | 
					
						
							|  |  |  |         ui->antenna->addItem("50Ohm"); | 
					
						
							|  |  |  |         ui->amNotch->setVisible(false); | 
					
						
							|  |  |  |         ui->extRef->setVisible(false); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case SDRPLAY_RSP2_ID: | 
					
						
							|  |  |  |         ui->tuner->addItem("1"); | 
					
						
							|  |  |  |         ui->antenna->addItem("A"); | 
					
						
							|  |  |  |         ui->antenna->addItem("B"); | 
					
						
							|  |  |  |         ui->antenna->addItem("Hi-Z"); | 
					
						
							|  |  |  |         ui->amNotch->setVisible(false); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case SDRPLAY_RSPduo_ID: | 
					
						
							|  |  |  |         ui->tuner->addItem("1"); | 
					
						
							|  |  |  |         ui->tuner->addItem("2"); | 
					
						
							|  |  |  |         ui->antenna->addItem("50Ohm"); | 
					
						
							|  |  |  |         ui->antenna->addItem("Hi-Z"); | 
					
						
							|  |  |  |         ui->biasTee->setVisible(false); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case SDRPLAY_RSPdx_ID: | 
					
						
							|  |  |  |         ui->tuner->addItem("1"); | 
					
						
							|  |  |  |         ui->antenna->addItem("A"); | 
					
						
							|  |  |  |         ui->antenna->addItem("B"); | 
					
						
							|  |  |  |         ui->antenna->addItem("C"); | 
					
						
							|  |  |  |         ui->amNotch->setVisible(false); | 
					
						
							|  |  |  |         ui->extRef->setVisible(false); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->tuner->blockSignals(false); | 
					
						
							|  |  |  |     ui->antenna->blockSignals(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     makeUIConnections(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); | 
					
						
							|  |  |  |     m_sdrPlayV3Input->setMessageQueueToGUI(&m_inputMessageQueue); | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  |     DialPopup::addPopupsToChildDials(this); | 
					
						
							| 
									
										
										
										
											2023-11-13 20:51:03 +00:00
										 |  |  |     m_resizer.enableChildMouseTracking(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SDRPlayV3Gui::~SDRPlayV3Gui() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-05 15:40:09 +01:00
										 |  |  |     m_statusTimer.stop(); | 
					
						
							|  |  |  |     m_updateTimer.stop(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.resetToDefaults(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_forceSettings = true; | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray SDRPlayV3Gui::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool SDRPlayV3Gui::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if(m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         m_forceSettings = true; | 
					
						
							|  |  |  |         sendSettings(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool SDRPlayV3Gui::handleMessage(const Message& message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (SDRPlayV3Input::MsgConfigureSDRPlayV3::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const SDRPlayV3Input::MsgConfigureSDRPlayV3& cfg = (SDRPlayV3Input::MsgConfigureSDRPlayV3&) message; | 
					
						
							| 
									
										
										
										
											2023-09-15 09:32:41 +01:00
										 |  |  |         qDebug() << "SDRPlayV3Gui::handleMessage: MsgConfigureSDRPlayV3: " << cfg.getSettings().getDebugString(cfg.getSettingsKeys(), cfg.getForce()); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (cfg.getForce()) { | 
					
						
							|  |  |  |             m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (SDRPlayV3Input::MsgStartStop::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SDRPlayV3Input::MsgStartStop& notif = (SDRPlayV3Input::MsgStartStop&) message; | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->startStop->setChecked(notif.getStartStop()); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::handleInputMessages() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ((message = m_inputMessageQueue.pop()) != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("SDRPlayV3Gui::handleInputMessages: message: %s", message->getIdentifier()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_sampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							|  |  |  |             qDebug("SDRPlayV3Gui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							|  |  |  |             updateSampleRateAndFrequency(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (handleMessage(*message)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 delete message; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); | 
					
						
							|  |  |  |     m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							|  |  |  |     ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  | void SDRPlayV3Gui::updateFrequencyLimits() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // values in kHz
 | 
					
						
							|  |  |  |     qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; | 
					
						
							|  |  |  |     qint64 minLimit = 1U + deltaFrequency; | 
					
						
							|  |  |  |     qint64 maxLimit = 2000000U + deltaFrequency; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 15:04:54 +01:00
										 |  |  |     if (m_settings.m_transverterMode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         minLimit = minLimit < 0 ? 0 : minLimit > 999999999 ? 999999999 : minLimit; | 
					
						
							|  |  |  |         maxLimit = maxLimit < 0 ? 0 : maxLimit > 999999999 ? 999999999 : maxLimit; | 
					
						
							|  |  |  |         ui->centerFrequency->setValueRange(9, minLimit, maxLimit); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit; | 
					
						
							|  |  |  |         maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit; | 
					
						
							|  |  |  |         ui->centerFrequency->setValueRange(7, minLimit, maxLimit); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  |     qDebug("SDRPlayV3Gui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | void SDRPlayV3Gui::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  |     ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency); | 
					
						
							|  |  |  |     ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode); | 
					
						
							|  |  |  |     ui->transverter->setIQOrder(m_settings.m_iqOrder); | 
					
						
							|  |  |  |     updateFrequencyLimits(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->ppm->setValue(m_settings.m_LOppmTenths); | 
					
						
							|  |  |  |     ui->ppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->tuner->setCurrentIndex(m_settings.m_tuner); | 
					
						
							|  |  |  |     ui->antenna->setCurrentIndex(m_settings.m_antenna); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->samplerate->setValue(m_settings.m_devSampleRate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->dcOffset->setChecked(m_settings.m_dcBlock); | 
					
						
							|  |  |  |     ui->iqImbalance->setChecked(m_settings.m_iqCorrection); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->extRef->setChecked(m_settings.m_extRef); | 
					
						
							|  |  |  |     ui->biasTee->setChecked(m_settings.m_biasTee); | 
					
						
							|  |  |  |     ui->amNotch->setChecked(m_settings.m_amNotch); | 
					
						
							|  |  |  |     ui->fmNotch->setChecked(m_settings.m_fmNotch); | 
					
						
							|  |  |  |     ui->dabNotch->setChecked(m_settings.m_dabNotch); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->bandwidth->setCurrentIndex(m_settings.m_bandwidthIndex); | 
					
						
							|  |  |  |     ui->ifFrequency->setCurrentIndex(m_settings.m_ifFrequencyIndex); | 
					
						
							|  |  |  |     ui->samplerate->setValue(m_settings.m_devSampleRate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->decim->setCurrentIndex(m_settings.m_log2Decim); | 
					
						
							|  |  |  |     ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updateLNAValues(); | 
					
						
							|  |  |  |     ui->gainLNA->setCurrentIndex(m_settings.m_lnaIndex); | 
					
						
							|  |  |  |     if (m_settings.m_ifAGC) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gainIFAGC->setChecked(true); | 
					
						
							|  |  |  |         ui->gainIF->setEnabled(false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gainIFAGC->setChecked(false); | 
					
						
							|  |  |  |         ui->gainIF->setEnabled(true); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     int gain = m_settings.m_ifGain; | 
					
						
							|  |  |  |     ui->gainIF->setValue(gain); | 
					
						
							|  |  |  |     QString gainText = QStringLiteral("%1").arg(gain, 2, 10, QLatin1Char('0')); | 
					
						
							|  |  |  |     ui->gainIFText->setText(gainText); | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  |     displayReplayLength(); | 
					
						
							|  |  |  |     displayReplayOffset(); | 
					
						
							|  |  |  |     displayReplayStep(); | 
					
						
							|  |  |  |     ui->replayLoop->setChecked(m_settings.m_replayLoop); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::updateLNAValues() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int currentValue = ui->gainLNA->currentText().toInt(); | 
					
						
							|  |  |  |     bool found = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const int *attenuations = SDRPlayV3LNA::getAttenuations(m_sdrPlayV3Input->getDeviceId(), m_settings.m_centerFrequency); | 
					
						
							| 
									
										
										
										
											2023-09-15 09:32:41 +01:00
										 |  |  |     ui->gainLNA->blockSignals(true); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     ui->gainLNA->clear(); | 
					
						
							| 
									
										
										
										
											2024-02-27 13:59:15 +00:00
										 |  |  |     if (attenuations) | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-02-27 13:59:15 +00:00
										 |  |  |         int len = attenuations[0]; | 
					
						
							|  |  |  |         for (int i = 1; i <= len; i++) | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-02-27 13:59:15 +00:00
										 |  |  |             if (attenuations[i] == 0) | 
					
						
							|  |  |  |                 ui->gainLNA->addItem("0"); | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 ui->gainLNA->addItem(QString("-%1").arg(attenuations[i])); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // Find closest match
 | 
					
						
							|  |  |  |             if ((attenuations[i] == -currentValue) || (!found && (attenuations[i] > -currentValue))) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 ui->gainLNA->setCurrentIndex(i - 1); | 
					
						
							|  |  |  |                 found = true; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-27 13:59:15 +00:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug() << "SDRPlayV3Gui::updateLNAValues: No attenuations for deviceID: " << m_sdrPlayV3Input->getDeviceId(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-15 09:32:41 +01:00
										 |  |  |     ui->gainLNA->blockSignals(false); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::sendSettings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     if (!m_updateTimer.isActive()) { | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |         m_updateTimer.start(100); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::updateHardware() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-07-19 10:10:20 +01:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug() << "SDRPlayV3Gui::updateHardware"; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |         SDRPlayV3Input::MsgConfigureSDRPlayV3* message = SDRPlayV3Input::MsgConfigureSDRPlayV3::create(m_settings, m_settingsKeys, m_forceSettings); | 
					
						
							| 
									
										
										
										
											2022-07-19 10:10:20 +01:00
										 |  |  |         m_sdrPlayV3Input->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         m_forceSettings = false; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |         m_settingsKeys.clear(); | 
					
						
							| 
									
										
										
										
											2022-07-19 10:10:20 +01:00
										 |  |  |         m_updateTimer.stop(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state = m_deviceUISet->m_deviceAPI->state(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(m_lastEngineState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch(state) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             case DeviceAPI::StNotStarted: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DeviceAPI::StIdle: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DeviceAPI::StRunning: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DeviceAPI::StError: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							|  |  |  |                 QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage()); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastEngineState = state; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_centerFrequency_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_centerFrequency = value * 1000; | 
					
						
							|  |  |  |     updateLNAValues(); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_ppm_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_LOppmTenths = value; | 
					
						
							|  |  |  |     ui->ppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1))); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("LOppmTenths"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_tuner_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_tuner = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("tuner"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     if (m_sdrPlayV3Input->getDeviceId() == SDRPLAY_RSPduo_ID) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->antenna->clear(); | 
					
						
							|  |  |  |         ui->antenna->addItem("50Ohm"); | 
					
						
							|  |  |  |         if (m_settings.m_tuner == 0) | 
					
						
							|  |  |  |             ui->antenna->addItem("Hi-Z"); | 
					
						
							|  |  |  |         ui->amNotch->setVisible(index == 0); | 
					
						
							|  |  |  |         ui->biasTee->setVisible(index == 1); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_antenna_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_antenna = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("antenna"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_dcOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dcBlock = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("dcBlock"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_iqImbalance_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_iqCorrection = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("iqCorrection"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_extRef_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_extRef = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("extRef"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_biasTee_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_biasTee = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("biasTee"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_amNotch_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_amNotch = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("amNotch"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_fmNotch_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_fmNotch = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("fmNotch"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_dabNotch_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dabNotch = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("dabNotch"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_bandwidth_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_bandwidthIndex = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("bandwidthIndex"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_samplerate_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settings.m_devSampleRate = (uint32_t) value; | 
					
						
							|  |  |  |     m_settingsKeys.append("devSampleRate"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_ifFrequency_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ifFrequencyIndex = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("ifFrequencyIndex"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_decim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_log2Decim = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("log2Decim"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_fcPos_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_fcPos = (SDRPlayV3Settings::fcPos_t) index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("fcPos"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_gainLNA_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lnaIndex = index; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("lnaIndex"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_gainIFAGC_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ifAGC = checked; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("ifAGC"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  |     ui->gainIF->setEnabled(!checked); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_gainIF_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ifGain = value; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("ifGain"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QString gainText = QStringLiteral("%1").arg(value, 2, 10, QLatin1Char('0')); | 
					
						
							|  |  |  |     ui->gainIFText->setText(gainText); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SDRPlayV3Input::MsgStartStop *message = SDRPlayV3Input::MsgStartStop::create(checked); | 
					
						
							|  |  |  |         m_sdrPlayV3Input->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  | void SDRPlayV3Gui::on_transverter_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive(); | 
					
						
							|  |  |  |     m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency(); | 
					
						
							|  |  |  |     m_settings.m_iqOrder = ui->transverter->getIQOrder(); | 
					
						
							|  |  |  |     qDebug("SDRPlayV3Gui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); | 
					
						
							|  |  |  |     updateFrequencyLimits(); | 
					
						
							|  |  |  |     m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000; | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |     m_settingsKeys.append("transverterMode"); | 
					
						
							|  |  |  |     m_settingsKeys.append("transverterDeltaFrequency"); | 
					
						
							|  |  |  |     m_settingsKeys.append("iqOrder"); | 
					
						
							|  |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2022-02-06 20:30:00 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | void SDRPlayV3Gui::openDeviceSettingsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     if (m_contextMenuType == ContextMenuDeviceSettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         BasicDeviceSettingsDialog dialog(this); | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  |         dialog.setReplayBytesPerSecond(m_settings.m_devSampleRate * 2 * sizeof(qint16)); | 
					
						
							|  |  |  |         dialog.setReplayLength(m_settings.m_replayLength); | 
					
						
							|  |  |  |         dialog.setReplayStep(m_settings.m_replayStep); | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         dialog.setUseReverseAPI(m_settings.m_useReverseAPI); | 
					
						
							|  |  |  |         dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); | 
					
						
							|  |  |  |         dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); | 
					
						
							|  |  |  |         dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         dialog.move(p); | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  |         new DialogPositioner(&dialog, false); | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         dialog.exec(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         m_settings.m_useReverseAPI = dialog.useReverseAPI(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  |         m_settings.m_replayLength = dialog.getReplayLength(); | 
					
						
							|  |  |  |         m_settings.m_replayStep = dialog.getReplayStep(); | 
					
						
							|  |  |  |         displayReplayLength(); | 
					
						
							|  |  |  |         displayReplayOffset(); | 
					
						
							|  |  |  |         displayReplayStep(); | 
					
						
							| 
									
										
										
										
											2022-10-28 18:52:08 +02:00
										 |  |  |         m_settingsKeys.append("useReverseAPI"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIAddress"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIPort"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIDeviceIndex"); | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  |         m_settingsKeys.append("replayLength"); | 
					
						
							|  |  |  |         m_settingsKeys.append("replayStep"); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         sendSettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resetContextMenuType(); | 
					
						
							| 
									
										
										
										
											2021-04-11 21:21:36 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  | void SDRPlayV3Gui::displayReplayLength() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool replayEnabled = m_settings.m_replayLength > 0.0f; | 
					
						
							|  |  |  |     if (!replayEnabled) { | 
					
						
							|  |  |  |         ui->replayOffset->setMaximum(0); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         ui->replayOffset->setMaximum(m_settings.m_replayLength * 10 - 1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->replayLabel->setEnabled(replayEnabled); | 
					
						
							|  |  |  |     ui->replayOffset->setEnabled(replayEnabled); | 
					
						
							|  |  |  |     ui->replayOffsetText->setEnabled(replayEnabled); | 
					
						
							|  |  |  |     ui->replaySave->setEnabled(replayEnabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::displayReplayOffset() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool replayEnabled = m_settings.m_replayLength > 0.0f; | 
					
						
							|  |  |  |     ui->replayOffset->setValue(m_settings.m_replayOffset * 10); | 
					
						
							|  |  |  |     ui->replayOffsetText->setText(QString("%1s").arg(m_settings.m_replayOffset, 0, 'f', 1)); | 
					
						
							|  |  |  |     ui->replayNow->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); | 
					
						
							|  |  |  |     ui->replayPlus->setEnabled(replayEnabled && (std::round(m_settings.m_replayOffset * 10) < ui->replayOffset->maximum())); | 
					
						
							|  |  |  |     ui->replayMinus->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::displayReplayStep() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString step; | 
					
						
							|  |  |  |     float intpart; | 
					
						
							|  |  |  |     float frac = modf(m_settings.m_replayStep, &intpart); | 
					
						
							|  |  |  |     if (frac == 0.0f) { | 
					
						
							|  |  |  |         step = QString::number((int)intpart); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         step = QString::number(m_settings.m_replayStep, 'f', 1); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ui->replayPlus->setText(QString("+%1s").arg(step)); | 
					
						
							|  |  |  |     ui->replayPlus->setToolTip(QString("Add %1 seconds to time delay").arg(step)); | 
					
						
							|  |  |  |     ui->replayMinus->setText(QString("-%1s").arg(step)); | 
					
						
							|  |  |  |     ui->replayMinus->setToolTip(QString("Remove %1 seconds from time delay").arg(step)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replayOffset_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_replayOffset = value / 10.0f; | 
					
						
							|  |  |  |     displayReplayOffset(); | 
					
						
							|  |  |  |     m_settingsKeys.append("replayOffset"); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replayNow_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replayPlus_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(ui->replayOffset->value() + m_settings.m_replayStep * 10); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replayMinus_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(ui->replayOffset->value() - m_settings.m_replayStep * 10); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replaySave_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QFileDialog fileDialog(nullptr, "Select file to save IQ data to", "", "*.wav"); | 
					
						
							|  |  |  |     fileDialog.setAcceptMode(QFileDialog::AcceptSave); | 
					
						
							|  |  |  |     if (fileDialog.exec()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QStringList fileNames = fileDialog.selectedFiles(); | 
					
						
							|  |  |  |         if (fileNames.size() > 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SDRPlayV3Input::MsgSaveReplay *message = SDRPlayV3Input::MsgSaveReplay::create(fileNames[0]); | 
					
						
							|  |  |  |             m_sdrPlayV3Input->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRPlayV3Gui::on_replayLoop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_replayLoop = checked; | 
					
						
							|  |  |  |     m_settingsKeys.append("replayLoop"); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:30 +00:00
										 |  |  | void SDRPlayV3Gui::setReplayTime(float time) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(std::ceil(time * 10.0f)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | void SDRPlayV3Gui::makeUIConnections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &SDRPlayV3Gui::on_centerFrequency_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->ppm, &QSlider::valueChanged, this, &SDRPlayV3Gui::on_ppm_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->tuner, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_tuner_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->antenna, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_antenna_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->dcOffset, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_dcOffset_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->iqImbalance, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_iqImbalance_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->extRef, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_extRef_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->biasTee, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_biasTee_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->amNotch, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_amNotch_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->fmNotch, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_fmNotch_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->dabNotch, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_dabNotch_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->bandwidth, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_bandwidth_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->samplerate, &ValueDial::changed, this, &SDRPlayV3Gui::on_samplerate_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->ifFrequency, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_ifFrequency_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->decim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_decim_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->fcPos, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_fcPos_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->gainLNA, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SDRPlayV3Gui::on_gainLNA_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->gainIFAGC, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_gainIFAGC_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->gainIF, &QDial::valueChanged, this, &SDRPlayV3Gui::on_gainIF_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_startStop_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->transverter, &TransverterButton::clicked, this, &SDRPlayV3Gui::on_transverter_clicked); | 
					
						
							| 
									
										
										
										
											2023-11-22 14:28:35 +00:00
										 |  |  |     QObject::connect(ui->replayOffset, &QSlider::valueChanged, this, &SDRPlayV3Gui::on_replayOffset_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->replayNow, &QToolButton::clicked, this, &SDRPlayV3Gui::on_replayNow_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayPlus, &QToolButton::clicked, this, &SDRPlayV3Gui::on_replayPlus_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayMinus, &QToolButton::clicked, this, &SDRPlayV3Gui::on_replayMinus_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replaySave, &QToolButton::clicked, this, &SDRPlayV3Gui::on_replaySave_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayLoop, &ButtonSwitch::toggled, this, &SDRPlayV3Gui::on_replayLoop_toggled); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | } |