diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp index a73ffbded..972f82a98 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp @@ -41,6 +41,7 @@ HackRFOutputGui::HackRFOutputGui(DeviceUISet *deviceUISet, QWidget* parent) : m_deviceUISet(deviceUISet), m_forceSettings(true), m_settings(), + m_sampleRateMode(true), m_deviceSampleSink(0), m_lastEngineState(DSPDeviceSinkEngine::StNotStarted), m_doApplySettings(true) @@ -196,7 +197,36 @@ void HackRFOutputGui::updateSampleRateAndFrequency() { m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); - ui->deviceRateText->setText(QString("%1k").arg(QString::number(m_sampleRate/1000.0, 'g', 5))); + displaySampleRate(); +} + +void HackRFOutputGui::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, 1000000U, 20000000U); + 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, 1000000U/(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 HackRFOutputGui::displaySettings() @@ -209,7 +239,7 @@ void HackRFOutputGui::displaySettings() ui->biasT->setChecked(m_settings.m_biasT); - ui->sampleRate->setValue(m_settings.m_devSampleRate); + displaySampleRate(); ui->interp->setCurrentIndex(m_settings.m_log2Interp); ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); @@ -262,7 +292,12 @@ void HackRFOutputGui::on_centerFrequency_changed(quint64 value) void HackRFOutputGui::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(); } @@ -294,9 +329,19 @@ void HackRFOutputGui::on_lnaExt_stateChanged(int state) void HackRFOutputGui::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(); } @@ -325,6 +370,12 @@ void HackRFOutputGui::on_startStop_toggled(bool checked) } } +void HackRFOutputGui::on_sampleRateMode_toggled(bool checked) +{ + m_sampleRateMode = checked; + displaySampleRate(); +} + void HackRFOutputGui::updateHardware() { if (m_doApplySettings) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h index 0f07b121b..4eab1cfcc 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h @@ -68,6 +68,7 @@ private: DeviceUISet* m_deviceUISet; bool m_forceSettings; HackRFOutputSettings m_settings; + bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode QTimer m_updateTimer; QTimer m_statusTimer; DeviceSampleSink* m_deviceSampleSink; @@ -78,6 +79,7 @@ private: bool m_doApplySettings; void displaySettings(); + void displaySampleRate(); void displayBandwidths(); void sendSettings(); void updateSampleRateAndFrequency(); @@ -95,6 +97,7 @@ private slots: void on_bbFilter_currentIndexChanged(int index); void on_txvga_valueChanged(int value); 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/hackrfoutput/hackrfoutputgui.ui b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui index 01fdecd4a..240dc59ec 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui @@ -292,16 +292,31 @@ 4 - - - - 0 - 0 - + + + + 24 + 0 + + + + + 24 + 16777215 + + + + Toggle between device to host (SR) and base band (BB) sample rate input SR + + true + + + true +