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

PlutoSDR input: implemented baseband or device sample rate input option

This commit is contained in:
f4exb 2019-04-13 22:16:08 +02:00
parent 41fd3ea765
commit 2f3418487d
5 changed files with 97 additions and 15 deletions

View File

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

View File

@ -33,7 +33,7 @@
const PluginDescriptor HackRFInputPlugin::m_pluginDescriptor = { const PluginDescriptor HackRFInputPlugin::m_pluginDescriptor = {
QString("HackRF Input"), QString("HackRF Input"),
QString("4.5.3"), QString("4.5.4"),
QString("(c) Edouard Griffiths, F4EXB"), QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"), QString("https://github.com/f4exb/sdrangel"),
true, true,

View File

@ -36,6 +36,7 @@ PlutoSDRInputGui::PlutoSDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
ui(new Ui::PlutoSDRInputGUI), ui(new Ui::PlutoSDRInputGUI),
m_deviceUISet(deviceUISet), m_deviceUISet(deviceUISet),
m_settings(), m_settings(),
m_sampleRateMode(true),
m_forceSettings(true), m_forceSettings(true),
m_sampleSource(NULL), m_sampleSource(NULL),
m_sampleRate(0), m_sampleRate(0),
@ -228,18 +229,33 @@ void PlutoSDRInputGui::on_iqImbalance_toggled(bool checked)
void PlutoSDRInputGui::on_swDecim_currentIndexChanged(int index) void PlutoSDRInputGui::on_swDecim_currentIndexChanged(int index)
{ {
m_settings.m_log2Decim = index > 6 ? 6 : index; m_settings.m_log2Decim = index > 6 ? 6 : 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(); sendSettings();
} }
void PlutoSDRInputGui::on_fcPos_currentIndexChanged(int index) void PlutoSDRInputGui::on_fcPos_currentIndexChanged(int index)
{ {
m_settings.m_fcPos = (PlutoSDRInputSettings::fcPos_t) (index < (int) PlutoSDRInputSettings::FC_POS_END ? index : PlutoSDRInputSettings::FC_POS_CENTER); m_settings.m_fcPos = (PlutoSDRInputSettings::fcPos_t) (index < (int) PlutoSDRInputSettings::FC_POS_END ? index : PlutoSDRInputSettings::FC_POS_CENTER);
displayFcTooltip();
sendSettings(); sendSettings();
} }
void PlutoSDRInputGui::on_sampleRate_changed(quint64 value) void PlutoSDRInputGui::on_sampleRate_changed(quint64 value)
{ {
if (m_sampleRateMode) {
m_settings.m_devSampleRate = value; m_settings.m_devSampleRate = value;
} else {
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim);
}
displayFcTooltip();
sendSettings(); sendSettings();
} }
@ -306,13 +322,60 @@ void PlutoSDRInputGui::on_transverter_clicked()
sendSettings(); sendSettings();
} }
void PlutoSDRInputGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void PlutoSDRInputGui::displaySampleRate()
{
ui->sampleRate->blockSignals(true);
displayFcTooltip();
if (m_sampleRateMode)
{
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }");
ui->sampleRateMode->setText("SR");
ui->sampleRate->setValueRange(8, DevicePlutoSDR::srLowLimitFreq, DevicePlutoSDR::srHighLimitFreq);
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");
ui->sampleRate->setValueRange(8, DevicePlutoSDR::srLowLimitFreq/(1<<m_settings.m_log2Decim), DevicePlutoSDR::srHighLimitFreq/(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 PlutoSDRInputGui::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 PlutoSDRInputGui::displaySettings() void PlutoSDRInputGui::displaySettings()
{ {
ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency); ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency);
ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode); ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode);
updateFrequencyLimits(); updateFrequencyLimits();
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->sampleRate->setValue(m_settings.m_devSampleRate); displaySampleRate();
ui->dcOffset->setChecked(m_settings.m_dcBlock); ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection); ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
@ -397,9 +460,9 @@ void PlutoSDRInputGui::updateStatus()
uint32_t adcRate = ((PlutoSDRInput *) m_sampleSource)->getADCSampleRate(); uint32_t adcRate = ((PlutoSDRInput *) m_sampleSource)->getADCSampleRate();
if (adcRate < 100000000) { if (adcRate < 100000000) {
ui->adcRateLabel->setText(tr("%1k").arg(QString::number(adcRate / 1000.0f, 'g', 5))); ui->adcRateText->setText(tr("%1k").arg(QString::number(adcRate / 1000.0f, 'g', 5)));
} else { } else {
ui->adcRateLabel->setText(tr("%1M").arg(QString::number(adcRate / 1000000.0f, 'g', 5))); ui->adcRateText->setText(tr("%1M").arg(QString::number(adcRate / 1000000.0f, 'g', 5)));
} }
} }
@ -491,7 +554,7 @@ void PlutoSDRInputGui::updateSampleRateAndFrequency()
{ {
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateLabel->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5))); displaySampleRate();
} }
void PlutoSDRInputGui::openDeviceSettingsDialog(const QPoint& p) void PlutoSDRInputGui::openDeviceSettingsDialog(const QPoint& p)

View File

@ -57,6 +57,7 @@ private:
Ui::PlutoSDRInputGUI* ui; Ui::PlutoSDRInputGUI* ui;
DeviceUISet* m_deviceUISet; DeviceUISet* m_deviceUISet;
PlutoSDRInputSettings m_settings; PlutoSDRInputSettings m_settings;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
bool m_forceSettings; bool m_forceSettings;
QTimer m_updateTimer; QTimer m_updateTimer;
QTimer m_statusTimer; QTimer m_statusTimer;
@ -69,6 +70,8 @@ private:
MessageQueue m_inputMessageQueue; MessageQueue m_inputMessageQueue;
void displaySettings(); void displaySettings();
void displaySampleRate();
void displayFcTooltip();
void sendSettings(bool forceSettings = false); void sendSettings(bool forceSettings = false);
void blockApplySettings(bool block); void blockApplySettings(bool block);
void updateSampleRateAndFrequency(); void updateSampleRateAndFrequency();
@ -95,6 +98,7 @@ private slots:
void on_gain_valueChanged(int value); void on_gain_valueChanged(int value);
void on_antenna_currentIndexChanged(int index); void on_antenna_currentIndexChanged(int index);
void on_transverter_clicked(); void on_transverter_clicked();
void on_sampleRateMode_toggled(bool checked);
void updateHardware(); void updateHardware();
void updateStatus(); void updateStatus();
void handleInputMessages(); void handleInputMessages();

View File

@ -91,7 +91,7 @@
<item> <item>
<layout class="QHBoxLayout" name="freqLeftBotLayout"> <layout class="QHBoxLayout" name="freqLeftBotLayout">
<item> <item>
<widget class="QLabel" name="adcRateLabel"> <widget class="QLabel" name="adcRateText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>54</width> <width>54</width>
@ -179,7 +179,7 @@
<item> <item>
<layout class="QHBoxLayout" name="freqRightBotLayout"> <layout class="QHBoxLayout" name="freqRightBotLayout">
<item> <item>
<widget class="QLabel" name="deviceRateLabel"> <widget class="QLabel" name="deviceRateText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>54</width> <width>54</width>
@ -503,16 +503,31 @@
<item> <item>
<layout class="QHBoxLayout" name="sampleRateLayout"> <layout class="QHBoxLayout" name="sampleRateLayout">
<item> <item>
<widget class="QLabel" name="samplerateLabel"> <widget class="QToolButton" name="sampleRateMode">
<property name="sizePolicy"> <property name="minimumSize">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <size>
<horstretch>0</horstretch> <width>24</width>
<verstretch>0</verstretch> <height>0</height>
</sizepolicy> </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>
<property name="text"> <property name="text">
<string>SR</string> <string>SR</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>