From 7dfa4cdc6b9fd995a19b55d5afd21b963b097462 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 2 Apr 2017 04:34:58 +0200 Subject: [PATCH] HackRF output: continuous sample rate setting --- .../bladerfoutput/bladerfoutput.cpp | 4 +- .../bladerfoutput/bladerfoutputgui.cpp | 20 +- .../bladerfoutput/bladerfoutputgui.h | 2 +- .../bladerfoutput/bladerfoutputgui.ui | 234 +++++++++--------- 4 files changed, 128 insertions(+), 132 deletions(-) diff --git a/plugins/samplesink/bladerfoutput/bladerfoutput.cpp b/plugins/samplesink/bladerfoutput/bladerfoutput.cpp index 8389e8d89..45dedda23 100644 --- a/plugins/samplesink/bladerfoutput/bladerfoutput.cpp +++ b/plugins/samplesink/bladerfoutput/bladerfoutput.cpp @@ -461,8 +461,8 @@ bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool fo } qDebug() << "BladerfOutput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" - << " device sample rate: " << m_settings.m_devSampleRate << "Hz" - << " baseband sample rate: " << m_settings.m_devSampleRate/(1<centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->centerFrequency->setValueRange(7, BLADERF_FREQUENCY_MIN_XB200/1000, BLADERF_FREQUENCY_MAX/1000); - ui->samplerate->clear(); - for (int i = 0; i < BladerfSampleRates::getNbRates(); i++) - { - ui->samplerate->addItem(QString::number(BladerfSampleRates::getRate(i)/1000)); - } + ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::ReverseGreenYellow)); + ui->sampleRate->setValueRange(8, BLADERF_SAMPLERATE_MIN, BLADERF_SAMPLERATE_REC_MAX); ui->bandwidth->clear(); for (int i = 0; i < BladerfBandwidths::getNbBandwidths(); i++) @@ -169,15 +166,13 @@ void BladerfOutputGui::updateSampleRateAndFrequency() { m_deviceAPI->getSpectrum()->setSampleRate(m_sampleRate); m_deviceAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); - ui->deviceRateLabel->setText(tr("%1k").arg((float)m_sampleRate / 1000)); + ui->deviceRateLabel->setText(QString("%1k").arg(QString::number(m_sampleRate/1000.0, 'g', 5))); } void BladerfOutputGui::displaySettings() { ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); - - unsigned int sampleRateIndex = BladerfSampleRates::getRateIndex(m_settings.m_devSampleRate); - ui->samplerate->setCurrentIndex(sampleRateIndex); + ui->sampleRate->setValue(m_settings.m_devSampleRate); unsigned int bandwidthIndex = BladerfBandwidths::getBandwidthIndex(m_settings.m_bandwidth); ui->bandwidth->setCurrentIndex(bandwidthIndex); @@ -205,11 +200,10 @@ void BladerfOutputGui::on_centerFrequency_changed(quint64 value) sendSettings(); } -void BladerfOutputGui::on_samplerate_currentIndexChanged(int index) +void BladerfOutputGui::on_sampleRate_changed(quint64 value) { - int newrate = BladerfSampleRates::getRate(index); - m_settings.m_devSampleRate = newrate; - sendSettings(); + m_settings.m_devSampleRate = value; + sendSettings(); } void BladerfOutputGui::on_bandwidth_currentIndexChanged(int index) diff --git a/plugins/samplesink/bladerfoutput/bladerfoutputgui.h b/plugins/samplesink/bladerfoutput/bladerfoutputgui.h index 2aaae6bbc..06c38e454 100644 --- a/plugins/samplesink/bladerfoutput/bladerfoutputgui.h +++ b/plugins/samplesink/bladerfoutput/bladerfoutputgui.h @@ -69,7 +69,7 @@ private: private slots: void handleDSPMessages(); void on_centerFrequency_changed(quint64 value); - void on_samplerate_currentIndexChanged(int index); + void on_sampleRate_changed(quint64 value); void on_bandwidth_currentIndexChanged(int index); void on_interp_currentIndexChanged(int index); void on_vga1_valueChanged(int value); diff --git a/plugins/samplesink/bladerfoutput/bladerfoutputgui.ui b/plugins/samplesink/bladerfoutput/bladerfoutputgui.ui index 4dee0f64e..9c4c440f1 100644 --- a/plugins/samplesink/bladerfoutput/bladerfoutputgui.ui +++ b/plugins/samplesink/bladerfoutput/bladerfoutputgui.ui @@ -6,20 +6,20 @@ 0 0 - 259 - 251 + 310 + 250 - + 0 0 - 0 - 210 + 310 + 250 @@ -170,7 +170,7 @@ - + Qt::Horizontal @@ -183,14 +183,14 @@ - + xb200 - + XB200 board mode @@ -246,14 +246,122 @@ - + + + + + 0 + 0 + + + + BW + + + + + + + + 70 + 16777215 + + + + IF bandwidth in kHz + + + + + + + kHz + + + + + + + + + Qt::Horizontal + + + + + + + 2 + + + 2 + + + + + + 0 + 0 + + + + SR + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Monospace + 12 + + + + Device sample rate (S/s) + + + + + + + S/s + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Int - + @@ -301,112 +409,6 @@ - - - - Qt::Horizontal - - - - - - - 3 - - - - - - 0 - 0 - - - - SR - - - - - - - - 70 - 16777215 - - - - Sample rate in kS/s - - - - - - - kS/s - - - - - - - - 70 - 16777215 - - - - IF bandwidth in kHz - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - BW - - - - - - - kHz - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - -