2017-04-15 05:45:01 -04: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>
|
|
|
|
|
2017-08-04 03:33:25 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2017-04-15 05:45:01 -04:00
|
|
|
#include "ui_limesdrinputgui.h"
|
|
|
|
#include "gui/colormapper.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "device/devicesourceapi.h"
|
2017-10-29 19:02:28 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2017-04-15 05:45:01 -04:00
|
|
|
|
2017-10-29 19:45:23 -04:00
|
|
|
LimeSDRInputGUI::LimeSDRInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
2017-04-15 05:45:01 -04:00
|
|
|
QWidget(parent),
|
2017-04-15 22:58:52 -04:00
|
|
|
ui(new Ui::LimeSDRInputGUI),
|
2017-10-29 19:02:28 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2017-04-15 05:45:01 -04:00
|
|
|
m_settings(),
|
|
|
|
m_sampleRate(0),
|
2017-04-16 19:10:32 -04:00
|
|
|
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
|
2017-04-19 12:41:55 -04:00
|
|
|
m_doApplySettings(true),
|
2017-10-14 00:48:09 -04:00
|
|
|
m_forceSettings(true),
|
2017-07-03 07:42:11 -04:00
|
|
|
m_statusCounter(0),
|
|
|
|
m_deviceStatusCounter(0)
|
2017-04-15 05:45:01 -04:00
|
|
|
{
|
2017-10-29 19:45:23 -04:00
|
|
|
m_limeSDRInput = (LimeSDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
|
2017-04-15 05:45:01 -04:00
|
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
float minF, maxF;
|
2017-04-15 05:45:01 -04:00
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
m_limeSDRInput->getLORange(minF, maxF);
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2017-04-15 05:45:01 -04:00
|
|
|
ui->centerFrequency->setValueRange(7, ((uint32_t) minF)/1000, ((uint32_t) maxF)/1000); // frequency dial is in kHz
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
m_limeSDRInput->getSRRange(minF, maxF);
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
2017-04-15 05:45:01 -04:00
|
|
|
ui->sampleRate->setValueRange(8, (uint32_t) minF, (uint32_t) maxF);
|
|
|
|
|
2018-03-14 06:03:22 -04:00
|
|
|
m_limeSDRInput->getLPRange(minF, maxF);
|
2017-05-16 15:24:25 -04:00
|
|
|
ui->lpf->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
|
2017-04-17 19:16:39 -04:00
|
|
|
ui->lpf->setValueRange(6, (minF/1000)+1, maxF/1000);
|
2017-04-15 05:45:01 -04:00
|
|
|
|
2017-05-16 15:24:25 -04:00
|
|
|
ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
|
2017-04-17 18:50:03 -04:00
|
|
|
ui->lpFIR->setValueRange(5, 1U, 56000U);
|
|
|
|
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->ncoFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2017-04-20 12:21:01 -04:00
|
|
|
|
2017-04-15 22:58:52 -04:00
|
|
|
ui->channelNumberText->setText(tr("#%1").arg(m_limeSDRInput->getChannelIndex()));
|
|
|
|
|
2017-04-20 14:18:50 -04:00
|
|
|
ui->hwDecimLabel->setText(QString::fromUtf8("H\u2193"));
|
|
|
|
ui->swDecimLabel->setText(QString::fromUtf8("S\u2193"));
|
|
|
|
|
2017-04-15 05:45:01 -04:00
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(500);
|
|
|
|
|
|
|
|
displaySettings();
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
2017-04-15 05:45:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
LimeSDRInputGUI::~LimeSDRInputGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-04-15 22:58:52 -04: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-16 19:10:32 -04:00
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
{
|
2017-04-15 22:58:52 -04:00
|
|
|
displaySettings();
|
2017-10-14 00:48:09 -04:00
|
|
|
m_forceSettings = true;
|
2017-04-15 22:58:52 -04:00
|
|
|
sendSettings();
|
|
|
|
return true;
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-15 22:58:52 -04:00
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 11:35:03 -04:00
|
|
|
bool LimeSDRInputGUI::handleMessage(const Message& message)
|
2017-04-16 19:10:32 -04:00
|
|
|
{
|
2017-12-27 21:21:48 -05:00
|
|
|
if (LimeSDRInput::MsgConfigureLimeSDR::match(message))
|
|
|
|
{
|
|
|
|
const LimeSDRInput::MsgConfigureLimeSDR& cfg = (LimeSDRInput::MsgConfigureLimeSDR&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (DeviceLimeSDRShared::MsgReportBuddyChange::match(message))
|
2017-10-23 20:20:57 -04:00
|
|
|
{
|
2017-10-24 19:38:39 -04:00
|
|
|
DeviceLimeSDRShared::MsgReportBuddyChange& report = (DeviceLimeSDRShared::MsgReportBuddyChange&) message;
|
2017-10-23 20:20:57 -04:00
|
|
|
m_settings.m_devSampleRate = report.getDevSampleRate();
|
|
|
|
m_settings.m_log2HardDecim = report.getLog2HardDecimInterp();
|
|
|
|
|
2017-10-24 19:38:39 -04:00
|
|
|
if (report.getRxElseTx()) {
|
|
|
|
m_settings.m_centerFrequency = report.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
2017-10-23 20:20:57 -04:00
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
2017-09-17 11:35:03 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-05 04:16:36 -05: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;
|
|
|
|
}
|
2017-09-17 11:35:03 -04:00
|
|
|
else if (LimeSDRInput::MsgReportStreamInfo::match(message))
|
|
|
|
{
|
|
|
|
LimeSDRInput::MsgReportStreamInfo& report = (LimeSDRInput::MsgReportStreamInfo&) message;
|
|
|
|
|
|
|
|
if (report.getSuccess())
|
|
|
|
{
|
2017-10-26 18:22:58 -04:00
|
|
|
if (report.getActive()) {
|
|
|
|
ui->streamStatusLabel->setStyleSheet("QLabel { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->streamStatusLabel->setStyleSheet("QLabel { background-color : blue; }");
|
|
|
|
}
|
|
|
|
|
2017-09-17 11:35:03 -04: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)));
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-14 12:02:49 -05: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 11:35:03 -04:00
|
|
|
|
2017-12-14 12:02:49 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
void LimeSDRInputGUI::handleInputMessages()
|
2017-04-15 22:58:52 -04:00
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
2017-04-15 22:58:52 -04:00
|
|
|
{
|
|
|
|
if (DSPSignalNotification::match(*message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
|
|
|
m_sampleRate = notif->getSampleRate();
|
|
|
|
m_deviceCenterFrequency = notif->getCenterFrequency();
|
2017-09-16 19:23:54 -04:00
|
|
|
qDebug("LimeSDRInputGUI::handleInputMessages: DSPSignalNotification: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency());
|
2017-04-15 22:58:52 -04:00
|
|
|
updateSampleRateAndFrequency();
|
|
|
|
|
2017-04-16 19:10:32 -04:00
|
|
|
delete message;
|
|
|
|
}
|
2017-12-08 09:11:16 -05:00
|
|
|
else if (LimeSDRInput::MsgConfigureLimeSDR::match(*message))
|
|
|
|
{
|
|
|
|
const LimeSDRInput::MsgConfigureLimeSDR& cfg = (LimeSDRInput::MsgConfigureLimeSDR&) *message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
displaySettings();
|
|
|
|
|
|
|
|
delete message;
|
|
|
|
}
|
2017-09-17 11:35:03 -04:00
|
|
|
else
|
2017-04-16 19:10:32 -04:00
|
|
|
{
|
2017-09-17 11:35:03 -04:00
|
|
|
if (handleMessage(*message)) {
|
|
|
|
delete message;
|
2017-04-19 12:41:55 -04:00
|
|
|
}
|
2017-07-03 07:42:11 -04:00
|
|
|
}
|
2017-04-15 22:58:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-06 18:01:01 -04: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-15 22:58:52 -04:00
|
|
|
void LimeSDRInputGUI::updateSampleRateAndFrequency()
|
|
|
|
{
|
2017-10-29 19:02:28 -04:00
|
|
|
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
|
|
|
|
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
2017-04-15 22:58:52 -04:00
|
|
|
ui->deviceRateLabel->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::displaySettings()
|
|
|
|
{
|
2017-11-05 00:59:04 -04:00
|
|
|
ui->extClock->setExternalClockFrequency(m_settings.m_extClockFreq);
|
|
|
|
ui->extClock->setExternalClockActive(m_settings.m_extClock);
|
|
|
|
|
2018-03-14 01:30:45 -04:00
|
|
|
setCenterFrequencyDisplay();
|
2017-04-15 22:58:52 -04:00
|
|
|
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 05:45:01 -04:00
|
|
|
|
2017-07-06 18:01:01 -04:00
|
|
|
updateADCRate();
|
|
|
|
|
2017-04-17 19:16:39 -04:00
|
|
|
ui->lpf->setValue(m_settings.m_lpfBW / 1000);
|
2017-04-15 22:58:52 -04:00
|
|
|
|
|
|
|
ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable);
|
2017-04-17 18:50:03 -04:00
|
|
|
ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000);
|
2017-04-15 22:58:52 -04:00
|
|
|
|
|
|
|
ui->gain->setValue(m_settings.m_gain);
|
2017-07-04 17:48:24 -04:00
|
|
|
ui->gainText->setText(tr("%1").arg(m_settings.m_gain));
|
2017-04-20 12:21:01 -04:00
|
|
|
|
2017-05-06 19:47:31 -04:00
|
|
|
ui->antenna->setCurrentIndex((int) m_settings.m_antennaPath);
|
|
|
|
|
2017-07-04 17:48:24 -04: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 17:02:06 -04:00
|
|
|
setNCODisplay();
|
2017-05-11 21:31:42 -04:00
|
|
|
|
|
|
|
ui->ncoEnable->setChecked(m_settings.m_ncoEnable);
|
2017-04-20 17:02:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::setNCODisplay()
|
|
|
|
{
|
2017-04-20 12:21:01 -04:00
|
|
|
int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardDecim)))/2;
|
2018-03-14 01:30:45 -04:00
|
|
|
ui->ncoFrequency->setValueRange(
|
|
|
|
false,
|
|
|
|
8,
|
|
|
|
-ncoHalfRange,
|
2018-03-14 14:52:54 -04:00
|
|
|
ncoHalfRange);
|
2018-03-14 01:30:45 -04:00
|
|
|
|
|
|
|
ui->ncoFrequency->blockSignals(true);
|
2018-03-14 14:52:54 -04:00
|
|
|
ui->ncoFrequency->setToolTip(QString("NCO frequency shift in Hz (Range: +/- %1 kHz)").arg(ncoHalfRange/1000));
|
2018-03-14 01:30:45 -04: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-15 22:58:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::sendSettings()
|
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive())
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::updateHardware()
|
|
|
|
{
|
2017-04-16 19:10:32 -04:00
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2017-04-17 19:16:39 -04:00
|
|
|
qDebug() << "LimeSDRInputGUI::updateHardware";
|
2017-10-14 00:48:09 -04:00
|
|
|
LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings, m_forceSettings);
|
2017-09-17 19:11:15 -04:00
|
|
|
m_limeSDRInput->getInputMessageQueue()->push(message);
|
2017-10-14 00:48:09 -04:00
|
|
|
m_forceSettings = false;
|
2017-04-16 19:10:32 -04:00
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
2017-04-15 22:58:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::updateStatus()
|
|
|
|
{
|
2017-10-29 19:45:23 -04:00
|
|
|
int state = m_deviceUISet->m_deviceSourceAPI->state();
|
2017-04-15 22:58:52 -04:00
|
|
|
|
|
|
|
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; }");
|
2017-10-29 19:45:23 -04:00
|
|
|
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage());
|
2017-04-15 22:58:52 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastEngineState = state;
|
|
|
|
}
|
2017-04-19 12:41:55 -04:00
|
|
|
|
|
|
|
if (m_statusCounter < 1)
|
|
|
|
{
|
|
|
|
m_statusCounter++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LimeSDRInput::MsgGetStreamInfo* message = LimeSDRInput::MsgGetStreamInfo::create();
|
2017-09-17 19:11:15 -04:00
|
|
|
m_limeSDRInput->getInputMessageQueue()->push(message);
|
2017-04-19 12:41:55 -04:00
|
|
|
m_statusCounter = 0;
|
2017-07-03 07:42:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_deviceStatusCounter < 10)
|
|
|
|
{
|
|
|
|
m_deviceStatusCounter++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-29 19:45:23 -04:00
|
|
|
if (m_deviceUISet->m_deviceSourceAPI->isBuddyLeader())
|
2017-07-03 17:26:06 -04:00
|
|
|
{
|
|
|
|
LimeSDRInput::MsgGetDeviceInfo* message = LimeSDRInput::MsgGetDeviceInfo::create();
|
2017-09-17 19:11:15 -04:00
|
|
|
m_limeSDRInput->getInputMessageQueue()->push(message);
|
2017-07-03 17:26:06 -04:00
|
|
|
}
|
|
|
|
|
2017-07-03 07:42:11 -04:00
|
|
|
m_deviceStatusCounter = 0;
|
2017-04-19 12:41:55 -04:00
|
|
|
}
|
2017-04-15 22:58:52 -04:00
|
|
|
}
|
2017-04-15 05:45:01 -04:00
|
|
|
|
2017-04-16 19:10:32 -04:00
|
|
|
void LimeSDRInputGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_startStop_toggled(bool checked)
|
|
|
|
{
|
2017-12-14 12:02:49 -05:00
|
|
|
if (m_doApplySettings)
|
2017-04-17 04:05:05 -04:00
|
|
|
{
|
2017-12-14 12:02:49 -05:00
|
|
|
LimeSDRInput::MsgStartStop *message = LimeSDRInput::MsgStartStop::create(checked);
|
|
|
|
m_limeSDRInput->getInputMessageQueue()->push(message);
|
2017-04-17 04:05:05 -04:00
|
|
|
}
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_record_toggled(bool checked)
|
|
|
|
{
|
2017-09-04 18:00:33 -04:00
|
|
|
if (checked) {
|
2017-04-17 04:05:05 -04:00
|
|
|
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
2017-09-04 18:00:33 -04:00
|
|
|
} else {
|
2017-04-17 04:05:05 -04:00
|
|
|
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
2017-09-04 18:00:33 -04:00
|
|
|
|
|
|
|
LimeSDRInput::MsgFileRecord* message = LimeSDRInput::MsgFileRecord::create(checked);
|
2017-09-17 19:11:15 -04:00
|
|
|
m_limeSDRInput->getInputMessageQueue()->push(message);
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value)
|
|
|
|
{
|
2018-03-14 01:30:45 -04:00
|
|
|
setCenterFrequencySetting(value);
|
2017-04-17 04:05:05 -04:00
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
2018-03-14 01:30:45 -04:00
|
|
|
void LimeSDRInputGUI::on_ncoFrequency_changed(qint64 value)
|
2017-04-20 12:21:01 -04:00
|
|
|
{
|
2018-03-14 01:30:45 -04:00
|
|
|
m_settings.m_ncoFrequency = value;
|
|
|
|
setCenterFrequencyDisplay();
|
2017-04-20 12:21:01 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_ncoEnable_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_ncoEnable = checked;
|
2018-03-14 01:30:45 -04:00
|
|
|
setCenterFrequencyDisplay();
|
2017-04-20 12:21:01 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void LimeSDRInputGUI::on_ncoReset_clicked(bool checked __attribute__((unused)))
|
2017-04-20 12:21:01 -04:00
|
|
|
{
|
|
|
|
m_settings.m_ncoFrequency = 0;
|
2018-03-14 01:30:45 -04:00
|
|
|
ui->ncoFrequency->setValue(0);
|
2017-04-20 12:21:01 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2017-04-16 19:10:32 -04:00
|
|
|
void LimeSDRInputGUI::on_dcOffset_toggled(bool checked)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
m_settings.m_dcBlock = checked;
|
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_iqImbalance_toggled(bool checked)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
m_settings.m_iqCorrection = checked;
|
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_sampleRate_changed(quint64 value)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
m_settings.m_devSampleRate = value;
|
2017-07-06 18:01:01 -04:00
|
|
|
updateADCRate();
|
2017-04-20 17:02:06 -04:00
|
|
|
setNCODisplay();
|
2017-04-17 04:05:05 -04:00
|
|
|
sendSettings();}
|
2017-04-16 19:10:32 -04:00
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_hwDecim_currentIndexChanged(int index)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
if ((index <0) || (index > 5))
|
|
|
|
return;
|
|
|
|
m_settings.m_log2HardDecim = index;
|
2017-07-06 18:01:01 -04:00
|
|
|
updateADCRate();
|
2017-04-20 17:02:06 -04:00
|
|
|
setNCODisplay();
|
2017-04-17 04:05:05 -04:00
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index)
|
|
|
|
{
|
2017-05-08 11:30:08 -04:00
|
|
|
if ((index <0) || (index > 6))
|
2017-04-17 04:05:05 -04:00
|
|
|
return;
|
|
|
|
m_settings.m_log2SoftDecim = index;
|
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
2017-04-17 20:01:30 -04:00
|
|
|
void LimeSDRInputGUI::on_lpf_changed(quint64 value)
|
2017-04-16 19:10:32 -04:00
|
|
|
{
|
2017-04-17 19:16:39 -04:00
|
|
|
m_settings.m_lpfBW = value * 1000;
|
2017-04-17 04:05:05 -04:00
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_lpFIREnable_toggled(bool checked)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
m_settings.m_lpfFIREnable = checked;
|
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_lpFIR_changed(quint64 value)
|
|
|
|
{
|
2017-04-17 18:50:03 -04:00
|
|
|
m_settings.m_lpfFIRBW = value * 1000;
|
2017-04-20 12:21:01 -04:00
|
|
|
|
|
|
|
if (m_settings.m_lpfFIREnable) { // do not send the update if the FIR is disabled
|
|
|
|
sendSettings();
|
|
|
|
}
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
|
|
|
|
2017-07-04 17:48:24 -04: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2017-04-16 19:10:32 -04:00
|
|
|
void LimeSDRInputGUI::on_gain_valueChanged(int value)
|
|
|
|
{
|
2017-04-17 04:05:05 -04:00
|
|
|
m_settings.m_gain = value;
|
2017-07-04 17:48:24 -04:00
|
|
|
ui->gainText->setText(tr("%1").arg(m_settings.m_gain));
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_lnaGain_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_lnaGain = value;
|
|
|
|
ui->lnaGainText->setText(tr("%1").arg(m_settings.m_lnaGain));
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_tiaGain_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_tiaGain = index + 1;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_pgaGain_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_pgaGain = value;
|
|
|
|
ui->pgaGainText->setText(tr("%1").arg(m_settings.m_pgaGain));
|
2017-04-17 04:05:05 -04:00
|
|
|
sendSettings();
|
2017-04-16 19:10:32 -04:00
|
|
|
}
|
2017-04-23 10:23:01 -04:00
|
|
|
|
|
|
|
void LimeSDRInputGUI::on_antenna_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) index;
|
|
|
|
sendSettings();
|
|
|
|
}
|
2017-11-05 00:59:04 -04: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");
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|