| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 10:07:41 +01:00
										 |  |  | // Copyright (C) 2017-2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							|  |  |  | // Copyright (C) 2022-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +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-04-15 11:45:01 +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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "limesdrinputgui.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2020-04-01 23:17:26 +02:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-04 09:33:25 +02:00
										 |  |  | #include <algorithm>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | #include "ui_limesdrinputgui.h"
 | 
					
						
							|  |  |  | #include "gui/colormapper.h"
 | 
					
						
							|  |  |  | #include "gui/glspectrum.h"
 | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  | #include "gui/basicdevicesettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  | #include "gui/dialpopup.h"
 | 
					
						
							|  |  |  | #include "gui/dialogpositioner.h"
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | #include "dsp/dspcommands.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-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  | LimeSDRInputGUI::LimeSDRInputGUI(DeviceUISet *deviceUISet, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2020-10-05 19:23:13 +02:00
										 |  |  |     DeviceGUI(parent), | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     ui(new Ui::LimeSDRInputGUI), | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     m_settings(), | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     m_sampleRateMode(true), | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     m_sampleRate(0), | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     m_lastEngineState(DeviceAPI::StNotStarted), | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |     m_doApplySettings(true), | 
					
						
							| 
									
										
										
										
											2017-10-14 06:48:09 +02:00
										 |  |  |     m_forceSettings(true), | 
					
						
							| 
									
										
										
										
											2017-07-03 13:42:11 +02:00
										 |  |  |     m_statusCounter(0), | 
					
						
							|  |  |  |     m_deviceStatusCounter(0) | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +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_limeSDRInput = (LimeSDRInput*) m_deviceUISet->m_deviceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +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("#LimeSDRInputGUI { background-color: rgb(64, 64, 64); }"); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     m_helpURL = "plugins/samplesource/limesdrinput/readme.md"; | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 11:03:22 +01:00
										 |  |  |     float minF, maxF; | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 11:03:22 +01:00
										 |  |  |     m_limeSDRInput->getLORange(minF, maxF); | 
					
						
							| 
									
										
										
										
											2017-05-16 17:48:12 +02:00
										 |  |  |     ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2022-10-15 03:04:29 +02:00
										 |  |  |     ui->centerFrequency->setValueRange(9, ((uint32_t) minF)/1000, ((uint32_t) maxF)/1000); // frequency dial is in kHz
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 11:03:22 +01:00
										 |  |  |     m_limeSDRInput->getSRRange(minF, maxF); | 
					
						
							| 
									
										
										
										
											2017-05-16 17:48:12 +02:00
										 |  |  |     ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     ui->sampleRate->setValueRange(8, (uint32_t) minF, (uint32_t) maxF); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 11:03:22 +01:00
										 |  |  |     m_limeSDRInput->getLPRange(minF, maxF); | 
					
						
							| 
									
										
										
										
											2017-05-16 21:24:25 +02:00
										 |  |  |     ui->lpf->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); | 
					
						
							| 
									
										
										
										
											2017-04-18 01:16:39 +02:00
										 |  |  |     ui->lpf->setValueRange(6, (minF/1000)+1, maxF/1000); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 21:24:25 +02:00
										 |  |  |     ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); | 
					
						
							| 
									
										
										
										
											2017-04-18 00:50:03 +02:00
										 |  |  |     ui->lpFIR->setValueRange(5, 1U, 56000U); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 17:48:12 +02:00
										 |  |  |     ui->ncoFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     ui->channelNumberText->setText(tr("#%1").arg(m_limeSDRInput->getChannelIndex())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 01:06:23 +02:00
										 |  |  |     if (m_limeSDRInput->getLimeType() == DeviceLimeSDRParams::LimeMini) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->antenna->setItemText(2, "NC"); | 
					
						
							|  |  |  |         ui->antenna->setItemText(3, "Lo"); | 
					
						
							| 
									
										
										
										
											2020-04-19 12:52:32 +02:00
										 |  |  |         ui->antenna->setItemText(4, "NC"); | 
					
						
							|  |  |  |         ui->antenna->setItemText(5, "NC"); | 
					
						
							|  |  |  |         ui->antenna->setToolTip("Antenna select: No: none, NC: not connected, Hi: 2 - 3.5 GHz, Lo: 10 MHz - 2 GHz"); | 
					
						
							| 
									
										
										
										
											2019-04-21 01:06:23 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->antenna->setItemText(2, "Lo"); | 
					
						
							|  |  |  |         ui->antenna->setItemText(3, "Wi"); | 
					
						
							| 
									
										
										
										
											2020-04-19 12:52:32 +02:00
										 |  |  |         ui->antenna->setItemText(4, "T1"); | 
					
						
							| 
									
										
										
										
											2022-02-24 15:51:38 +00:00
										 |  |  |         ui->antenna->setItemText(5, "T2"); | 
					
						
							| 
									
										
										
										
											2020-04-19 12:52:32 +02:00
										 |  |  |         ui->antenna->setToolTip("Antenna select: No: none, NC: not connected, Hi: >1.5 GHz, Lo: <1.5 GHz Wi: full band, T1: Tx1 LB, T2: Tx2 LB"); | 
					
						
							| 
									
										
										
										
											2019-04-21 01:06:23 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); | 
					
						
							|  |  |  |     connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  |     m_statusTimer.start(500); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     makeUIConnections(); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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_limeSDRInput->setMessageQueueToGUI(&m_inputMessageQueue); | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &))); | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  |     DialPopup::addPopupsToChildDials(this); | 
					
						
							| 
									
										
										
										
											2023-11-13 20:51:03 +00:00
										 |  |  |     m_resizer.enableChildMouseTracking(); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInputGUI::~LimeSDRInputGUI() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-05 15:40:09 +01:00
										 |  |  |     m_statusTimer.stop(); | 
					
						
							|  |  |  |     m_updateTimer.stop(); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | void LimeSDRInputGUI::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.resetToDefaults(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_forceSettings = true; | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray LimeSDRInputGUI::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool LimeSDRInputGUI::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |     if (m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |         displaySettings(); | 
					
						
							| 
									
										
										
										
											2017-10-14 06:48:09 +02:00
										 |  |  |         m_forceSettings = true; | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |         sendSettings(); | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  | bool LimeSDRInputGUI::handleMessage(const Message& message) | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |     if (LimeSDRInput::MsgConfigureLimeSDR::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const LimeSDRInput::MsgConfigureLimeSDR& cfg = (LimeSDRInput::MsgConfigureLimeSDR&) message; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +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 (DeviceLimeSDRShared::MsgReportBuddyChange::match(message)) | 
					
						
							| 
									
										
										
										
											2017-10-24 02:20:57 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-10-25 01:38:39 +02:00
										 |  |  |         DeviceLimeSDRShared::MsgReportBuddyChange& report = (DeviceLimeSDRShared::MsgReportBuddyChange&) message; | 
					
						
							| 
									
										
										
										
											2017-10-24 02:20:57 +02:00
										 |  |  |         m_settings.m_devSampleRate = report.getDevSampleRate(); | 
					
						
							|  |  |  |         m_settings.m_log2HardDecim = report.getLog2HardDecimInterp(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-25 01:38:39 +02:00
										 |  |  |         if (report.getRxElseTx()) { | 
					
						
							|  |  |  |             m_settings.m_centerFrequency = report.getCenterFrequency(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 02:20:57 +02:00
										 |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-05 10:16:36 +01:00
										 |  |  |     else if (DeviceLimeSDRShared::MsgReportClockSourceChange::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceLimeSDRShared::MsgReportClockSourceChange& report = (DeviceLimeSDRShared::MsgReportClockSourceChange&) message; | 
					
						
							|  |  |  |         m_settings.m_extClockFreq = report.getExtClockFeq(); | 
					
						
							|  |  |  |         m_settings.m_extClock = report.getExtClock(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->extClock->setExternalClockFrequency(m_settings.m_extClockFreq); | 
					
						
							|  |  |  |         ui->extClock->setExternalClockActive(m_settings.m_extClock); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-08-27 17:08:03 +01:00
										 |  |  |     else if (LimeSDRInput::MsgCalibrationResult::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         LimeSDRInput::MsgCalibrationResult& report = (LimeSDRInput::MsgCalibrationResult&) message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (report.getSuccess()) { | 
					
						
							|  |  |  |             ui->calibrationLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             ui->calibrationLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-09-16 15:32:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2022-08-27 17:08:03 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |     else if (LimeSDRInput::MsgReportStreamInfo::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         LimeSDRInput::MsgReportStreamInfo& report = (LimeSDRInput::MsgReportStreamInfo&) message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (report.getSuccess()) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-10-27 00:22:58 +02:00
										 |  |  |             if (report.getActive()) { | 
					
						
							|  |  |  |                 ui->streamStatusLabel->setStyleSheet("QLabel { background-color : green; }"); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->streamStatusLabel->setStyleSheet("QLabel { background-color : blue; }"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |             ui->streamLinkRateText->setText(tr("%1 MB/s").arg(QString::number(report.getLinkRate() / 1000000.0f, 'f', 3))); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (report.getUnderrun() > 0) { | 
					
						
							|  |  |  |                 ui->underrunLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->underrunLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (report.getOverrun() > 0) { | 
					
						
							|  |  |  |                 ui->overrunLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->overrunLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (report.getDroppedPackets() > 0) { | 
					
						
							|  |  |  |                 ui->droppedLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->droppedLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             ui->fifoBar->setMaximum(report.getFifoSize()); | 
					
						
							|  |  |  |             ui->fifoBar->setValue(report.getFifoFilledCount()); | 
					
						
							|  |  |  |             ui->fifoBar->setToolTip(tr("FIFO fill %1/%2 samples").arg(QString::number(report.getFifoFilledCount())).arg(QString::number(report.getFifoSize()))); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ui->streamStatusLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (DeviceLimeSDRShared::MsgReportDeviceInfo::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceLimeSDRShared::MsgReportDeviceInfo& report = (DeviceLimeSDRShared::MsgReportDeviceInfo&) message; | 
					
						
							|  |  |  |         ui->temperatureText->setText(tr("%1C").arg(QString::number(report.getTemperature(), 'f', 0))); | 
					
						
							| 
									
										
										
										
											2018-11-29 23:37:34 +01:00
										 |  |  |         ui->gpioText->setText(tr("%1").arg(report.getGPIOPins(), 2, 16, QChar('0')).toUpper()); | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |     else if (LimeSDRInput::MsgStartStop::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         LimeSDRInput::MsgStartStop& notif = (LimeSDRInput::MsgStartStop&) message; | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->startStop->setChecked(notif.getStartStop()); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  | void LimeSDRInputGUI::updateFrequencyLimits() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // values in kHz
 | 
					
						
							|  |  |  |     float minF, maxF; | 
					
						
							|  |  |  |     qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; | 
					
						
							|  |  |  |     m_limeSDRInput->getLORange(minF, maxF); | 
					
						
							|  |  |  |     qint64 minLimit = minF/1000 + deltaFrequency; | 
					
						
							|  |  |  |     qint64 maxLimit = maxF/1000 + deltaFrequency; | 
					
						
							| 
									
										
										
										
											2022-08-21 15:34:51 +01:00
										 |  |  |     // Min freq is 30MHz - NCO must be used to go below this
 | 
					
						
							|  |  |  |     qint64 minFreq = m_settings.m_ncoEnable ? 30000 + m_settings.m_ncoFrequency/1000 : 30000; | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 13:43:32 +01:00
										 |  |  |     if (m_settings.m_transverterMode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         minLimit = minLimit < minFreq ? minFreq : minLimit > 999999999 ? 999999999 : minLimit; | 
					
						
							|  |  |  |         maxLimit = maxLimit < 0 ? 0 : maxLimit > 999999999 ? 999999999 : maxLimit; | 
					
						
							|  |  |  |         ui->centerFrequency->setValueRange(9, minLimit, maxLimit); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         minLimit = minLimit < minFreq ? minFreq : minLimit > 9999999 ? 9999999 : minLimit; | 
					
						
							|  |  |  |         maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit; | 
					
						
							|  |  |  |         ui->centerFrequency->setValueRange(7, minLimit, maxLimit); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |     qDebug("LimeSDRInputGUI::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  | void LimeSDRInputGUI::handleInputMessages() | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |     while ((message = m_inputMessageQueue.pop()) != 0) | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_sampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |             qDebug("LimeSDRInputGUI::handleInputMessages: DSPSignalNotification: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |             updateSampleRateAndFrequency(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-08 15:11:16 +01:00
										 |  |  |         else if (LimeSDRInput::MsgConfigureLimeSDR::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             const LimeSDRInput::MsgConfigureLimeSDR& cfg = (LimeSDRInput::MsgConfigureLimeSDR&) *message; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (cfg.getForce()) { | 
					
						
							|  |  |  |                 m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 15:11:16 +01:00
										 |  |  |             displaySettings(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |             if (handleMessage(*message)) { | 
					
						
							|  |  |  |                 delete message; | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-07-03 13:42:11 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-07 00:01:01 +02:00
										 |  |  | void LimeSDRInputGUI::updateADCRate() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint32_t adcRate = m_settings.m_devSampleRate * (1<<m_settings.m_log2HardDecim); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (adcRate < 100000000) { | 
					
						
							|  |  |  |         ui->adcRateLabel->setText(tr("%1k").arg(QString::number(adcRate / 1000.0f, 'g', 5))); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         ui->adcRateLabel->setText(tr("%1M").arg(QString::number(adcRate / 1000000.0f, 'g', 5))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | void LimeSDRInputGUI::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); | 
					
						
							|  |  |  |     m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							| 
									
										
										
										
											2022-08-27 17:08:03 +01:00
										 |  |  |     checkLPF(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Check if LPF BW is set wide enough when up-converting using NCO
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::checkLPF() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool highlightLPFLabel = false; | 
					
						
							|  |  |  |     int64_t centerFrequency = m_settings.m_centerFrequency; | 
					
						
							|  |  |  |     if (m_settings.m_ncoEnable) { | 
					
						
							|  |  |  |         centerFrequency += m_settings.m_ncoFrequency; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (centerFrequency < 30000000) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int64_t requiredBW = 30000000 - centerFrequency; | 
					
						
							|  |  |  |         highlightLPFLabel = m_settings.m_lpfBW < requiredBW; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (highlightLPFLabel) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->lpfLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |         ui->lpfLabel->setToolTip("LPF BW is too low for selected center frequency"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->lpfLabel->setStyleSheet("QLabel { background-color: rgb(64, 64, 64); }"); | 
					
						
							|  |  |  |         ui->lpfLabel->setToolTip(""); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  | void LimeSDRInputGUI::displaySampleRate() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     float minF, maxF; | 
					
						
							|  |  |  |     m_limeSDRInput->getSRRange(minF, maxF); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->sampleRate->blockSignals(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_sampleRateMode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }"); | 
					
						
							|  |  |  |         ui->sampleRateMode->setText("SR"); | 
					
						
							|  |  |  |         ui->sampleRate->setValueRange(8, (uint32_t) minF, (uint32_t) maxF); | 
					
						
							|  |  |  |         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_log2SoftDecim); | 
					
						
							|  |  |  |         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, (uint32_t) minF/(1<<m_settings.m_log2SoftDecim), (uint32_t) maxF/(1<<m_settings.m_log2SoftDecim)); | 
					
						
							|  |  |  |         ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2SoftDecim)); | 
					
						
							|  |  |  |         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); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | void LimeSDRInputGUI::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-01-16 21:28:35 +01: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); | 
					
						
							| 
									
										
										
										
											2019-01-16 21:28:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-05 05:59:04 +01:00
										 |  |  |     ui->extClock->setExternalClockFrequency(m_settings.m_extClockFreq); | 
					
						
							|  |  |  |     ui->extClock->setExternalClockActive(m_settings.m_extClock); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-25 12:25:50 +02:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     setCenterFrequencyDisplay(); | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->dcOffset->setChecked(m_settings.m_dcBlock); | 
					
						
							| 
									
										
										
										
											2025-03-27 01:20:53 +01:00
										 |  |  |     ui->splitFreq->setChecked(m_settings.m_splitFreq); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     ui->iqImbalance->setChecked(m_settings.m_iqCorrection); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->hwDecim->setCurrentIndex(m_settings.m_log2HardDecim); | 
					
						
							|  |  |  |     ui->swDecim->setCurrentIndex(m_settings.m_log2SoftDecim); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-07 00:01:01 +02:00
										 |  |  |     updateADCRate(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 01:16:39 +02:00
										 |  |  |     ui->lpf->setValue(m_settings.m_lpfBW / 1000); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable); | 
					
						
							| 
									
										
										
										
											2017-04-18 00:50:03 +02:00
										 |  |  |     ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->gain->setValue(m_settings.m_gain); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     ui->gainText->setText(tr("%1").arg(m_settings.m_gain)); | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 01:47:31 +02:00
										 |  |  |     ui->antenna->setCurrentIndex((int) m_settings.m_antennaPath); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     ui->gainMode->setCurrentIndex((int) m_settings.m_gainMode); | 
					
						
							|  |  |  |     ui->lnaGain->setValue(m_settings.m_lnaGain); | 
					
						
							|  |  |  |     ui->tiaGain->setCurrentIndex(m_settings.m_tiaGain - 1); | 
					
						
							|  |  |  |     ui->pgaGain->setValue(m_settings.m_pgaGain); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.m_gainMode == LimeSDRInputSettings::GAIN_AUTO) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gain->setEnabled(true); | 
					
						
							|  |  |  |         ui->lnaGain->setEnabled(false); | 
					
						
							|  |  |  |         ui->tiaGain->setEnabled(false); | 
					
						
							|  |  |  |         ui->pgaGain->setEnabled(false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gain->setEnabled(false); | 
					
						
							|  |  |  |         ui->lnaGain->setEnabled(true); | 
					
						
							|  |  |  |         ui->tiaGain->setEnabled(true); | 
					
						
							|  |  |  |         ui->pgaGain->setEnabled(true); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2017-05-12 03:31:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->ncoEnable->setChecked(m_settings.m_ncoEnable); | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:46 +00:00
										 |  |  |     displayReplayLength(); | 
					
						
							|  |  |  |     displayReplayOffset(); | 
					
						
							|  |  |  |     displayReplayStep(); | 
					
						
							|  |  |  |     ui->replayLoop->setChecked(m_settings.m_replayLoop); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setNCODisplay() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardDecim)))/2; | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     ui->ncoFrequency->setValueRange( | 
					
						
							|  |  |  |             false, | 
					
						
							|  |  |  |             8, | 
					
						
							|  |  |  |             -ncoHalfRange, | 
					
						
							| 
									
										
										
										
											2018-03-14 19:52:54 +01:00
										 |  |  |             ncoHalfRange); | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->ncoFrequency->blockSignals(true); | 
					
						
							| 
									
										
										
										
											2018-03-14 19:52:54 +01:00
										 |  |  |     ui->ncoFrequency->setToolTip(QString("NCO frequency shift in Hz (Range: +/- %1 kHz)").arg(ncoHalfRange/1000)); | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     ui->ncoFrequency->setValue(m_settings.m_ncoFrequency); | 
					
						
							|  |  |  |     ui->ncoFrequency->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setCenterFrequencyDisplay() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int64_t centerFrequency = m_settings.m_centerFrequency; | 
					
						
							|  |  |  |     ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.m_ncoEnable) { | 
					
						
							|  |  |  |         centerFrequency += m_settings.m_ncoFrequency; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->centerFrequency->blockSignals(true); | 
					
						
							|  |  |  |     ui->centerFrequency->setValue(centerFrequency < 0 ? 0 : (uint64_t) centerFrequency/1000); // kHz
 | 
					
						
							|  |  |  |     ui->centerFrequency->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setCenterFrequencySetting(uint64_t kHzValue) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int64_t centerFrequency = kHzValue*1000; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.m_ncoEnable) { | 
					
						
							|  |  |  |         centerFrequency -= m_settings.m_ncoFrequency; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_settings.m_centerFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; | 
					
						
							|  |  |  |     ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::sendSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if(!m_updateTimer.isActive()) | 
					
						
							|  |  |  |         m_updateTimer.start(100); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::updateHardware() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-18 01:16:39 +02:00
										 |  |  |         qDebug() << "LimeSDRInputGUI::updateHardware"; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |         LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings, m_settingsKeys, m_forceSettings); | 
					
						
							| 
									
										
										
										
											2017-09-18 01:11:15 +02:00
										 |  |  |         m_limeSDRInput->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2017-10-14 06:48:09 +02:00
										 |  |  |         m_forceSettings = false; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |         m_settingsKeys.clear(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |         m_updateTimer.stop(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     int state = m_deviceUISet->m_deviceAPI->state(); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if(m_lastEngineState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch(state) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StNotStarted: | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StIdle: | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StRunning: | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |             case DeviceAPI::StError: | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +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-04-16 04:58:52 +02:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastEngineState = state; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_statusCounter < 1) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_statusCounter++; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         LimeSDRInput::MsgGetStreamInfo* message = LimeSDRInput::MsgGetStreamInfo::create(); | 
					
						
							| 
									
										
										
										
											2017-09-18 01:11:15 +02:00
										 |  |  |         m_limeSDRInput->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |         m_statusCounter = 0; | 
					
						
							| 
									
										
										
										
											2017-07-03 13:42:11 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_deviceStatusCounter < 10) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_deviceStatusCounter++; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |         if (m_deviceUISet->m_deviceAPI->isBuddyLeader()) | 
					
						
							| 
									
										
										
										
											2017-07-03 23:26:06 +02:00
										 |  |  |         { | 
					
						
							|  |  |  |             LimeSDRInput::MsgGetDeviceInfo* message = LimeSDRInput::MsgGetDeviceInfo::create(); | 
					
						
							| 
									
										
										
										
											2017-09-18 01:11:15 +02:00
										 |  |  |             m_limeSDRInput->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2017-07-03 23:26:06 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-03 13:42:11 +02:00
										 |  |  |         m_deviceStatusCounter = 0; | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | void LimeSDRInputGUI::blockApplySettings(bool block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_doApplySettings = !block; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |         LimeSDRInput::MsgStartStop *message = LimeSDRInput::MsgStartStop::create(checked); | 
					
						
							|  |  |  |         m_limeSDRInput->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     setCenterFrequencySetting(value); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  | void LimeSDRInputGUI::on_ncoFrequency_changed(qint64 value) | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     m_settings.m_ncoFrequency = value; | 
					
						
							| 
									
										
										
										
											2022-08-21 15:34:51 +01:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     setCenterFrequencyDisplay(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("ncoFrequency"); | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_ncoEnable_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ncoEnable = checked; | 
					
						
							| 
									
										
										
										
											2022-08-21 15:34:51 +01:00
										 |  |  |     updateFrequencyLimits(); | 
					
						
							| 
									
										
										
										
											2018-03-14 06:30:45 +01:00
										 |  |  |     setCenterFrequencyDisplay(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("ncoEnable"); | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | void LimeSDRInputGUI::on_dcOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_dcBlock = checked; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("dcBlock"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 01:20:53 +01:00
										 |  |  | void LimeSDRInputGUI::on_splitFreq_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_splitFreq = checked; | 
					
						
							|  |  |  |     m_settingsKeys.append("splitFreq"); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | void LimeSDRInputGUI::on_iqImbalance_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_iqCorrection = checked; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("iqCorrection"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_sampleRate_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     if (m_sampleRateMode) { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = value; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = value * (1 << m_settings.m_log2SoftDecim); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-07 00:01:01 +02:00
										 |  |  |     updateADCRate(); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("devSampleRate"); | 
					
						
							| 
									
										
										
										
											2020-04-09 06:45:31 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_hwDecim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     if ((index <0) || (index > 5)) { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_log2HardDecim = index; | 
					
						
							| 
									
										
										
										
											2017-07-07 00:01:01 +02:00
										 |  |  |     updateADCRate(); | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("log2HardDecim"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     if ((index <0) || (index > 6)) { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_log2SoftDecim = index; | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  |     displaySampleRate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_sampleRateMode) { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2SoftDecim); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("log2SoftDecim"); | 
					
						
							|  |  |  |     m_settingsKeys.append("devSampleRate"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 02:01:30 +02:00
										 |  |  | void LimeSDRInputGUI::on_lpf_changed(quint64 value) | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-18 01:16:39 +02:00
										 |  |  |     m_settings.m_lpfBW = value * 1000; | 
					
						
							| 
									
										
										
										
											2022-08-27 17:08:03 +01:00
										 |  |  |     checkLPF(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("lpfBW"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_lpFIREnable_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_lpfFIREnable = checked; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIREnable"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_lpFIR_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-18 00:50:03 +02:00
										 |  |  |     m_settings.m_lpfFIRBW = value * 1000; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("lpfFIRBW"); | 
					
						
							| 
									
										
										
										
											2018-08-13 16:58:43 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  | void LimeSDRInputGUI::on_gainMode_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_gainMode = (LimeSDRInputSettings::GainMode) index; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (index == 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gain->setEnabled(true); | 
					
						
							|  |  |  |         ui->lnaGain->setEnabled(false); | 
					
						
							|  |  |  |         ui->tiaGain->setEnabled(false); | 
					
						
							|  |  |  |         ui->pgaGain->setEnabled(false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->gain->setEnabled(false); | 
					
						
							|  |  |  |         ui->lnaGain->setEnabled(true); | 
					
						
							|  |  |  |         ui->tiaGain->setEnabled(true); | 
					
						
							|  |  |  |         ui->pgaGain->setEnabled(true); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("gainMode"); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | void LimeSDRInputGUI::on_gain_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_gain = value; | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     ui->gainText->setText(tr("%1").arg(m_settings.m_gain)); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("gain"); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_lnaGain_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_lnaGain = value; | 
					
						
							|  |  |  |     ui->lnaGainText->setText(tr("%1").arg(m_settings.m_lnaGain)); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("lnaGain"); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_tiaGain_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_tiaGain = index + 1; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("tiaGain"); | 
					
						
							| 
									
										
										
										
											2017-07-04 23:48:24 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_pgaGain_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_pgaGain = value; | 
					
						
							|  |  |  |     ui->pgaGainText->setText(tr("%1").arg(m_settings.m_pgaGain)); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("pgaGain"); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_antenna_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) index; | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("antennaPath"); | 
					
						
							| 
									
										
										
										
											2017-04-23 16:23:01 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-05 05:59:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_extClock_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_extClock = ui->extClock->getExternalClockActive(); | 
					
						
							|  |  |  |     m_settings.m_extClockFreq = ui->extClock->getExternalClockFrequency(); | 
					
						
							|  |  |  |     qDebug("LimeSDRInputGUI::on_extClock_clicked: %u Hz %s", m_settings.m_extClockFreq, m_settings.m_extClock ? "on" : "off"); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("extClock"); | 
					
						
							|  |  |  |     m_settingsKeys.append("extClockFreq"); | 
					
						
							| 
									
										
										
										
											2017-11-05 05:59:04 +01:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  | void LimeSDRInputGUI::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(); | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |     qDebug("LimeSDRInputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); | 
					
						
							|  |  |  |     updateFrequencyLimits(); | 
					
						
							|  |  |  |     setCenterFrequencySetting(ui->centerFrequency->getValueNew()); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |     m_settingsKeys.append("transverterMode"); | 
					
						
							|  |  |  |     m_settingsKeys.append("transverterDeltaFrequency"); | 
					
						
							|  |  |  |     m_settingsKeys.append("iqOrder"); | 
					
						
							|  |  |  |     m_settingsKeys.append("centerFrequency"); | 
					
						
							| 
									
										
										
										
											2018-04-17 00:25:19 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-09 01:34:51 +02:00
										 |  |  | void LimeSDRInputGUI::on_sampleRateMode_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_sampleRateMode = checked; | 
					
						
							|  |  |  |     displaySampleRate(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  | void LimeSDRInputGUI::openDeviceSettingsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |     if (m_contextMenuType == ContextMenuDeviceSettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         BasicDeviceSettingsDialog dialog(this); | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:46 +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); | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +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-04-17 00:25:19 +02: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-12-06 10:09:46 +00:00
										 |  |  |         m_settings.m_replayLength = dialog.getReplayLength(); | 
					
						
							|  |  |  |         m_settings.m_replayStep = dialog.getReplayStep(); | 
					
						
							|  |  |  |         displayReplayLength(); | 
					
						
							|  |  |  |         displayReplayOffset(); | 
					
						
							|  |  |  |         displayReplayStep(); | 
					
						
							| 
									
										
										
										
											2022-10-23 23:13:55 +02:00
										 |  |  |         m_settingsKeys.append("useReverseAPI"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIAddress"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIPort"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIDeviceIndex"); | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:46 +00:00
										 |  |  |         m_settingsKeys.append("replayLength"); | 
					
						
							|  |  |  |         m_settingsKeys.append("replayStep"); | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-17 01:31:50 +02:00
										 |  |  |         sendSettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resetContextMenuType(); | 
					
						
							| 
									
										
										
										
											2018-12-18 23:37:26 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:46 +00:00
										 |  |  | void LimeSDRInputGUI::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 LimeSDRInputGUI::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 LimeSDRInputGUI::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 LimeSDRInputGUI::on_replayOffset_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_replayOffset = value / 10.0f; | 
					
						
							|  |  |  |     displayReplayOffset(); | 
					
						
							|  |  |  |     m_settingsKeys.append("replayOffset"); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_replayNow_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_replayPlus_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(ui->replayOffset->value() + m_settings.m_replayStep * 10); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_replayMinus_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(ui->replayOffset->value() - m_settings.m_replayStep * 10); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::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) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LimeSDRInput::MsgSaveReplay *message = LimeSDRInput::MsgSaveReplay::create(fileNames[0]); | 
					
						
							|  |  |  |             m_limeSDRInput->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_replayLoop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_replayLoop = checked; | 
					
						
							|  |  |  |     m_settingsKeys.append("replayLoop"); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setReplayTime(float time) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->replayOffset->setValue(std::ceil(time * 10.0f)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | void LimeSDRInputGUI::makeUIConnections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_startStop_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &LimeSDRInputGUI::on_centerFrequency_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->ncoFrequency, &ValueDialZ::changed, this, &LimeSDRInputGUI::on_ncoFrequency_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->ncoEnable, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_ncoEnable_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->dcOffset, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_dcOffset_toggled); | 
					
						
							| 
									
										
										
										
											2025-03-27 01:20:53 +01:00
										 |  |  |     QObject::connect(ui->splitFreq, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_splitFreq_toggled); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  |     QObject::connect(ui->iqImbalance, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_iqImbalance_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->sampleRate, &ValueDial::changed, this, &LimeSDRInputGUI::on_sampleRate_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->hwDecim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LimeSDRInputGUI::on_hwDecim_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->swDecim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LimeSDRInputGUI::on_swDecim_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->lpf, &ValueDial::changed, this, &LimeSDRInputGUI::on_lpf_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIREnable, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_lpFIREnable_toggled); | 
					
						
							|  |  |  |     QObject::connect(ui->lpFIR, &ValueDial::changed, this, &LimeSDRInputGUI::on_lpFIR_changed); | 
					
						
							|  |  |  |     QObject::connect(ui->gainMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LimeSDRInputGUI::on_gainMode_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->gain, &QDial::valueChanged, this, &LimeSDRInputGUI::on_gain_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->lnaGain, &QDial::valueChanged, this, &LimeSDRInputGUI::on_lnaGain_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->tiaGain, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LimeSDRInputGUI::on_tiaGain_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->pgaGain, &QDial::valueChanged, this, &LimeSDRInputGUI::on_pgaGain_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->antenna, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LimeSDRInputGUI::on_antenna_currentIndexChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->extClock, &ExternalClockButton::clicked, this, &LimeSDRInputGUI::on_extClock_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->transverter, &TransverterButton::clicked, this, &LimeSDRInputGUI::on_transverter_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->sampleRateMode, &QToolButton::toggled, this, &LimeSDRInputGUI::on_sampleRateMode_toggled); | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:46 +00:00
										 |  |  |     QObject::connect(ui->replayOffset, &QSlider::valueChanged, this, &LimeSDRInputGUI::on_replayOffset_valueChanged); | 
					
						
							|  |  |  |     QObject::connect(ui->replayNow, &QToolButton::clicked, this, &LimeSDRInputGUI::on_replayNow_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayPlus, &QToolButton::clicked, this, &LimeSDRInputGUI::on_replayPlus_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayMinus, &QToolButton::clicked, this, &LimeSDRInputGUI::on_replayMinus_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replaySave, &QToolButton::clicked, this, &LimeSDRInputGUI::on_replaySave_clicked); | 
					
						
							|  |  |  |     QObject::connect(ui->replayLoop, &ButtonSwitch::toggled, this, &LimeSDRInputGUI::on_replayLoop_toggled); | 
					
						
							| 
									
										
										
										
											2022-04-07 16:32:03 +02:00
										 |  |  | } |