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

BladeRF1 input: implemented baseband or device sample rate input option

This commit is contained in:
f4exb 2019-04-11 23:07:44 +02:00
parent 1cdb3a1c0c
commit 461b33f099
3 changed files with 99 additions and 21 deletions

View File

@ -39,6 +39,7 @@ Bladerf1InputGui::Bladerf1InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_doApplySettings(true),
m_settings(),
m_sampleRateMode(true),
m_sampleSource(NULL),
m_sampleRate(0),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
@ -189,7 +190,50 @@ void Bladerf1InputGui::updateSampleRateAndFrequency()
{
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateLabel->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5)));
displaySampleRate();
}
void Bladerf1InputGui::displaySampleRate()
{
ui->sampleRate->blockSignals(true);
displayFcTooltip();
if (m_sampleRateMode)
{
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }");
ui->sampleRateMode->setText("SR");
// BladeRF can go as low as 80 kS/s but because of buffering in practice experience is not good below 330 kS/s
ui->sampleRate->setValueRange(8, 330000U, BLADERF_SAMPLERATE_REC_MAX);
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->setStyleSheet("QToolButton { background:rgb(50,50,50); }");
ui->sampleRateMode->setText("BB");
// BladeRF can go as low as 80 kS/s but because of buffering in practice experience is not good below 330 kS/s
ui->sampleRate->setValueRange(8, 330000U/(1<<m_settings.m_log2Decim), BLADERF_SAMPLERATE_REC_MAX/(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 Bladerf1InputGui::displayFcTooltip()
{
int32_t fShift = DeviceSampleSource::calculateFrequencyShift(
m_settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) m_settings.m_fcPos,
m_settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD
);
ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5)));
}
void Bladerf1InputGui::displaySettings()
@ -197,7 +241,7 @@ void Bladerf1InputGui::displaySettings()
blockApplySettings(true);
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->sampleRate->setValue(m_settings.m_devSampleRate);
displaySampleRate();
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
@ -236,7 +280,13 @@ void Bladerf1InputGui::on_centerFrequency_changed(quint64 value)
void Bladerf1InputGui::on_sampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;
if (m_sampleRateMode) {
m_settings.m_devSampleRate = value;
} else {
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim);
}
displayFcTooltip();
sendSettings();
}
@ -261,24 +311,27 @@ void Bladerf1InputGui::on_bandwidth_currentIndexChanged(int index)
void Bladerf1InputGui::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();
}
void Bladerf1InputGui::on_fcPos_currentIndexChanged(int index)
{
if (index == 0) {
m_settings.m_fcPos = BladeRF1InputSettings::FC_POS_INFRA;
sendSettings();
} else if (index == 1) {
m_settings.m_fcPos = BladeRF1InputSettings::FC_POS_SUPRA;
sendSettings();
} else if (index == 2) {
m_settings.m_fcPos = BladeRF1InputSettings::FC_POS_CENTER;
sendSettings();
}
m_settings.m_fcPos = (BladeRF1InputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
displayFcTooltip();
sendSettings();
}
void Bladerf1InputGui::on_lna_currentIndexChanged(int index)
@ -393,6 +446,12 @@ void Bladerf1InputGui::on_record_toggled(bool checked)
m_sampleSource->getInputMessageQueue()->push(message);
}
void Bladerf1InputGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void Bladerf1InputGui::updateHardware()
{
if (m_doApplySettings)

View File

@ -58,6 +58,7 @@ private:
bool m_forceSettings;
bool m_doApplySettings;
BladeRF1InputSettings 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,8 @@ private:
MessageQueue m_inputMessageQueue;
void displaySettings();
void displaySampleRate();
void displayFcTooltip();
void sendSettings();
unsigned int getXb200Index(bool xb_200, bladerf_xb200_path xb200Path, bladerf_xb200_filter xb200Filter);
void updateSampleRateAndFrequency();
@ -88,6 +91,7 @@ private slots:
void on_fcPos_currentIndexChanged(int index);
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void on_sampleRateMode_toggled(bool checked);
void updateHardware();
void updateStatus();
void openDeviceSettingsDialog(const QPoint& p);

View File

@ -91,7 +91,7 @@
<item>
<layout class="QHBoxLayout" name="deviceRateLayout">
<item>
<widget class="QLabel" name="deviceRateLabel">
<widget class="QLabel" name="deviceRateText">
<property name="toolTip">
<string>I/Q sample rate kS/s</string>
</property>
@ -303,16 +303,31 @@
<number>2</number>
</property>
<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>24</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Toggle between device to host (SR) and base band (BB) 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>