1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 11:18:56 -05:00

BladeRF2: implemented baseband or device sample rate input option

This commit is contained in:
f4exb 2019-04-12 14:14:17 +02:00
parent bfe38e7965
commit 10be66085b
8 changed files with 187 additions and 34 deletions

View File

@ -39,6 +39,7 @@ BladeRF2OutputGui::BladeRF2OutputGui(DeviceUISet *deviceUISet, QWidget* parent)
m_doApplySettings(true),
m_forceSettings(true),
m_settings(),
m_sampleRateMode(true),
m_sampleRate(0),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted)
{
@ -241,7 +242,39 @@ void BladeRF2OutputGui::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 BladeRF2OutputGui::displaySampleRate()
{
int max, min, step;
m_sampleSink->getSampleRateRange(min, max, step);
ui->sampleRate->blockSignals(true);
if (m_sampleRateMode)
{
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }");
ui->sampleRateMode->setText("SR");
ui->sampleRate->setValueRange(8, min, 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_log2Interp);
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");
ui->sampleRate->setValueRange(8, min/(1<<m_settings.m_log2Interp), max/(1<<m_settings.m_log2Interp));
ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp));
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 BladeRF2OutputGui::displaySettings()
@ -254,7 +287,7 @@ void BladeRF2OutputGui::displaySettings()
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
ui->sampleRate->setValue(m_settings.m_devSampleRate);
displaySampleRate();
ui->bandwidth->setValue(m_settings.m_bandwidth / 1000);
ui->interp->setCurrentIndex(m_settings.m_log2Interp);
@ -287,7 +320,12 @@ void BladeRF2OutputGui::on_LOppm_valueChanged(int value)
void BladeRF2OutputGui::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_log2Interp);
}
sendSettings();
}
@ -305,9 +343,19 @@ void BladeRF2OutputGui::on_bandwidth_changed(quint64 value)
void BladeRF2OutputGui::on_interp_currentIndexChanged(int index)
{
if ((index <0) || (index > 6))
if ((index <0) || (index > 6)) {
return;
}
m_settings.m_log2Interp = index;
displaySampleRate();
if (m_sampleRateMode) {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
} else {
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Interp);
}
sendSettings();
}
@ -337,6 +385,12 @@ void BladeRF2OutputGui::on_startStop_toggled(bool checked)
}
}
void BladeRF2OutputGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void BladeRF2OutputGui::updateHardware()
{
if (m_doApplySettings)

View File

@ -59,6 +59,7 @@ private:
bool m_doApplySettings;
bool m_forceSettings;
BladeRF2OutputSettings m_settings;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
QTimer m_updateTimer;
QTimer m_statusTimer;
BladeRF2Output* m_sampleSink;
@ -69,6 +70,7 @@ private:
void blockApplySettings(bool block) { m_doApplySettings = !block; }
void displaySettings();
void displaySampleRate();
void sendSettings();
void updateSampleRateAndFrequency();
void updateFrequencyLimits();
@ -85,6 +87,7 @@ private slots:
void on_gain_valueChanged(int value);
void on_startStop_toggled(bool checked);
void on_transverter_clicked();
void on_sampleRateMode_toggled(bool checked);
void updateHardware();
void updateStatus();
void openDeviceSettingsDialog(const QPoint& p);

View File

@ -76,7 +76,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>
@ -301,16 +301,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>

View File

@ -31,7 +31,7 @@
const PluginDescriptor BladeRF2OutputPlugin::m_pluginDescriptor = {
QString("BladeRF2 Output"),
QString("4.5.2"),
QString("4.5.4"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,

View File

@ -39,6 +39,7 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_doApplySettings(true),
m_settings(),
m_sampleRateMode(true),
m_sampleSource(0),
m_sampleRate(0),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
@ -253,7 +254,53 @@ void BladeRF2InputGui::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 BladeRF2InputGui::displaySampleRate()
{
int max, min, step;
m_sampleSource->getSampleRateRange(min, max, step);
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, min, 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, min/(1<<m_settings.m_log2Decim), 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 BladeRF2InputGui::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 BladeRF2InputGui::displaySettings()
@ -266,7 +313,7 @@ void BladeRF2InputGui::displaySettings()
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
ui->sampleRate->setValue(m_settings.m_devSampleRate);
displaySampleRate();
ui->bandwidth->setValue(m_settings.m_bandwidth / 1000);
ui->dcOffset->setChecked(m_settings.m_dcBlock);
@ -310,7 +357,13 @@ void BladeRF2InputGui::on_LOppm_valueChanged(int value)
void BladeRF2InputGui::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();
}
@ -340,24 +393,27 @@ void BladeRF2InputGui::on_bandwidth_changed(quint64 value)
void BladeRF2InputGui::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 BladeRF2InputGui::on_fcPos_currentIndexChanged(int index)
{
if (index == 0) {
m_settings.m_fcPos = BladeRF2InputSettings::FC_POS_INFRA;
sendSettings();
} else if (index == 1) {
m_settings.m_fcPos = BladeRF2InputSettings::FC_POS_SUPRA;
sendSettings();
} else if (index == 2) {
m_settings.m_fcPos = BladeRF2InputSettings::FC_POS_CENTER;
sendSettings();
}
m_settings.m_fcPos = (BladeRF2InputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
displayFcTooltip();
sendSettings();
}
void BladeRF2InputGui::on_gainMode_currentIndexChanged(int index)
@ -423,6 +479,12 @@ void BladeRF2InputGui::on_record_toggled(bool checked)
m_sampleSource->getInputMessageQueue()->push(message);
}
void BladeRF2InputGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void BladeRF2InputGui::updateHardware()
{
if (m_doApplySettings)

View File

@ -58,6 +58,7 @@ private:
bool m_forceSettings;
bool m_doApplySettings;
BladeRF2InputSettings 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();
void updateSampleRateAndFrequency();
void updateFrequencyLimits();
@ -90,6 +93,7 @@ private slots:
void on_transverter_clicked();
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>
@ -343,16 +343,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>

View File

@ -31,7 +31,7 @@
const PluginDescriptor Blderf2InputPlugin::m_pluginDescriptor = {
QString("BladeRF2 Input"),
QString("4.5.2"),
QString("4.5.4"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,