2015-06-07 11:56:19 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 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 //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2015-06-07 11:56:19 -04: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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-08-09 04:33:04 -04:00
|
|
|
#include <QDebug>
|
2016-05-11 17:35:16 -04:00
|
|
|
#include <QMessageBox>
|
2020-04-01 17:17:26 -04:00
|
|
|
#include <QFileDialog>
|
2022-04-21 01:53:36 -04:00
|
|
|
#include <QResizeEvent>
|
2016-05-11 17:35:16 -04:00
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
#include <libbladeRF.h>
|
|
|
|
|
2018-09-19 00:27:40 -04:00
|
|
|
#include "ui_bladerf1inputgui.h"
|
2015-07-19 13:39:16 -04:00
|
|
|
#include "gui/colormapper.h"
|
2016-05-12 04:31:57 -04:00
|
|
|
#include "gui/glspectrum.h"
|
2018-12-25 15:05:24 -05:00
|
|
|
#include "gui/basicdevicesettingsdialog.h"
|
2015-08-17 02:29:34 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2016-05-12 04:31:57 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2017-10-29 19:02:28 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2018-09-24 18:38:38 -04:00
|
|
|
#include "bladerf1inputgui.h"
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
Bladerf1InputGui::Bladerf1InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI(parent),
|
2018-09-19 00:27:40 -04:00
|
|
|
ui(new Ui::Bladerf1InputGui),
|
2017-10-29 19:02:28 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2017-10-14 00:36:29 -04:00
|
|
|
m_forceSettings(true),
|
2017-11-05 20:34:46 -05:00
|
|
|
m_doApplySettings(true),
|
2015-06-06 21:30:28 -04:00
|
|
|
m_settings(),
|
2019-04-11 17:07:44 -04:00
|
|
|
m_sampleRateMode(true),
|
2016-05-11 17:35:16 -04:00
|
|
|
m_sampleSource(NULL),
|
2016-05-12 04:31:57 -04:00
|
|
|
m_sampleRate(0),
|
2019-05-08 16:11:53 -04:00
|
|
|
m_lastEngineState(DeviceAPI::StNotStarted)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_sampleSource = (Bladerf1Input*) m_deviceUISet->m_deviceAPI->getSampleSource();
|
2017-04-13 14:32:10 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
ui->setupUi(getContents());
|
2022-04-21 01:53:36 -04:00
|
|
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2022-04-23 20:13:18 -04:00
|
|
|
getContents()->setStyleSheet("#Bladerf1InputGui { background-color: rgb(64, 64, 64); }");
|
2022-04-07 10:32:03 -04:00
|
|
|
m_helpURL = "plugins/samplesource/bladerf1input/readme.md";
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2015-06-09 02:18:32 -04:00
|
|
|
ui->centerFrequency->setValueRange(7, BLADERF_FREQUENCY_MIN_XB200/1000, BLADERF_FREQUENCY_MAX/1000);
|
2016-03-29 11:31:44 -04:00
|
|
|
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
2017-04-01 21:24:11 -04:00
|
|
|
// BladeRF can go as low as 80 kS/s but because of buffering in practice experience is not good below 330 kS/s
|
|
|
|
ui->sampleRate->setValueRange(8, 330000U, BLADERF_SAMPLERATE_REC_MAX);
|
2016-03-29 11:31:44 -04:00
|
|
|
|
|
|
|
ui->bandwidth->clear();
|
2017-05-25 14:13:34 -04:00
|
|
|
for (unsigned int i = 0; i < BladerfBandwidths::getNbBandwidths(); i++)
|
2016-03-29 11:31:44 -04:00
|
|
|
{
|
|
|
|
ui->bandwidth->addItem(QString::number(BladerfBandwidths::getBandwidth(i)));
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
2016-05-11 17:35:16 -04:00
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(500);
|
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
2018-12-25 15:05:24 -05:00
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
displaySettings();
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
2018-05-25 13:28:57 -04:00
|
|
|
m_sampleSource->setMessageQueueToGUI(&m_inputMessageQueue);
|
2017-11-05 20:12:44 -05:00
|
|
|
|
|
|
|
sendSettings();
|
2022-04-07 10:32:03 -04:00
|
|
|
makeUIConnections();
|
2015-06-06 21:30:28 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
Bladerf1InputGui::~Bladerf1InputGui()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::destroy()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::resetToDefaults()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
QByteArray Bladerf1InputGui::serialize() const
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
bool Bladerf1InputGui::deserialize(const QByteArray& data)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
2017-10-14 00:36:29 -04:00
|
|
|
m_forceSettings = true;
|
2015-06-06 21:30:28 -04:00
|
|
|
sendSettings();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 01:53:36 -04:00
|
|
|
void Bladerf1InputGui::resizeEvent(QResizeEvent* size)
|
|
|
|
{
|
|
|
|
adjustSize();
|
|
|
|
size->accept();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
bool Bladerf1InputGui::handleMessage(const Message& message)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2018-09-19 02:56:39 -04:00
|
|
|
if (Bladerf1Input::MsgConfigureBladerf1::match(message))
|
2017-12-27 21:21:48 -05:00
|
|
|
{
|
2018-09-19 02:56:39 -04:00
|
|
|
const Bladerf1Input::MsgConfigureBladerf1& cfg = (Bladerf1Input::MsgConfigureBladerf1&) message;
|
2017-12-27 21:21:48 -05:00
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-19 02:56:39 -04:00
|
|
|
else if (Bladerf1Input::MsgStartStop::match(message))
|
2017-12-13 18:19:59 -05:00
|
|
|
{
|
2018-09-19 02:56:39 -04:00
|
|
|
Bladerf1Input::MsgStartStop& notif = (Bladerf1Input::MsgStartStop&) message;
|
2017-12-13 18:19:59 -05:00
|
|
|
blockApplySettings(true);
|
|
|
|
ui->startStop->setChecked(notif.getStartStop());
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-06 21:30:28 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::handleInputMessages()
|
2016-05-12 04:31:57 -04:00
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
2016-05-12 04:31:57 -04:00
|
|
|
{
|
2017-09-16 19:23:54 -04:00
|
|
|
qDebug("BladerfGui::handleInputMessages: message: %s", message->getIdentifier());
|
2016-05-12 04:31:57 -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("BladerfGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
2016-05-12 04:31:57 -04:00
|
|
|
updateSampleRateAndFrequency();
|
|
|
|
|
|
|
|
delete message;
|
|
|
|
}
|
2017-12-13 18:19:59 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
2016-05-12 04:31:57 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::updateSampleRateAndFrequency()
|
2016-05-12 04:31:57 -04:00
|
|
|
{
|
2017-10-29 19:02:28 -04:00
|
|
|
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
|
|
|
|
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
2019-04-11 17:07:44 -04:00
|
|
|
displaySampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bladerf1InputGui::displaySampleRate()
|
|
|
|
{
|
|
|
|
ui->sampleRate->blockSignals(true);
|
|
|
|
displayFcTooltip();
|
|
|
|
|
|
|
|
if (m_sampleRateMode)
|
|
|
|
{
|
|
|
|
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }");
|
|
|
|
ui->sampleRateMode->setText("SR");
|
|
|
|
// BladeRF can go as low as 80 kS/s but because of buffering in practice experience is not good below 330 kS/s
|
|
|
|
ui->sampleRate->setValueRange(8, 330000U, BLADERF_SAMPLERATE_REC_MAX);
|
|
|
|
ui->sampleRate->setValue(m_settings.m_devSampleRate);
|
|
|
|
ui->sampleRate->setToolTip("Device to host sample rate (S/s)");
|
|
|
|
ui->deviceRateText->setToolTip("Baseband sample rate (S/s)");
|
|
|
|
uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(50,50,50); }");
|
|
|
|
ui->sampleRateMode->setText("BB");
|
|
|
|
// BladeRF can go as low as 80 kS/s but because of buffering in practice experience is not good below 330 kS/s
|
|
|
|
ui->sampleRate->setValueRange(8, 330000U/(1<<m_settings.m_log2Decim), BLADERF_SAMPLERATE_REC_MAX/(1<<m_settings.m_log2Decim));
|
|
|
|
ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim));
|
|
|
|
ui->sampleRate->setToolTip("Baseband sample rate (S/s)");
|
|
|
|
ui->deviceRateText->setToolTip("Device to host sample rate (S/s)");
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5)));
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->sampleRate->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bladerf1InputGui::displayFcTooltip()
|
|
|
|
{
|
|
|
|
int32_t fShift = DeviceSampleSource::calculateFrequencyShift(
|
|
|
|
m_settings.m_log2Decim,
|
|
|
|
(DeviceSampleSource::fcPos_t) m_settings.m_fcPos,
|
|
|
|
m_settings.m_devSampleRate,
|
|
|
|
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD
|
|
|
|
);
|
|
|
|
ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5)));
|
2016-05-12 04:31:57 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::displaySettings()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2017-11-05 20:34:46 -05:00
|
|
|
blockApplySettings(true);
|
|
|
|
|
|
|
|
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
2019-04-11 17:07:44 -04:00
|
|
|
displaySampleRate();
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2015-09-30 21:18:20 -04:00
|
|
|
ui->dcOffset->setChecked(m_settings.m_dcBlock);
|
|
|
|
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
unsigned int bandwidthIndex = BladerfBandwidths::getBandwidthIndex(m_settings.m_bandwidth);
|
2016-03-29 11:31:44 -04:00
|
|
|
ui->bandwidth->setCurrentIndex(bandwidthIndex);
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2016-03-29 11:31:44 -04:00
|
|
|
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2015-07-01 19:00:27 -04:00
|
|
|
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
|
|
|
|
|
2016-03-29 11:31:44 -04:00
|
|
|
ui->lna->setCurrentIndex(m_settings.m_lnaGain);
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2015-07-26 14:44:05 -04:00
|
|
|
ui->vga1Text->setText(tr("%1dB").arg(m_settings.m_vga1));
|
2015-06-06 21:30:28 -04:00
|
|
|
ui->vga1->setValue(m_settings.m_vga1);
|
|
|
|
|
2015-07-28 17:54:17 -04:00
|
|
|
ui->vga2Text->setText(tr("%1dB").arg(m_settings.m_vga2));
|
2015-06-06 21:30:28 -04:00
|
|
|
ui->vga2->setValue(m_settings.m_vga2);
|
|
|
|
|
|
|
|
ui->xb200->setCurrentIndex(getXb200Index(m_settings.m_xb200, m_settings.m_xb200Path, m_settings.m_xb200Filter));
|
2017-11-05 20:34:46 -05:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
2015-06-06 21:30:28 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::sendSettings()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive())
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_centerFrequency_changed(quint64 value)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
m_settings.m_centerFrequency = value * 1000;
|
2015-06-06 21:30:28 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_sampleRate_changed(quint64 value)
|
2017-04-01 21:24:11 -04:00
|
|
|
{
|
2019-04-11 17:07:44 -04:00
|
|
|
if (m_sampleRateMode) {
|
|
|
|
m_settings.m_devSampleRate = value;
|
|
|
|
} else {
|
|
|
|
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
|
|
|
|
displayFcTooltip();
|
2017-04-01 21:24:11 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_dcOffset_toggled(bool checked)
|
2015-09-30 21:18:20 -04:00
|
|
|
{
|
|
|
|
m_settings.m_dcBlock = checked;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_iqImbalance_toggled(bool checked)
|
2015-09-30 21:18:20 -04:00
|
|
|
{
|
|
|
|
m_settings.m_iqCorrection = checked;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_bandwidth_currentIndexChanged(int index)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2016-03-29 11:31:44 -04:00
|
|
|
int newbw = BladerfBandwidths::getBandwidth(index);
|
2015-06-06 21:30:28 -04:00
|
|
|
m_settings.m_bandwidth = newbw * 1000;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_decim_currentIndexChanged(int index)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2019-04-11 17:07:44 -04:00
|
|
|
if ((index <0) || (index > 6)) {
|
2015-06-06 21:30:28 -04:00
|
|
|
return;
|
2019-04-11 17:07:44 -04:00
|
|
|
}
|
|
|
|
|
2016-03-29 11:31:44 -04:00
|
|
|
m_settings.m_log2Decim = index;
|
2019-04-11 17:07:44 -04:00
|
|
|
displaySampleRate();
|
|
|
|
|
|
|
|
if (m_sampleRateMode) {
|
|
|
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
|
|
|
} else {
|
|
|
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_fcPos_currentIndexChanged(int index)
|
2015-07-01 19:00:27 -04:00
|
|
|
{
|
2019-04-11 17:07:44 -04:00
|
|
|
m_settings.m_fcPos = (BladeRF1InputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
|
|
|
|
displayFcTooltip();
|
|
|
|
sendSettings();
|
2015-07-01 19:00:27 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_lna_currentIndexChanged(int index)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2016-03-29 11:31:44 -04:00
|
|
|
qDebug() << "BladerfGui: LNA gain = " << index * 3 << " dB";
|
2015-06-06 21:30:28 -04:00
|
|
|
|
2016-03-29 11:31:44 -04:00
|
|
|
if ((index < 0) || (index > 2))
|
2015-06-06 21:30:28 -04:00
|
|
|
return;
|
|
|
|
|
2016-03-29 11:31:44 -04:00
|
|
|
m_settings.m_lnaGain = index;
|
2015-06-06 21:30:28 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_vga1_valueChanged(int value)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if ((value < BLADERF_RXVGA1_GAIN_MIN) || (value > BLADERF_RXVGA1_GAIN_MAX))
|
|
|
|
return;
|
|
|
|
|
2015-07-26 14:44:05 -04:00
|
|
|
ui->vga1Text->setText(tr("%1dB").arg(value));
|
2015-06-06 21:30:28 -04:00
|
|
|
m_settings.m_vga1 = value;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_vga2_valueChanged(int value)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if ((value < BLADERF_RXVGA2_GAIN_MIN) || (value > BLADERF_RXVGA2_GAIN_MAX))
|
|
|
|
return;
|
|
|
|
|
2015-07-26 14:44:05 -04:00
|
|
|
ui->vga2Text->setText(tr("%1dB").arg(value));
|
2015-06-06 21:30:28 -04:00
|
|
|
m_settings.m_vga2 = value;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_xb200_currentIndexChanged(int index)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if (index == 1) // bypass
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_BYPASS;
|
|
|
|
}
|
|
|
|
else if (index == 2) // Auto 1dB
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_AUTO_1DB;
|
|
|
|
}
|
|
|
|
else if (index == 3) // Auto 3dB
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_AUTO_3DB;
|
|
|
|
}
|
|
|
|
else if (index == 4) // Custom
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_CUSTOM;
|
|
|
|
}
|
|
|
|
else if (index == 5) // 50 MHz
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_50M;
|
|
|
|
}
|
|
|
|
else if (index == 6) // 144 MHz
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_144M;
|
|
|
|
}
|
|
|
|
else if (index == 7) // 222 MHz
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = true;
|
|
|
|
m_settings.m_xb200Path = BLADERF_XB200_MIX;
|
|
|
|
m_settings.m_xb200Filter = BLADERF_XB200_222M;
|
|
|
|
}
|
|
|
|
else // no xb200
|
|
|
|
{
|
|
|
|
m_settings.m_xb200 = false;
|
|
|
|
}
|
|
|
|
|
2015-06-07 17:07:19 -04:00
|
|
|
if (m_settings.m_xb200)
|
|
|
|
{
|
|
|
|
ui->centerFrequency->setValueRange(7, BLADERF_FREQUENCY_MIN_XB200/1000, BLADERF_FREQUENCY_MAX/1000);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->centerFrequency->setValueRange(7, BLADERF_FREQUENCY_MIN/1000, BLADERF_FREQUENCY_MAX/1000);
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::on_startStop_toggled(bool checked)
|
2016-05-11 17:35:16 -04:00
|
|
|
{
|
2017-12-13 18:19:59 -05:00
|
|
|
if (m_doApplySettings)
|
2016-05-11 17:35:16 -04:00
|
|
|
{
|
2018-09-19 02:56:39 -04:00
|
|
|
Bladerf1Input::MsgStartStop *message = Bladerf1Input::MsgStartStop::create(checked);
|
2017-12-13 18:19:59 -05:00
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
2016-05-11 17:35:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 17:07:44 -04:00
|
|
|
void Bladerf1InputGui::on_sampleRateMode_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_sampleRateMode = checked;
|
|
|
|
displaySampleRate();
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::updateHardware()
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
2017-11-05 20:34:46 -05:00
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
qDebug() << "BladerfGui::updateHardware";
|
2018-09-19 02:56:39 -04:00
|
|
|
Bladerf1Input::MsgConfigureBladerf1* message = Bladerf1Input::MsgConfigureBladerf1::create(m_settings, m_forceSettings);
|
2017-11-05 20:34:46 -05:00
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
|
|
|
m_forceSettings = false;
|
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::blockApplySettings(bool block)
|
2017-11-05 20:34:46 -05:00
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
2015-06-06 21:30:28 -04:00
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
void Bladerf1InputGui::updateStatus()
|
2016-05-11 17:35:16 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
int state = m_deviceUISet->m_deviceAPI->state();
|
2016-05-11 17:35:16 -04:00
|
|
|
|
|
|
|
if(m_lastEngineState != state)
|
|
|
|
{
|
|
|
|
switch(state)
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StNotStarted:
|
2016-05-11 17:35:16 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StIdle:
|
2016-05-11 17:35:16 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StRunning:
|
2016-05-11 17:35:16 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StError:
|
2016-05-11 17:35:16 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
2019-05-08 16:11:53 -04:00
|
|
|
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
|
2016-05-11 17:35:16 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastEngineState = state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 02:56:39 -04:00
|
|
|
unsigned int Bladerf1InputGui::getXb200Index(bool xb_200, bladerf_xb200_path xb200Path, bladerf_xb200_filter xb200Filter)
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
if (xb_200)
|
|
|
|
{
|
|
|
|
if (xb200Path == BLADERF_XB200_BYPASS)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (xb200Filter == BLADERF_XB200_AUTO_1DB)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else if (xb200Filter == BLADERF_XB200_AUTO_3DB)
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
else if (xb200Filter == BLADERF_XB200_CUSTOM)
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
else if (xb200Filter == BLADERF_XB200_50M)
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
else if (xb200Filter == BLADERF_XB200_144M)
|
|
|
|
{
|
|
|
|
return 6;
|
|
|
|
}
|
2018-11-18 03:39:22 -05:00
|
|
|
else // xb200Filter == BLADERF_XB200_222M
|
2015-06-06 21:30:28 -04:00
|
|
|
{
|
|
|
|
return 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-25 15:05:24 -05:00
|
|
|
void Bladerf1InputGui::openDeviceSettingsDialog(const QPoint& p)
|
|
|
|
{
|
2022-04-16 19:31:50 -04:00
|
|
|
if (m_contextMenuType == ContextMenuDeviceSettings)
|
|
|
|
{
|
|
|
|
BasicDeviceSettingsDialog dialog(this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
2018-12-25 15:05:24 -05:00
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2018-12-25 15:05:24 -05:00
|
|
|
|
2022-04-16 19:31:50 -04: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();
|
2018-12-25 15:05:24 -05:00
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
2018-12-25 15:05:24 -05:00
|
|
|
}
|
2022-04-07 10:32:03 -04:00
|
|
|
|
|
|
|
void Bladerf1InputGui::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &Bladerf1InputGui::on_centerFrequency_changed);
|
|
|
|
QObject::connect(ui->sampleRate, &ValueDial::changed, this, &Bladerf1InputGui::on_sampleRate_changed);
|
|
|
|
QObject::connect(ui->dcOffset, &ButtonSwitch::toggled, this, &Bladerf1InputGui::on_dcOffset_toggled);
|
|
|
|
QObject::connect(ui->iqImbalance, &ButtonSwitch::toggled, this, &Bladerf1InputGui::on_iqImbalance_toggled);
|
|
|
|
QObject::connect(ui->bandwidth, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Bladerf1InputGui::on_bandwidth_currentIndexChanged);
|
|
|
|
QObject::connect(ui->decim, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Bladerf1InputGui::on_decim_currentIndexChanged);
|
|
|
|
QObject::connect(ui->lna, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Bladerf1InputGui::on_lna_currentIndexChanged);
|
|
|
|
QObject::connect(ui->fcPos, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Bladerf1InputGui::on_fcPos_currentIndexChanged);
|
|
|
|
QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &Bladerf1InputGui::on_startStop_toggled);
|
|
|
|
QObject::connect(ui->sampleRateMode, &QToolButton::toggled, this, &Bladerf1InputGui::on_sampleRateMode_toggled);
|
|
|
|
}
|