| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 10:07:41 +01:00
										 |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2015-2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							|  |  |  | // Copyright (C) 2019 Robin Getz <robin.getz@analog.com>                         //
 | 
					
						
							|  |  |  | // Copyright (C) 2022-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02: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                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:57:41 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-04 08:39:51 +02:00
										 |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2020-04-01 23:17:26 +02:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2017-09-04 08:39:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | #include "dsp/dspengine.h"
 | 
					
						
							|  |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							|  |  |  | #include "gui/glspectrum.h"
 | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +01:00
										 |  |  | #include "gui/basicdevicesettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  | #include "gui/dialpopup.h"
 | 
					
						
							|  |  |  | #include "gui/dialogpositioner.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | #include "device/deviceapi.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  | #include "device/deviceuiset.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-05 14:11:25 +02:00
										 |  |  | #include "plutosdr/deviceplutosdr.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | #include "plutosdrinput.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-04 08:39:51 +02:00
										 |  |  | #include "ui_plutosdrinputgui.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | #include "plutosdrinputgui.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  | PlutoSDRInputGui::PlutoSDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2020-10-05 19:23:13 +02:00
										 |  |  |     DeviceGUI(parent), | 
					
						
							| 
									
										
										
										
											2017-09-04 08:39:51 +02:00
										 |  |  |     ui(new Ui::PlutoSDRInputGUI), | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  |     m_settings(), | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     m_sampleRateMode(true), | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  |     m_forceSettings(true), | 
					
						
							|  |  |  |     m_sampleSource(NULL), | 
					
						
							|  |  |  |     m_sampleRate(0), | 
					
						
							|  |  |  |     m_deviceCenterFrequency(0), | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     m_lastEngineState(DeviceAPI::StNotStarted), | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     m_doApplySettings(true), | 
					
						
							|  |  |  |     m_statusCounter(0) | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |     m_deviceUISet = deviceUISet; | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     setAttribute(Qt::WA_DeleteOnClose, true); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     m_sampleSource = (PlutoSDRInput*) m_deviceUISet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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("#PlutoSDRInputGUI { background-color: rgb(64, 64, 64); }"); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     m_helpURL = "plugins/samplesource/plutosdrinput/readme.md"; | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  |     ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); | 
					
						
							| 
									
										
										
										
											2017-09-05 14:11:25 +02:00
										 |  |  |     ui->sampleRate->setValueRange(8, DevicePlutoSDR::srLowLimitFreq, DevicePlutoSDR::srHighLimitFreq); | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->lpf->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); | 
					
						
							| 
									
										
										
										
											2019-02-01 16:42:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     quint32 minLimit, maxLimit; | 
					
						
							|  |  |  |     ((PlutoSDRInput *) m_sampleSource)->getbbLPRange(minLimit, maxLimit); | 
					
						
							|  |  |  |     ui->lpf->setValueRange(5, minLimit/1000, maxLimit/1000); | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); | 
					
						
							| 
									
										
										
										
											2017-09-05 14:11:25 +02:00
										 |  |  |     ui->lpFIR->setValueRange(5, 1U, 56000U); // will be dynamically recalculated
 | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-05 23:51:03 +02:00
										 |  |  |     ui->swDecimLabel->setText(QString::fromUtf8("S\u2193")); | 
					
						
							| 
									
										
										
										
											2017-09-10 18:45:41 +02:00
										 |  |  |     ui->lpFIRDecimationLabel->setText(QString::fromUtf8("\u2193")); | 
					
						
							| 
									
										
										
										
											2017-09-05 23:51:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &))); | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     blockApplySettings(true); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     makeUIConnections(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-05 08:48:09 +02:00
										 |  |  |     connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); | 
					
						
							|  |  |  |     connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  |     m_statusTimer.start(500); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |     connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2018-05-25 19:28:57 +02:00
										 |  |  |     m_sampleSource->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(); | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PlutoSDRInputGui::~PlutoSDRInputGui() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-05 15:40:09 +01:00
										 |  |  |     m_statusTimer.stop(); | 
					
						
							|  |  |  |     m_updateTimer.stop(); | 
					
						
							| 
									
										
										
										
											2017-09-04 08:39:51 +02:00
										 |  |  |     delete ui; | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  | 	m_settings.resetToDefaults(); | 
					
						
							|  |  |  | 	displaySettings(); | 
					
						
							|  |  |  |     m_forceSettings = true; | 
					
						
							|  |  |  | 	sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray PlutoSDRInputGui::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool PlutoSDRInputGui::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if(m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |         m_forceSettings = true; | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         sendSettings(true); | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  | bool PlutoSDRInputGui::handleMessage(const Message& message) | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |     if (PlutoSDRInput::MsgConfigurePlutoSDR::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const PlutoSDRInput::MsgConfigurePlutoSDR& cfg = (PlutoSDRInput::MsgConfigurePlutoSDR&) message; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (cfg.getForce()) { | 
					
						
							|  |  |  |             m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (PlutoSDRInput::MsgStartStop::match(message)) | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         PlutoSDRInput::MsgStartStop& notif = (PlutoSDRInput::MsgStartStop&) message; | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->startStop->setChecked(notif.getStartStop()); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (DevicePlutoSDRShared::MsgCrossReportToBuddy::match(message)) // message from buddy
 | 
					
						
							| 
									
										
										
										
											2017-09-20 18:25:54 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         DevicePlutoSDRShared::MsgCrossReportToBuddy& conf = (DevicePlutoSDRShared::MsgCrossReportToBuddy&) message; | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = conf.getDevSampleRate(); | 
					
						
							|  |  |  |         m_settings.m_lpfFIRlog2Decim = conf.getLpfFiRlog2IntDec(); | 
					
						
							|  |  |  |         m_settings.m_lpfFIRBW = conf.getLpfFirbw(); | 
					
						
							|  |  |  |         m_settings.m_LOppmTenths = conf.getLoPPMTenths(); | 
					
						
							|  |  |  |         m_settings.m_lpfFIREnable = conf.isLpfFirEnable(); | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-02 05:39:55 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |         PlutoSDRInput::MsgStartStop *message = PlutoSDRInput::MsgStartStop::create(checked); | 
					
						
							|  |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_centerFrequency_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_centerFrequency = value * 1000; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_loPPM_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-10 17:18:08 +02:00
										 |  |  |     ui->loPPMText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1))); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     m_settings.m_LOppmTenths = value; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("LOppmTenths"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_dcOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_dcBlock = checked; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("dcBlock"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_iqImbalance_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_iqCorrection = checked; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("iqCorrection"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-25 13:57:24 +02:00
										 |  |  | void PlutoSDRInputGui::on_rfDCOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_hwRFDCBlock = checked; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("hwRFDCBlock"); | 
					
						
							| 
									
										
										
										
											2019-07-25 13:57:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_bbDCOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_hwBBDCBlock = checked; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("hwBBDCBlock"); | 
					
						
							| 
									
										
										
										
											2019-07-25 13:57:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_hwIQImbalance_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_hwIQCorrection = checked; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("hwIQCorrection"); | 
					
						
							| 
									
										
										
										
											2019-07-25 13:57:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | void PlutoSDRInputGui::on_swDecim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_log2Decim = index > 6 ? 6 : index; | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							| 
									
										
										
										
											2019-06-14 16:58:09 +02:00
										 |  |  |     m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-14 16:58:09 +02:00
										 |  |  |     if (!m_sampleRateMode) { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate <<= m_settings.m_log2Decim; | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("log2Decim"); | 
					
						
							|  |  |  |     m_settingsKeys.append("devSampleRate"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_fcPos_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-23 03:03:35 +02:00
										 |  |  |     m_settings.m_fcPos = (PlutoSDRInputSettings::fcPos_t) (index < (int) PlutoSDRInputSettings::FC_POS_END ? index : PlutoSDRInputSettings::FC_POS_CENTER); | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     displayFcTooltip(); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("fcPos"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_sampleRate_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-06-14 16:58:09 +02:00
										 |  |  |     m_settings.m_devSampleRate = value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!m_sampleRateMode) { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate <<= m_settings.m_log2Decim; | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     displayFcTooltip(); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("devSampleRate"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_lpf_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lpfBW = value * 1000; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("lpfBW"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_lpFIREnable_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lpfFIREnable = checked; | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  |     ui->lpFIRDecimation->setEnabled(checked); | 
					
						
							|  |  |  |     ui->lpFIRGain->setEnabled(checked); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIREnable"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_lpFIR_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lpfFIRBW = value * 1000; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIRBW"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_lpFIRDecimation_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lpfFIRlog2Decim = index > 2 ? 2 : index; | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  |     setSampleRateLimits(); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIRlog2Decim"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_lpFIRGain_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-11 23:51:58 +02:00
										 |  |  |     m_settings.m_lpfFIRGain = 6*(index > 3 ? 3 : index) - 12; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIRGain"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_gainMode_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_gainMode = (PlutoSDRInputSettings::GainMode) (index < PlutoSDRInputSettings::GAIN_END ? index : 0); | 
					
						
							| 
									
										
										
										
											2017-09-10 18:51:25 +02:00
										 |  |  |     ui->gain->setEnabled(m_settings.m_gainMode == PlutoSDRInputSettings::GAIN_MANUAL); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("gainMode"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_gain_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-09 15:34:04 +02:00
										 |  |  |     ui->gainText->setText(tr("%1").arg(value)); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     m_settings.m_gain = value; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("gain"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::on_antenna_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_antennaPath = (PlutoSDRInputSettings::RFPath) (index < PlutoSDRInputSettings::RFPATH_END ? index : 0); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("antennaPath"); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  | void PlutoSDRInputGui::on_transverter_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive(); | 
					
						
							|  |  |  |     m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency(); | 
					
						
							| 
									
										
										
										
											2020-06-23 05:04:41 +02:00
										 |  |  |     m_settings.m_iqOrder = ui->transverter->getIQOrder(); | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     qDebug("PlutoSDRInputGui::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-24 00:57:41 +02:00
										 |  |  |     m_settingsKeys.append("transverterMode"); | 
					
						
							|  |  |  |     m_settingsKeys.append("transverterDeltaFrequency"); | 
					
						
							|  |  |  |     m_settingsKeys.append("iqOrder"); | 
					
						
							|  |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  | void PlutoSDRInputGui::on_sampleRateMode_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_sampleRateMode = checked; | 
					
						
							|  |  |  |     displaySampleRate(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::displaySampleRate() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->sampleRate->blockSignals(true); | 
					
						
							|  |  |  |     displayFcTooltip(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_sampleRateMode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }"); | 
					
						
							|  |  |  |         ui->sampleRateMode->setText("SR"); | 
					
						
							|  |  |  |         ui->sampleRate->setValueRange(8, DevicePlutoSDR::srLowLimitFreq, DevicePlutoSDR::srHighLimitFreq); | 
					
						
							|  |  |  |         ui->sampleRate->setValue(m_settings.m_devSampleRate); | 
					
						
							|  |  |  |         ui->sampleRate->setToolTip("Device to host sample rate (S/s)"); | 
					
						
							|  |  |  |         ui->deviceRateText->setToolTip("Baseband sample rate (S/s)"); | 
					
						
							|  |  |  |         uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim); | 
					
						
							|  |  |  |         ui->deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(50,50,50); }"); | 
					
						
							|  |  |  |         ui->sampleRateMode->setText("BB"); | 
					
						
							|  |  |  |         ui->sampleRate->setValueRange(8, DevicePlutoSDR::srLowLimitFreq/(1<<m_settings.m_log2Decim), DevicePlutoSDR::srHighLimitFreq/(1<<m_settings.m_log2Decim)); | 
					
						
							|  |  |  |         ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim)); | 
					
						
							|  |  |  |         ui->sampleRate->setToolTip("Baseband sample rate (S/s)"); | 
					
						
							|  |  |  |         ui->deviceRateText->setToolTip("Device to host sample rate (S/s)"); | 
					
						
							|  |  |  |         ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->sampleRate->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::displayFcTooltip() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int32_t fShift = DeviceSampleSource::calculateFrequencyShift( | 
					
						
							|  |  |  |         m_settings.m_log2Decim, | 
					
						
							|  |  |  |         (DeviceSampleSource::fcPos_t) m_settings.m_fcPos, | 
					
						
							|  |  |  |         m_settings.m_devSampleRate, | 
					
						
							|  |  |  |         DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | void PlutoSDRInputGui::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency); | 
					
						
							|  |  |  |     ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode); | 
					
						
							| 
									
										
										
										
											2020-06-23 05:04:41 +02:00
										 |  |  |     ui->transverter->setIQOrder(m_settings.m_iqOrder); | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->dcOffset->setChecked(m_settings.m_dcBlock); | 
					
						
							|  |  |  |     ui->iqImbalance->setChecked(m_settings.m_iqCorrection); | 
					
						
							| 
									
										
										
										
											2019-07-25 13:57:24 +02:00
										 |  |  |     ui->bbDCOffset->setChecked(m_settings.m_hwBBDCBlock); | 
					
						
							|  |  |  |     ui->rfDCOffset->setChecked(m_settings.m_hwRFDCBlock); | 
					
						
							|  |  |  |     ui->hwIQImbalance->setChecked(m_settings.m_hwIQCorrection); | 
					
						
							| 
									
										
										
										
											2017-09-10 23:38:50 +02:00
										 |  |  |     ui->loPPM->setValue(m_settings.m_LOppmTenths); | 
					
						
							| 
									
										
										
										
											2017-09-10 17:18:08 +02:00
										 |  |  |     ui->loPPMText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1))); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->swDecim->setCurrentIndex(m_settings.m_log2Decim); | 
					
						
							| 
									
										
										
										
											2018-05-26 18:07:21 +02:00
										 |  |  |     ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->lpf->setValue(m_settings.m_lpfBW / 1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable); | 
					
						
							|  |  |  |     ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000); | 
					
						
							|  |  |  |     ui->lpFIRDecimation->setCurrentIndex(m_settings.m_lpfFIRlog2Decim); | 
					
						
							| 
									
										
										
										
											2017-09-11 23:51:58 +02:00
										 |  |  |     ui->lpFIRGain->setCurrentIndex((m_settings.m_lpfFIRGain + 12)/6); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  |     ui->lpFIRDecimation->setEnabled(m_settings.m_lpfFIREnable); | 
					
						
							|  |  |  |     ui->lpFIRGain->setEnabled(m_settings.m_lpfFIREnable); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->gainMode->setCurrentIndex((int) m_settings.m_gainMode); | 
					
						
							|  |  |  |     ui->gain->setValue(m_settings.m_gain); | 
					
						
							|  |  |  |     ui->gainText->setText(tr("%1").arg(m_settings.m_gain)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->antenna->setCurrentIndex((int) m_settings.m_antennaPath); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     setFIRBWLimits(); | 
					
						
							|  |  |  |     setSampleRateLimits(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::sendSettings(bool forceSettings) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_forceSettings = forceSettings; | 
					
						
							|  |  |  |     if(!m_updateTimer.isActive()) { m_updateTimer.start(100); } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::updateHardware() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug() << "PlutoSDRInputGui::updateHardware"; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |         PlutoSDRInput::MsgConfigurePlutoSDR* message = PlutoSDRInput::MsgConfigurePlutoSDR::create(m_settings, m_settingsKeys, m_forceSettings); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         m_forceSettings = false; | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |         m_settingsKeys.clear(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         m_updateTimer.stop(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::blockApplySettings(bool block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_doApplySettings = !block; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     int state = m_deviceUISet->m_deviceAPI->state(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if(m_lastEngineState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch(state) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StNotStarted: | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StIdle: | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StRunning: | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StError: | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |                 QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage()); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastEngineState = state; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_statusCounter % 2 == 0) // 1s
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         uint32_t adcRate = ((PlutoSDRInput *) m_sampleSource)->getADCSampleRate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (adcRate < 100000000) { | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |             ui->adcRateText->setText(tr("%1k").arg(QString::number(adcRate / 1000.0f, 'g', 5))); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |             ui->adcRateText->setText(tr("%1M").arg(QString::number(adcRate / 1000000.0f, 'g', 5))); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_statusCounter % 4 == 0) // 2s
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         std::string rssiStr; | 
					
						
							|  |  |  |         ((PlutoSDRInput *) m_sampleSource)->getRSSI(rssiStr); | 
					
						
							| 
									
										
										
										
											2017-09-10 17:44:34 +02:00
										 |  |  |         ui->rssiText->setText(tr("-%1").arg(QString::fromStdString(rssiStr))); | 
					
						
							| 
									
										
										
										
											2017-10-09 02:18:04 +02:00
										 |  |  |         int gaindB; | 
					
						
							|  |  |  |         ((PlutoSDRInput *) m_sampleSource)->getGain(gaindB); | 
					
						
							|  |  |  |         ui->actualGainText->setText(tr("%1").arg(gaindB)); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_statusCounter % 10 == 0) // 5s
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         if (m_deviceUISet->m_deviceAPI->isBuddyLeader()) { | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |             ((PlutoSDRInput *) m_sampleSource)->fetchTemperature(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ui->temperatureText->setText(tr("%1C").arg(QString::number(((PlutoSDRInput *) m_sampleSource)->getTemperature(), 'f', 0))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_statusCounter++; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  | void PlutoSDRInputGui::setFIRBWLimits() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     float high = DevicePlutoSDR::firBWHighLimitFactor * ((PlutoSDRInput *) m_sampleSource)->getFIRSampleRate(); | 
					
						
							|  |  |  |     float low = DevicePlutoSDR::firBWLowLimitFactor * ((PlutoSDRInput *) m_sampleSource)->getFIRSampleRate(); | 
					
						
							|  |  |  |     ui->lpFIR->setValueRange(5, (int(low)/1000)+1, (int(high)/1000)+1); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:55:13 +02:00
										 |  |  |     ui->lpFIR->setValue(m_settings.m_lpfFIRBW/1000); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::setSampleRateLimits() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint32_t low = ui->lpFIREnable->isChecked() ? DevicePlutoSDR::srLowLimitFreq / (1<<ui->lpFIRDecimation->currentIndex()) : DevicePlutoSDR::srLowLimitFreq; | 
					
						
							|  |  |  |     ui->sampleRate->setValueRange(8, low, DevicePlutoSDR::srHighLimitFreq); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:55:13 +02:00
										 |  |  |     ui->sampleRate->setValue(m_settings.m_devSampleRate); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  | void PlutoSDRInputGui::updateFrequencyLimits() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-01-02 08:50:33 -05:00
										 |  |  |     qint64 minLimit, maxLimit; | 
					
						
							|  |  |  |     // values should be in kHz
 | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; | 
					
						
							| 
									
										
										
										
											2019-01-02 08:50:33 -05:00
										 |  |  |     ((PlutoSDRInput *) m_sampleSource)->getLORange(minLimit, maxLimit); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     minLimit = minLimit/1000 + deltaFrequency; | 
					
						
							|  |  |  |     maxLimit = maxLimit/1000 + deltaFrequency; | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 13:43:32 +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); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |     qDebug("PlutoSDRInputGui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  | void PlutoSDRInputGui::handleInputMessages() | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |     while ((message = m_inputMessageQueue.pop()) != 0) | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |         qDebug("PlutoSDRInputGui::handleInputMessages: message: %s", message->getIdentifier()); | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_sampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-09-24 13:03:08 +02:00
										 |  |  |             qDebug("PlutoSDRInputGui::handleInputMessages: DSPSignalNotification: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |             updateSampleRateAndFrequency(); | 
					
						
							| 
									
										
										
										
											2017-09-10 19:37:23 +02:00
										 |  |  |             setFIRBWLimits(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (handleMessage(*message)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 delete message; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); | 
					
						
							|  |  |  |     m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							| 
									
										
										
										
											2019-04-13 22:16:08 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							| 
									
										
										
										
											2017-09-09 03:09:17 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::openDeviceSettingsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     if (m_contextMenuType == ContextMenuDeviceSettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         BasicDeviceSettingsDialog dialog(this); | 
					
						
							|  |  |  |         dialog.setUseReverseAPI(m_settings.m_useReverseAPI); | 
					
						
							|  |  |  |         dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); | 
					
						
							|  |  |  |         dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); | 
					
						
							|  |  |  |         dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex); | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +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(); | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +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(); | 
					
						
							| 
									
										
										
										
											2022-10-24 00:57:41 +02:00
										 |  |  |         m_settingsKeys.append("useReverseAPI"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIAddress"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIPort"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIDeviceIndex"); | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         sendSettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resetContextMenuType(); | 
					
						
							| 
									
										
										
										
											2018-12-26 16:39:48 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void PlutoSDRInputGui::makeUIConnections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_startStop_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &PlutoSDRInputGui::on_centerFrequency_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->loPPM, &QSlider::valueChanged, this, &PlutoSDRInputGui::on_loPPM_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->dcOffset, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_dcOffset_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->rfDCOffset, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_rfDCOffset_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->bbDCOffset, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_bbDCOffset_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->hwIQImbalance, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_hwIQImbalance_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->iqImbalance, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_iqImbalance_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->swDecim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_swDecim_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->fcPos, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_fcPos_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->sampleRate, &ValueDial::changed, this, &PlutoSDRInputGui::on_sampleRate_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->lpf, &ValueDial::changed, this, &PlutoSDRInputGui::on_lpf_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIREnable, &ButtonSwitch::toggled, this, &PlutoSDRInputGui::on_lpFIREnable_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIR, &ValueDial::changed, this, &PlutoSDRInputGui::on_lpFIR_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIRDecimation, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_lpFIRDecimation_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIRGain, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_lpFIRGain_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->gainMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_gainMode_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->gain, &QDial::valueChanged, this, &PlutoSDRInputGui::on_gain_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->antenna, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlutoSDRInputGui::on_antenna_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->transverter, &TransverterButton::clicked, this, &PlutoSDRInputGui::on_transverter_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->sampleRateMode, &QToolButton::toggled, this, &PlutoSDRInputGui::on_sampleRateMode_toggled); | 
					
						
							|  |  |  | } |