From 66bfff90daec5f2ab0d60a727c50001c46071fe7 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 12 Apr 2019 00:18:29 +0200 Subject: [PATCH] BladeRF1 output: implemented baseband or device sample rate input option --- .../bladerf1output/bladerf1outputgui.cpp | 61 +++++++++++++++++-- .../bladerf1output/bladerf1outputgui.h | 3 + .../bladerf1output/bladerf1outputgui.ui | 29 ++++++--- 3 files changed, 81 insertions(+), 12 deletions(-) diff --git a/plugins/samplesink/bladerf1output/bladerf1outputgui.cpp b/plugins/samplesink/bladerf1output/bladerf1outputgui.cpp index 179167e55..8f674dbad 100644 --- a/plugins/samplesink/bladerf1output/bladerf1outputgui.cpp +++ b/plugins/samplesink/bladerf1output/bladerf1outputgui.cpp @@ -38,7 +38,8 @@ Bladerf1OutputGui::Bladerf1OutputGui(DeviceUISet *deviceUISet, QWidget* parent) m_doApplySettings(true), m_forceSettings(true), m_settings(), - m_deviceSampleSink(NULL), + m_sampleRateMode(true), + m_deviceSampleSink(nullptr), m_sampleRate(0), m_lastEngineState(DSPDeviceSinkEngine::StNotStarted) { @@ -189,13 +190,42 @@ void Bladerf1OutputGui::updateSampleRateAndFrequency() { m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); - ui->deviceRateLabel->setText(QString("%1k").arg(QString::number(m_sampleRate/1000.0, 'g', 5))); + displaySampleRate(); +} + +void Bladerf1OutputGui::displaySampleRate() +{ + ui->sampleRate->blockSignals(true); + + if (m_sampleRateMode) + { + ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }"); + ui->sampleRateMode->setText("SR"); + ui->sampleRate->setValueRange(8, BLADERF_SAMPLERATE_MIN, 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<deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5))); + } + else + { + ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(50,50,50); }"); + ui->sampleRateMode->setText("BB"); + ui->sampleRate->setValueRange(8, BLADERF_SAMPLERATE_MIN/(1<sampleRate->setValue(m_settings.m_devSampleRate/(1<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 Bladerf1OutputGui::displaySettings() { ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); - ui->sampleRate->setValue(m_settings.m_devSampleRate); + displaySampleRate(); unsigned int bandwidthIndex = BladerfBandwidths::getBandwidthIndex(m_settings.m_bandwidth); ui->bandwidth->setCurrentIndex(bandwidthIndex); @@ -225,7 +255,12 @@ void Bladerf1OutputGui::on_centerFrequency_changed(quint64 value) void Bladerf1OutputGui::on_sampleRate_changed(quint64 value) { - m_settings.m_devSampleRate = value; + if (m_sampleRateMode) { + m_settings.m_devSampleRate = value; + } else { + m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Interp); + } + sendSettings(); } @@ -238,9 +273,19 @@ void Bladerf1OutputGui::on_bandwidth_currentIndexChanged(int index) void Bladerf1OutputGui::on_interp_currentIndexChanged(int index) { - if ((index <0) || (index > 6)) + if ((index <0) || (index > 6)) { return; + } + m_settings.m_log2Interp = index; + displaySampleRate(); + + if (m_sampleRateMode) { + m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); + } else { + m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Interp); + } + sendSettings(); } @@ -333,6 +378,12 @@ void Bladerf1OutputGui::on_startStop_toggled(bool checked) } } +void Bladerf1OutputGui::on_sampleRateMode_toggled(bool checked) +{ + m_sampleRateMode = checked; + displaySampleRate(); +} + void Bladerf1OutputGui::updateHardware() { qDebug() << "BladerfGui::updateHardware"; diff --git a/plugins/samplesink/bladerf1output/bladerf1outputgui.h b/plugins/samplesink/bladerf1output/bladerf1outputgui.h index aee6641c0..0da480d8e 100644 --- a/plugins/samplesink/bladerf1output/bladerf1outputgui.h +++ b/plugins/samplesink/bladerf1output/bladerf1outputgui.h @@ -59,6 +59,7 @@ private: bool m_doApplySettings; bool m_forceSettings; BladeRF1OutputSettings m_settings; + bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode QTimer m_updateTimer; QTimer m_statusTimer; DeviceSampleSink* m_deviceSampleSink; @@ -69,6 +70,7 @@ private: void blockApplySettings(bool block) { m_doApplySettings = !block; } void displaySettings(); + void displaySampleRate(); void sendSettings(); unsigned int getXb200Index(bool xb_200, bladerf_xb200_path xb200Path, bladerf_xb200_filter xb200Filter); void updateSampleRateAndFrequency(); @@ -83,6 +85,7 @@ private slots: void on_vga2_valueChanged(int value); void on_xb200_currentIndexChanged(int index); void on_startStop_toggled(bool checked); + void on_sampleRateMode_toggled(bool checked); void updateHardware(); void updateStatus(); void openDeviceSettingsDialog(const QPoint& p); diff --git a/plugins/samplesink/bladerf1output/bladerf1outputgui.ui b/plugins/samplesink/bladerf1output/bladerf1outputgui.ui index ec2607191..d8260c1d4 100644 --- a/plugins/samplesink/bladerf1output/bladerf1outputgui.ui +++ b/plugins/samplesink/bladerf1output/bladerf1outputgui.ui @@ -76,7 +76,7 @@ - + 50 @@ -300,16 +300,31 @@ 2 - - - - 0 - 0 - + + + + 24 + 0 + + + + + 24 + 16777215 + + + + Toggle between device to host (SR) and base band (BB) sample rate input SR + + true + + + true +