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

HackRF input: implemented baseband or device sample rate input option

This commit is contained in:
f4exb 2019-04-13 21:20:22 +02:00
parent f5f2349d09
commit 457c873365
3 changed files with 93 additions and 23 deletions

View File

@ -40,6 +40,7 @@ HackRFInputGui::HackRFInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
ui(new Ui::HackRFInputGui),
m_deviceUISet(deviceUISet),
m_settings(),
m_sampleRateMode(true),
m_forceSettings(true),
m_doApplySettings(true),
m_sampleSource(NULL),
@ -193,7 +194,48 @@ void HackRFInputGui::updateSampleRateAndFrequency()
{
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateText->setText(QString("%1k").arg(QString::number(m_sampleRate/1000.0, 'g', 5)));
displaySampleRate();
}
void HackRFInputGui::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, 1000000U, 20000000U);
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, 1000000U/(1<<m_settings.m_log2Decim), 20000000U/(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 HackRFInputGui::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 HackRFInputGui::displaySettings()
@ -208,7 +250,7 @@ void HackRFInputGui::displaySettings()
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
ui->sampleRate->setValue(m_settings.m_devSampleRate);
displaySampleRate();
ui->biasT->setChecked(m_settings.m_biasT);
@ -304,30 +346,39 @@ void HackRFInputGui::on_centerFrequency_changed(quint64 value)
void HackRFInputGui::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();
}
void HackRFInputGui::on_decim_currentIndexChanged(int index)
{
if ((index <0) || (index > 6))
if ((index <0) || (index > 6)) {
return;
}
m_settings.m_log2Decim = index;
sendSettings();
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 HackRFInputGui::on_fcPos_currentIndexChanged(int index)
{
if (index == 0) {
m_settings.m_fcPos = HackRFInputSettings::FC_POS_INFRA;
sendSettings();
} else if (index == 1) {
m_settings.m_fcPos = HackRFInputSettings::FC_POS_SUPRA;
sendSettings();
} else if (index == 2) {
m_settings.m_fcPos = HackRFInputSettings::FC_POS_CENTER;
sendSettings();
}
m_settings.m_fcPos = (HackRFInputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
displayFcTooltip();
sendSettings();
}
void HackRFInputGui::on_lna_valueChanged(int value)
@ -371,6 +422,12 @@ void HackRFInputGui::on_record_toggled(bool checked)
m_sampleSource->getInputMessageQueue()->push(message);
}
void HackRFInputGui::on_sampleRateMode_toggled(bool checked)
{
m_sampleRateMode = checked;
displaySampleRate();
}
void HackRFInputGui::updateHardware()
{
if (m_doApplySettings)

View File

@ -66,6 +66,7 @@ private:
DeviceUISet* m_deviceUISet;
HackRFInputSettings m_settings;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
bool m_forceSettings;
bool m_doApplySettings;
QTimer m_updateTimer;
@ -77,6 +78,8 @@ private:
MessageQueue m_inputMessageQueue;
void displaySettings();
void displaySampleRate();
void displayFcTooltip();
void displayBandwidths();
void sendSettings();
void updateSampleRateAndFrequency();
@ -98,6 +101,7 @@ private slots:
void on_vga_valueChanged(int value);
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

@ -307,22 +307,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>
</property>
<widget class="QToolButton" name="sampleRateMode">
<property name="minimumSize">
<size>
<width>16</width>
<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>