diff --git a/devices/plutosdr/deviceplutosdr.cpp b/devices/plutosdr/deviceplutosdr.cpp index 74a401435..7ac37317f 100644 --- a/devices/plutosdr/deviceplutosdr.cpp +++ b/devices/plutosdr/deviceplutosdr.cpp @@ -27,6 +27,9 @@ const uint32_t DevicePlutoSDR::bbLPRxHighLimitFreq = 14000000U; // 14 MHz const uint32_t DevicePlutoSDR::bbLPTxLowLimitFreq = 625000U; // 625 kHz const uint32_t DevicePlutoSDR::bbLPTxHighLimitFreq = 16000000U; // 16 MHz +const float DevicePlutoSDR::firBWLowLimitFactor = 0.1f; +const float DevicePlutoSDR::firBWHighLimitFactor = 0.9f; + DevicePlutoSDR::DevicePlutoSDR() { } diff --git a/devices/plutosdr/deviceplutosdr.h b/devices/plutosdr/deviceplutosdr.h index f7c69fcab..60795f755 100644 --- a/devices/plutosdr/deviceplutosdr.h +++ b/devices/plutosdr/deviceplutosdr.h @@ -42,7 +42,8 @@ public: static const uint32_t bbLPRxHighLimitFreq; //!< Analog base band Rx high pass filter lower frequency limit (Hz) static const uint32_t bbLPTxLowLimitFreq; //!< Analog base band Tx low pass filter lower frequency limit (Hz) static const uint32_t bbLPTxHighLimitFreq; //!< Analog base band Tx high pass filter lower frequency limit (Hz) - + static const float firBWLowLimitFactor; //!< Factor by which the FIR working sample rate is multiplied to yield bandwidth lower limit + static const float firBWHighLimitFactor; //!< Factor by which the FIR working sample rate is multiplied to yield bandwidth higher limit protected: DevicePlutoSDR(); ~DevicePlutoSDR(); diff --git a/devices/plutosdr/deviceplutosdrbox.cpp b/devices/plutosdr/deviceplutosdrbox.cpp index 48222b81e..3538fe33b 100644 --- a/devices/plutosdr/deviceplutosdrbox.cpp +++ b/devices/plutosdr/deviceplutosdrbox.cpp @@ -23,6 +23,7 @@ #include #include "dsp/wfir.h" +#include "deviceplutosdr.h" #include "deviceplutosdrbox.h" DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) : @@ -500,7 +501,9 @@ void DevicePlutoSDRBox::setFIR(uint32_t sampleRate, uint32_t log2IntDec, uint32_ nbTaps = nbGroups*8 > 128 ? 128 : nbGroups*8; nbTaps = intdec == 1 ? (nbTaps > 64 ? 64 : nbTaps) : nbTaps; normalizedBW = ((float) bw) / sampleRates.m_hb1Rate; - normalizedBW = normalizedBW < 0.1 ? 0.1 : normalizedBW > 0.9 ? 0.9 : normalizedBW; + normalizedBW = normalizedBW < DevicePlutoSDR::firBWLowLimitFactor ? + DevicePlutoSDR::firBWLowLimitFactor : + normalizedBW > DevicePlutoSDR::firBWHighLimitFactor ? DevicePlutoSDR::firBWHighLimitFactor : normalizedBW; qDebug("DevicePlutoSDRBox::setFIR: intdec: %u gain: %d nbTaps: %u BWin: %u BW: %f (%f)", intdec, diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.h b/plugins/samplesource/plutosdrinput/plutosdrinput.h index c6a6a17aa..14c204287 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.h @@ -87,6 +87,7 @@ public: virtual bool handleMessage(const Message& message); uint32_t getADCSampleRate() const { return m_deviceSampleRates.m_addaConnvRate; } + uint32_t getFIRSampleRate() const { return m_deviceSampleRates.m_hb1Rate; } void getRSSI(std::string& rssiStr); bool fetchTemperature(); float getTemperature(); diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp b/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp index 44c3e1146..b0b3a3a24 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp @@ -213,6 +213,8 @@ void PlutoSDRInputGui::on_lpf_changed(quint64 value) void PlutoSDRInputGui::on_lpFIREnable_toggled(bool checked) { m_settings.m_lpfFIREnable = checked; + ui->lpFIRDecimation->setEnabled(checked); + ui->lpFIRGain->setEnabled(checked); sendSettings(); } @@ -225,6 +227,7 @@ void PlutoSDRInputGui::on_lpFIR_changed(quint64 value) void PlutoSDRInputGui::on_lpFIRDecimation_currentIndexChanged(int index) { m_settings.m_lpfFIRlog2Decim = index > 2 ? 2 : index; + setSampleRateLimits(); sendSettings(); } @@ -271,12 +274,17 @@ void PlutoSDRInputGui::displaySettings() ui->lpFIR->setValue(m_settings.m_lpfFIRBW / 1000); ui->lpFIRDecimation->setCurrentIndex(m_settings.m_lpfFIRlog2Decim); ui->lpFIRGain->setCurrentIndex((m_settings.m_lpfFIRGain + 6)/6); + ui->lpFIRDecimation->setEnabled(m_settings.m_lpfFIREnable); + ui->lpFIRGain->setEnabled(m_settings.m_lpfFIREnable); ui->gainMode->setCurrentIndex((int) m_settings.m_gainMode); ui->gain->setValue(m_settings.m_gain); ui->gainText->setText(tr("%1").arg(m_settings.m_gain)); ui->antenna->setCurrentIndex((int) m_settings.m_antennaPath); + + setFIRBWLimits(); + setSampleRateLimits(); } void PlutoSDRInputGui::sendSettings(bool forceSettings) @@ -360,6 +368,19 @@ void PlutoSDRInputGui::updateStatus() m_statusCounter++; } +void PlutoSDRInputGui::setFIRBWLimits() +{ + float high = DevicePlutoSDR::firBWHighLimitFactor * ((PlutoSDRInput *) m_sampleSource)->getFIRSampleRate(); + float low = DevicePlutoSDR::firBWLowLimitFactor * ((PlutoSDRInput *) m_sampleSource)->getFIRSampleRate(); + ui->lpFIR->setValueRange(5, (int(low)/1000)+1, (int(high)/1000)+1); +} + +void PlutoSDRInputGui::setSampleRateLimits() +{ + uint32_t low = ui->lpFIREnable->isChecked() ? DevicePlutoSDR::srLowLimitFreq / (1<lpFIRDecimation->currentIndex()) : DevicePlutoSDR::srLowLimitFreq; + ui->sampleRate->setValueRange(8, low, DevicePlutoSDR::srHighLimitFreq); +} + void PlutoSDRInputGui::handleDSPMessages() { Message* message; @@ -374,6 +395,7 @@ void PlutoSDRInputGui::handleDSPMessages() m_deviceCenterFrequency = notif->getCenterFrequency(); qDebug("LimeSDRInputGUI::handleMessagesToGUI: SampleRate: %d, CenterFrequency: %llu", notif->getSampleRate(), notif->getCenterFrequency()); updateSampleRateAndFrequency(); + setFIRBWLimits(); delete message; } diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputgui.h b/plugins/samplesource/plutosdrinput/plutosdrinputgui.h index 679853de9..8d1f4f3bc 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputgui.h +++ b/plugins/samplesource/plutosdrinput/plutosdrinputgui.h @@ -67,6 +67,8 @@ private: void sendSettings(bool forceSettings = false); void blockApplySettings(bool block); void updateSampleRateAndFrequency(); + void setFIRBWLimits(); + void setSampleRateLimits(); private slots: void on_startStop_toggled(bool checked);