1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

RTL-SDR: implemented baseband or device sample rate input option

This commit is contained in:
f4exb 2019-04-07 02:06:05 +02:00
parent d9e13de372
commit 6978a90d43
3 changed files with 93 additions and 16 deletions

View File

@ -39,6 +39,7 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_doApplySettings(true),
m_forceSettings(true),
m_settings(),
m_sampleRateMode(true),
m_sampleSource(0),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
@ -49,7 +50,6 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) :
updateFrequencyLimits();
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin, RTLSDRInput::sampleRateHighRangeMax);
ui->rfBW->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
ui->rfBW->setValueRange(4, 350, 8000);
@ -202,7 +202,7 @@ void RTLSDRGui::updateSampleRateAndFrequency()
{
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5)));
displaySampleRate();
}
void RTLSDRGui::updateFrequencyLimits()
@ -249,13 +249,53 @@ void RTLSDRGui::displayGains()
}
}
void RTLSDRGui::displaySampleRate()
{
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
ui->sampleRate->blockSignals(true);
if (m_sampleRateMode)
{
ui->sampleRateMode->setText("SR");
if (m_settings.m_lowSampleRate) {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateLowRangeMin, RTLSDRInput::sampleRateLowRangeMax);
} else {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin, RTLSDRInput::sampleRateHighRangeMax);
}
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<<m_settings.m_log2Decim);
ui->deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5)));
}
else
{
ui->sampleRateMode->setText("BB");
if (m_settings.m_lowSampleRate) {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateLowRangeMin/(1<<m_settings.m_log2Decim), RTLSDRInput::sampleRateLowRangeMax/(1<<m_settings.m_log2Decim));
} else {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin/(1<<m_settings.m_log2Decim), RTLSDRInput::sampleRateHighRangeMax/(1<<m_settings.m_log2Decim));
}
ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim));
ui->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 RTLSDRGui::displaySettings()
{
ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency);
ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode);
updateFrequencyLimits();
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->sampleRate->setValue(m_settings.m_devSampleRate);
displaySampleRate();
ui->rfBW->setValue(m_settings.m_rfBandwidth / 1000);
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
@ -285,12 +325,18 @@ void RTLSDRGui::on_centerFrequency_changed(quint64 value)
void RTLSDRGui::on_decim_currentIndexChanged(int index)
{
if ((index <0) || (index > 6))
{
if ((index <0) || (index > 6)) {
return;
}
m_settings.m_log2Decim = index;
displaySampleRate();
if (m_sampleRateMode) {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
} else {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim);
}
sendSettings();
}
@ -367,6 +413,12 @@ void RTLSDRGui::on_transverter_clicked()
sendSettings();
}
void RTLSDRGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void RTLSDRGui::updateHardware()
{
if (m_doApplySettings)
@ -443,7 +495,12 @@ void RTLSDRGui::on_agc_stateChanged(int state)
void RTLSDRGui::on_sampleRate_changed(quint64 value)
{
if (m_sampleRateMode) {
m_settings.m_devSampleRate = value;
} else {
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim);
}
sendSettings();
}
@ -463,14 +520,16 @@ void RTLSDRGui::on_lowSampleRate_toggled(bool checked)
{
m_settings.m_lowSampleRate = checked;
if (m_settings.m_lowSampleRate) {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateLowRangeMin, RTLSDRInput::sampleRateLowRangeMax);
displaySampleRate();
if (m_sampleRateMode) {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
} else {
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin, RTLSDRInput::sampleRateHighRangeMax);
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim);
}
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
qDebug("RTLSDRGui::on_lowSampleRate_toggled: %d S/s", m_settings.m_devSampleRate);
sendSettings();
}

View File

@ -58,6 +58,7 @@ private:
bool m_doApplySettings;
bool m_forceSettings;
RTLSDRSettings m_settings;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
@ -68,6 +69,7 @@ private:
MessageQueue m_inputMessageQueue;
void displayGains();
void displaySampleRate();
void displaySettings();
void sendSettings();
void updateSampleRateAndFrequency();
@ -92,6 +94,7 @@ private slots:
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void on_transverter_clicked();
void on_sampleRateMode_toggled(bool checked);
void openDeviceSettingsDialog(const QPoint& p);
void updateHardware();
void updateStatus();

View File

@ -348,16 +348,31 @@
</widget>
</item>
<item>
<widget class="QLabel" name="samplerateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QToolButton" name="sampleRateMode">
<property name="minimumSize">
<size>
<width>26</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>26</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Toggle between device to host and base band sample rate input</string>
</property>
<property name="text">
<string>SR</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>