| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2017 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ui_limesdrinputgui.h"
 | 
					
						
							|  |  |  | #include "gui/colormapper.h"
 | 
					
						
							|  |  |  | #include "gui/glspectrum.h"
 | 
					
						
							|  |  |  | #include "dsp/dspengine.h"
 | 
					
						
							|  |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							|  |  |  | #include "device/devicesourceapi.h"
 | 
					
						
							|  |  |  | #include "dsp/filerecord.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) : | 
					
						
							|  |  |  |     QWidget(parent), | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     ui(new Ui::LimeSDRInputGUI), | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     m_deviceAPI(deviceAPI), | 
					
						
							|  |  |  |     m_settings(), | 
					
						
							|  |  |  |     m_sampleSource(0), | 
					
						
							|  |  |  |     m_sampleRate(0), | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |     m_lastEngineState((DSPDeviceSourceEngine::State)-1), | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |     m_doApplySettings(true), | 
					
						
							|  |  |  |     m_statusCounter(0) | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_limeSDRInput = new LimeSDRInput(m_deviceAPI); | 
					
						
							|  |  |  |     m_sampleSource = (DeviceSampleSource *) m_limeSDRInput; | 
					
						
							|  |  |  |     m_deviceAPI->setSource(m_sampleSource); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->setupUi(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     float minF, maxF, stepF; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_limeSDRInput->getLORange(minF, maxF, stepF); | 
					
						
							| 
									
										
										
										
											2017-05-16 17:48:12 +02:00
										 |  |  |     ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  |     ui->centerFrequency->setValueRange(7, ((uint32_t) minF)/1000, ((uint32_t) maxF)/1000); // frequency dial is in kHz
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_limeSDRInput->getSRRange(minF, maxF, stepF); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_limeSDRInput->getLPRange(minF, maxF, stepF); | 
					
						
							| 
									
										
										
										
											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())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |     ui->hwDecimLabel->setText(QString::fromUtf8("H\u2193")); | 
					
						
							|  |  |  |     ui->swDecimLabel->setText(QString::fromUtf8("S\u2193")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     char recFileNameCStr[30]; | 
					
						
							|  |  |  |     sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); | 
					
						
							|  |  |  |     m_fileSink = new FileRecord(std::string(recFileNameCStr)); | 
					
						
							|  |  |  |     m_deviceAPI->addSink(m_fileSink); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 19:30:46 +02:00
										 |  |  |     connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleMessagesToGUI()), Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2017-04-15 11:45:01 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LimeSDRInputGUI::~LimeSDRInputGUI() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_deviceAPI->removeSink(m_fileSink); | 
					
						
							|  |  |  |     delete m_fileSink; | 
					
						
							|  |  |  |     delete m_sampleSource; // Valgrind memcheck
 | 
					
						
							|  |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | void LimeSDRInputGUI::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setName(const QString& name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setObjectName(name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString LimeSDRInputGUI::getName() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return objectName(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.resetToDefaults(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | qint64 LimeSDRInputGUI::getCenterFrequency() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.m_centerFrequency; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::setCenterFrequency(qint64 centerFrequency) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_centerFrequency = centerFrequency; | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  |     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(); | 
					
						
							|  |  |  |         sendSettings(); | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | bool LimeSDRInputGUI::handleMessage(const Message& message) // TODO: does not seem to be really useful in any of the source (+sink?) plugins
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 19:30:46 +02:00
										 |  |  | void LimeSDRInputGUI::handleMessagesToGUI() | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ((message = m_deviceAPI->getDeviceOutputMessageQueue()->pop()) != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-20 00:48:00 +02:00
										 |  |  |             qDebug("LimeSDRInputGUI::handleMessagesToGUI: message: %s", message->getIdentifier()); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_sampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-04-19 00:00:47 +02:00
										 |  |  |             qDebug("LimeSDRInputGUI::handleMessagesToGUI: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |             updateSampleRateAndFrequency(); | 
					
						
							|  |  |  |             m_fileSink->handleMessage(*notif); // forward to file sink
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (LimeSDRInput::MsgReportLimeSDRToGUI::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-04-20 00:48:00 +02:00
										 |  |  |             qDebug("LimeSDRInputGUI::handleMessagesToGUI: message: %s", message->getIdentifier()); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |             LimeSDRInput::MsgReportLimeSDRToGUI *report = (LimeSDRInput::MsgReportLimeSDRToGUI *) message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |             m_settings.m_centerFrequency = report->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |             m_settings.m_devSampleRate = report->getSampleRate(); | 
					
						
							|  |  |  |             m_settings.m_log2HardDecim = report->getLog2HardDecim(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             blockApplySettings(true); | 
					
						
							|  |  |  |             displaySettings(); | 
					
						
							|  |  |  |             blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 01:04:57 +02:00
										 |  |  |             LimeSDRInput::MsgSetReferenceConfig* conf = LimeSDRInput::MsgSetReferenceConfig::create(m_settings); | 
					
						
							|  |  |  |             m_sampleSource->getInputMessageQueue()->push(conf); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-23 03:36:10 +02:00
										 |  |  |         else if (DeviceLimeSDRShared::MsgCrossReportToGUI::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DeviceLimeSDRShared::MsgCrossReportToGUI *report = (DeviceLimeSDRShared::MsgCrossReportToGUI *) message; | 
					
						
							|  |  |  |             m_settings.m_devSampleRate = report->getSampleRate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             blockApplySettings(true); | 
					
						
							|  |  |  |             displaySettings(); | 
					
						
							|  |  |  |             blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             LimeSDRInput::MsgSetReferenceConfig* conf = LimeSDRInput::MsgSetReferenceConfig::create(m_settings); | 
					
						
							|  |  |  |             m_sampleSource->getInputMessageQueue()->push(conf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |         else if (LimeSDRInput::MsgReportStreamInfo::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LimeSDRInput::MsgReportStreamInfo *report = (LimeSDRInput::MsgReportStreamInfo *) message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (report->getSuccess()) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-19 22:43:18 +02:00
										 |  |  |                 ui->streamStatusLabel->setStyleSheet("QLabel { background-color : green; }"); | 
					
						
							|  |  |  |                 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); }"); | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2017-04-19 22:43:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (report->getDroppedPackets() > 0) { | 
					
						
							|  |  |  |                     ui->droppedLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     ui->droppedLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 22:43:18 +02:00
										 |  |  |                 ui->fifoBar->setMaximum(report->getFifoSize()); | 
					
						
							|  |  |  |                 ui->fifoBar->setValue(report->getFifoFilledCount()); | 
					
						
							| 
									
										
										
										
											2017-04-24 03:12:02 +02:00
										 |  |  |                 ui->fifoBar->setToolTip(tr("FIFO fill %1/%2 samples").arg(QString::number(report->getFifoFilledCount())).arg(QString::number(report->getFifoSize()))); | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-04-19 22:43:18 +02:00
										 |  |  |                 ui->streamStatusLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							| 
									
										
										
										
											2017-04-19 18:41:55 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_deviceAPI->getSpectrum()->setSampleRate(m_sampleRate); | 
					
						
							|  |  |  |     m_deviceAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							|  |  |  |     ui->deviceRateLabel->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); | 
					
						
							|  |  |  |     ui->sampleRate->setValue(m_settings.m_devSampleRate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->dcOffset->setChecked(m_settings.m_dcBlock); | 
					
						
							|  |  |  |     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-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); | 
					
						
							|  |  |  |     ui->gainText->setText(tr("%1dB").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-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2017-05-12 03:31:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->ncoEnable->setChecked(m_settings.m_ncoEnable); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |     ui->ncoFrequency->setValueRange(7, | 
					
						
							|  |  |  |             (m_settings.m_centerFrequency - ncoHalfRange)/1000, | 
					
						
							|  |  |  |             (m_settings.m_centerFrequency + ncoHalfRange)/1000); // frequency dial is in kHz
 | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |     ui->ncoFrequency->setValue((m_settings.m_centerFrequency + m_settings.m_ncoFrequency)/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"; | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  |         LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings); | 
					
						
							|  |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         m_updateTimer.stop(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-16 04:58:52 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state = m_deviceAPI->state(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(m_lastEngineState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch(state) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             case DSPDeviceSourceEngine::StNotStarted: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DSPDeviceSourceEngine::StIdle: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DSPDeviceSourceEngine::StRunning: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case DSPDeviceSourceEngine::StError: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							|  |  |  |                 QMessageBox::information(this, tr("Message"), m_deviceAPI->errorMessage()); | 
					
						
							|  |  |  |                 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(); | 
					
						
							|  |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |         m_statusCounter = 0; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											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-04-17 10:05:05 +02:00
										 |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_deviceAPI->initAcquisition()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             m_deviceAPI->startAcquisition(); | 
					
						
							|  |  |  |             DSPEngine::instance()->startAudioOutput(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_deviceAPI->stopAcquisition(); | 
					
						
							|  |  |  |         DSPEngine::instance()->stopAudioOutput(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_record_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->record->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							|  |  |  |         m_fileSink->startRecording(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |         m_fileSink->stopRecording(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_centerFrequency = value * 1000; | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | void LimeSDRInputGUI::on_ncoFrequency_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |     m_settings.m_ncoFrequency = (int64_t) value - (int64_t) m_settings.m_centerFrequency/1000; | 
					
						
							|  |  |  |     m_settings.m_ncoFrequency *= 1000; | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_ncoEnable_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ncoEnable = checked; | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_ncoReset_clicked(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_ncoFrequency = 0; | 
					
						
							| 
									
										
										
										
											2017-04-20 20:18:50 +02:00
										 |  |  |     ui->ncoFrequency->setValue(m_settings.m_centerFrequency/1000); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |     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; | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_sampleRate_changed(quint64 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     m_settings.m_devSampleRate = value; | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings();} | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_hwDecim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     if ((index <0) || (index > 5)) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     m_settings.m_log2HardDecim = index; | 
					
						
							| 
									
										
										
										
											2017-04-20 23:02:06 +02:00
										 |  |  |     setNCODisplay(); | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |     sendSettings(); | 
					
						
							| 
									
										
										
										
											2017-04-17 01:10:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-05-08 17:30:08 +02:00
										 |  |  |     if ((index <0) || (index > 6)) | 
					
						
							| 
									
										
										
										
											2017-04-17 10:05:05 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     m_settings.m_log2SoftDecim = index; | 
					
						
							|  |  |  |     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; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |     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; | 
					
						
							| 
									
										
										
										
											2017-04-20 18:21:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.m_lpfFIREnable) { // do not send the update if the FIR is disabled
 | 
					
						
							|  |  |  |         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-04-18 02:01:30 +02:00
										 |  |  |     ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain)); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } |