diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 33ad554c9..36c6e414e 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -15,6 +15,14 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) : ui->setupUi(this); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->centerFrequency->setValueRange(7, 24000U, 1900000U); + + ui->sampleRate->clear(); + + for (int i = 0; i < RTLSDRSampleRates::getNbRates(); i++) + { + ui->sampleRate->addItem(QString::number(RTLSDRSampleRates::getRate(i))); + } + connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); displaySettings(); @@ -129,13 +137,11 @@ void RTLSDRGui::displaySettings() ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); ui->dcOffset->setChecked(m_settings.m_dcBlock); ui->iqImbalance->setChecked(m_settings.m_iqImbalance); - ui->samplerateText->setText(tr("%1k").arg(m_settings.m_devSampleRate / 1000)); unsigned int sampleRateIndex = RTLSDRSampleRates::getRateIndex(m_settings.m_devSampleRate); - ui->samplerate->setValue(sampleRateIndex); + ui->sampleRate->setCurrentIndex(sampleRateIndex); ui->ppm->setValue(m_settings.m_loPpmCorrection); ui->ppmText->setText(tr("%1").arg(m_settings.m_loPpmCorrection)); - ui->decimText->setText(tr("%1").arg(1<decim->setValue(m_settings.m_log2Decim); + ui->decim->setCurrentIndex(m_settings.m_log2Decim); ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); if (m_gains.size() > 0) @@ -179,15 +185,14 @@ void RTLSDRGui::on_centerFrequency_changed(quint64 value) sendSettings(); } -void RTLSDRGui::on_decim_valueChanged(int value) +void RTLSDRGui::on_decim_currentIndexChanged(int index) { - if ((value <0) || (value > 4)) + if ((index <0) || (index > 4)) { return; } - ui->decimText->setText(tr("%1").arg(1<samplerateText->setText(tr("%1k").arg(newrate)); + int newrate = RTLSDRSampleRates::getRate(index); m_settings.m_devSampleRate = newrate * 1000; sendSettings(); @@ -300,3 +304,8 @@ unsigned int RTLSDRSampleRates::getRateIndex(unsigned int rate) return 0; } + +unsigned int RTLSDRSampleRates::getNbRates() +{ + return RTLSDRSampleRates::m_nb_rates; +} diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.h b/plugins/samplesource/rtlsdr/rtlsdrgui.h index 95027942c..0cb085d8a 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.h +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.h @@ -46,11 +46,11 @@ private slots: void on_centerFrequency_changed(quint64 value); void on_dcOffset_toggled(bool checked); void on_iqImbalance_toggled(bool checked); - void on_decim_valueChanged(int value); + void on_decim_currentIndexChanged(int index); void on_fcPos_currentIndexChanged(int index); void on_ppm_valueChanged(int value); void on_gain_valueChanged(int value); - void on_samplerate_valueChanged(int value); + void on_sampleRate_currentIndexChanged(int index); void on_checkBox_stateChanged(int state); void updateHardware(); void handleSourceMessages(); @@ -60,6 +60,7 @@ class RTLSDRSampleRates { public: static unsigned int getRate(unsigned int rate_index); static unsigned int getRateIndex(unsigned int rate); + static unsigned int getNbRates(); private: static unsigned int m_rates[7]; static unsigned int m_nb_rates; diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.ui b/plugins/samplesource/rtlsdr/rtlsdrgui.ui index 33f01eb41..f9b0a36b8 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.ui +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.ui @@ -6,7 +6,7 @@ 0 0 - 305 + 287 271 @@ -29,16 +29,7 @@ 3 - - 2 - - - 2 - - - 2 - - + 2 @@ -194,42 +185,7 @@ - - - 3 - - - - - - 40 - 0 - - - - 1024k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Device Samplerate - - - 6 - - - 1 - - - Qt::Horizontal - - - + @@ -239,68 +195,31 @@ - Rate - - - - - - - - - 3 - - - - - Dec. - - - - - - - Decimation factor - - - 4 - - - 1 - - - 4 - - - Qt::Horizontal + SR - - - - 40 - 0 - - + - 16 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + k - - - - - + + + + 50 + 16777215 + + Relative postion of device center frequency + + 2 + Inf @@ -313,19 +232,19 @@ - Cent + Cen - + - Fc pos + Fp - + Qt::Horizontal @@ -338,6 +257,87 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Sample rate in kS/s + + + + + + + + 45 + 16777215 + + + + Decimation factor + + + 0 + + + + 1 + + + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + + + + Dec + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + +