From c07d4483e01a849f1b7a1784e2335f79500aad0c Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 18 Apr 2017 01:16:39 +0200 Subject: [PATCH] LimeSDR input: use a value dial for the analog lowpass filter --- .../limesdrinput/limesdrinput.cpp | 26 ++++-------- .../samplesource/limesdrinput/limesdrinput.h | 3 +- .../limesdrinput/limesdrinputgui.cpp | 17 +++----- .../limesdrinput/limesdrinputgui.h | 2 +- .../limesdrinput/limesdrinputgui.ui | 41 ++++++++++++------- 5 files changed, 42 insertions(+), 47 deletions(-) diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index 4f45758d8..49c18e094 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -37,7 +37,8 @@ LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) : m_settings(), m_limeSDRInputThread(0), m_deviceDescription(), - m_running(false) + m_running(false), + m_firstConfig(true) { openDevice(); } @@ -255,27 +256,12 @@ void LimeSDRInput::getSRRange(float& minF, float& maxF, float& stepF) const void LimeSDRInput::getLPRange(float& minF, float& maxF, float& stepF) const { lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; - float step = range.step < 1000.0f ? 1000.0 : range.step; minF = range.min; maxF = range.max; - stepF = step; + stepF = range.step; qDebug("LimeSDRInput::getLPRange: min: %f max: %f step: %f", range.min, range.max, range.step); } -int LimeSDRInput::getLPIndex(float lpfBW) const -{ - lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; - float step = range.step < 1000.0f ? 1000.0 : range.step; - return (int) ((lpfBW - range.min) / step); -} - -float LimeSDRInput::getLPValue(int index) const -{ - lms_range_t range = m_deviceShared.m_deviceParams->m_lpfRangeRx; - float step = range.step < 1000.0f ? 1000.0 : range.step; - return index * step; -} - uint32_t LimeSDRInput::getHWLog2Decim() const { return m_deviceShared.m_deviceParams->m_log2OvSRRx; @@ -288,10 +274,14 @@ bool LimeSDRInput::handleMessage(const Message& message) MsgConfigureLimeSDR& conf = (MsgConfigureLimeSDR&) message; qDebug() << "LimeSDRInput::handleMessage: MsgConfigureLimeSDR"; - if (!applySettings(conf.getSettings(), false)) + if (!applySettings(conf.getSettings(), m_firstConfig)) { qDebug("LimeSDRInput::handleMessage config error"); } + else + { + m_firstConfig = false; + } return true; } diff --git a/plugins/samplesource/limesdrinput/limesdrinput.h b/plugins/samplesource/limesdrinput/limesdrinput.h index 0e720ee9b..a49d1dc62 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.h +++ b/plugins/samplesource/limesdrinput/limesdrinput.h @@ -113,8 +113,6 @@ public: void getLORange(float& minF, float& maxF, float& stepF) const; void getSRRange(float& minF, float& maxF, float& stepF) const; void getLPRange(float& minF, float& maxF, float& stepF) const; - int getLPIndex(float lpfBW) const; - float getLPValue(int index) const; uint32_t getHWLog2Decim() const; private: @@ -125,6 +123,7 @@ private: QString m_deviceDescription; bool m_running; DeviceLimeSDRShared m_deviceShared; + bool m_firstConfig; lms_stream_t m_streamId; diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp index 1d6bc8295..d02e8d86b 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.cpp @@ -54,11 +54,8 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) : ui->sampleRate->setValueRange(8, (uint32_t) minF, (uint32_t) maxF); m_limeSDRInput->getLPRange(minF, maxF, stepF); - int minLP = (int) (minF / stepF); - int maxLP = (int) (maxF / stepF); - int nbSteps = (int) ((maxF - minF) / stepF); - ui->lpf->setMinimum(minLP); - ui->lpf->setMaximum(maxLP); + ui->lpf->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); + ui->lpf->setValueRange(6, (minF/1000)+1, maxF/1000); ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->lpFIR->setValueRange(5, 1U, 56000U); @@ -203,8 +200,7 @@ void LimeSDRInputGUI::displaySettings() ui->hwDecim->setCurrentIndex(m_settings.m_log2HardDecim); ui->swDecim->setCurrentIndex(m_settings.m_log2SoftDecim); - ui->lpf->setValue(m_limeSDRInput->getLPIndex(m_settings.m_lpfBW)); - ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfBW / 1000.0f, 'f', 0))); + ui->lpf->setValue(m_settings.m_lpfBW / 1000); ui->lpFIREnable->setChecked(m_settings.m_lpfFIREnable); ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000); @@ -223,7 +219,7 @@ void LimeSDRInputGUI::updateHardware() { if (m_doApplySettings) { - qDebug() << "BladerfGui::updateHardware"; + qDebug() << "LimeSDRInputGUI::updateHardware"; LimeSDRInput::MsgConfigureLimeSDR* message = LimeSDRInput::MsgConfigureLimeSDR::create(m_settings); m_sampleSource->getInputMessageQueue()->push(message); m_updateTimer.stop(); @@ -334,10 +330,9 @@ void LimeSDRInputGUI::on_swDecim_currentIndexChanged(int index) sendSettings(); } -void LimeSDRInputGUI::on_lpf_valueChanged(int value) +void LimeSDRInputGUI::on_lpf_changed(int value) { - m_settings.m_lpfBW = m_limeSDRInput->getLPValue(value); - ui->lpfText->setText(tr("%1k").arg(QString::number(m_settings.m_lpfBW / 1000.0f, 'f', 0))); + m_settings.m_lpfBW = value * 1000; sendSettings(); } diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.h b/plugins/samplesource/limesdrinput/limesdrinputgui.h index 458f49d0c..c4990f0b5 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.h +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.h @@ -78,7 +78,7 @@ private slots: void on_sampleRate_changed(quint64 value); void on_hwDecim_currentIndexChanged(int index); void on_swDecim_currentIndexChanged(int index); - void on_lpf_valueChanged(int value); + void on_lpf_changed(int value); void on_lpFIREnable_toggled(bool checked); void on_lpFIR_changed(quint64 value); void on_gain_valueChanged(int value); diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.ui b/plugins/samplesource/limesdrinput/limesdrinputgui.ui index daf79c919..b2ae7b18f 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.ui +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.ui @@ -265,7 +265,6 @@ 12 - samplerateUnit @@ -452,22 +451,34 @@ - + + + + 0 + 0 + + + + + 32 + 16 + + + + + Monospace + 12 + + - Analog lowpass filter bandwidth (kHz) - - - 1 - - - Qt::Horizontal + Analog lowpass filers bandwidth (kHz) - + - 00000k + k @@ -490,7 +501,7 @@ Enable or disable the digital FIR lowpass filters - LPFIR + FIR @@ -515,14 +526,14 @@ - Digital FIR lowpass filers bandwidth (Hz) + Digital FIR lowpass filers bandwidth (kHz) - + - Hz + k