1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

HackRF output: continuous sample rate setting

This commit is contained in:
f4exb 2017-04-02 00:23:02 +02:00
parent 813d79a115
commit f91eba5b10
11 changed files with 103 additions and 102 deletions

View File

@ -269,13 +269,13 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
if (rc != HACKRF_SUCCESS)
{
qCritical("HackRFOutput::applySettings: could not set sample rate to %d S/s: %s",
qCritical("HackRFOutput::applySettings: could not set sample rate to %llu S/s: %s",
settings.m_devSampleRate,
hackrf_error_name(rc));
}
else
{
qDebug("HackRFOutput::applySettings: sample rate set to %d S/s",
qDebug("HackRFOutput::applySettings: sample rate set to %llu S/s",
settings.m_devSampleRate);
m_hackRFThread->setSamplerate(settings.m_devSampleRate);
}

View File

@ -42,6 +42,9 @@ HackRFOutputGui::HackRFOutputGui(DeviceSinkAPI *deviceAPI, QWidget* parent) :
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 0U, 7250000U);
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::ReverseGreenYellow));
ui->sampleRate->setValueRange(8, 2400000U, 20000000U);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
@ -50,7 +53,6 @@ HackRFOutputGui::HackRFOutputGui(DeviceSinkAPI *deviceAPI, QWidget* parent) :
m_deviceSampleSink = new HackRFOutput(m_deviceAPI);
displaySampleRates();
displayBandwidths();
m_deviceAPI->setSink(m_deviceSampleSink);
@ -156,7 +158,7 @@ void HackRFOutputGui::updateSampleRateAndFrequency()
{
m_deviceAPI->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
ui->deviceRateText->setText(QString("%1k").arg(QString::number(m_sampleRate/1000.0, 'f', 0)));
}
void HackRFOutputGui::displaySettings()
@ -166,11 +168,10 @@ void HackRFOutputGui::displaySettings()
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
unsigned int sampleRateIndex = HackRFSampleRates::getRateIndex(m_settings.m_devSampleRate);
ui->sampleRate->setCurrentIndex(sampleRateIndex);
ui->biasT->setChecked(m_settings.m_biasT);
ui->sampleRate->setValue(m_settings.m_devSampleRate);
ui->interp->setCurrentIndex(m_settings.m_log2Interp);
ui->lnaExt->setChecked(m_settings.m_lnaExt);
@ -181,29 +182,6 @@ void HackRFOutputGui::displaySettings()
ui->bbFilter->setCurrentIndex(bandwidthIndex);
}
void HackRFOutputGui::displaySampleRates()
{
int savedIndex = HackRFSampleRates::getRateIndex(m_settings.m_devSampleRate);
ui->sampleRate->blockSignals(true);
ui->sampleRate->clear();
for (int i = 0; i < HackRFSampleRates::m_nb_rates; i++)
{
ui->sampleRate->addItem(QString("%1").arg(QString::number(HackRFSampleRates::m_rates[i] / 1000.0f, 'f', 0)));
}
ui->sampleRate->blockSignals(false);
if (savedIndex < HackRFSampleRates::m_nb_rates)
{
ui->sampleRate->setCurrentIndex(savedIndex);
}
else
{
ui->sampleRate->setCurrentIndex((int) HackRFSampleRates::m_nb_rates-1);
}
}
void HackRFOutputGui::displayBandwidths()
{
int savedIndex = HackRFBandwidths::getBandwidthIndex(m_settings.m_bandwidth/1000);
@ -239,6 +217,12 @@ void HackRFOutputGui::on_centerFrequency_changed(quint64 value)
sendSettings();
}
void HackRFOutputGui::on_sampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;
sendSettings();
}
void HackRFOutputGui::on_LOppm_valueChanged(int value)
{
m_settings.m_LOppmTenths = value;
@ -246,13 +230,6 @@ void HackRFOutputGui::on_LOppm_valueChanged(int value)
sendSettings();
}
void HackRFOutputGui::on_sampleRate_currentIndexChanged(int index)
{
int newrate = HackRFSampleRates::getRate(index);
m_settings.m_devSampleRate = newrate;
sendSettings();
}
void HackRFOutputGui::on_bbFilter_currentIndexChanged(int index)
{
int newBandwidth = HackRFBandwidths::getBandwidth(index);

View File

@ -70,7 +70,6 @@ private:
int m_lastEngineState;
void displaySettings();
void displaySampleRates();
void displayBandwidths();
void sendSettings();
void updateSampleRateAndFrequency();
@ -78,8 +77,8 @@ private:
private slots:
void handleDSPMessages();
void on_centerFrequency_changed(quint64 value);
void on_sampleRate_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_sampleRate_currentIndexChanged(int index);
void on_biasT_stateChanged(int state);
void on_interp_currentIndexChanged(int index);
void on_lnaExt_stateChanged(int state);

View File

@ -6,20 +6,20 @@
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<height>210</height>
<width>320</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>210</height>
<width>320</width>
<height>300</height>
</size>
</property>
<property name="font">
@ -49,6 +49,9 @@
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QVBoxLayout" name="deviceUILayout">
<item>
@ -163,6 +166,12 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_LOppm">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
@ -204,23 +213,22 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_corr">
<item row="0" column="0">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_interp">
<property name="text">
<string>Int</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item row="1" column="3">
<widget class="QCheckBox" name="biasT">
<property name="toolTip">
<string>Activate antenna bias tee</string>
@ -233,7 +241,7 @@
</property>
</widget>
</item>
<item row="0" column="4">
<item row="1" column="4">
<widget class="QCheckBox" name="lnaExt">
<property name="toolTip">
<string>Extra LNA +14dB</string>
@ -246,7 +254,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -259,7 +267,7 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="interp">
<property name="maximumSize">
<size>
@ -308,11 +316,27 @@
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_samplerate">
<property name="spacing">
<number>3</number>
<widget class="Line" name="line_freq">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<item row="0" column="0">
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="sampleRateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@ -321,39 +345,41 @@
</sizepolicy>
</property>
<property name="text">
<string>Rate</string>
<string>SR</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="sampleRate">
<property name="maximumSize">
<item>
<widget class="ValueDial" name="sampleRate" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>16777215</height>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>Device sample rate</string>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="bbFiltLabel">
<item>
<widget class="QLabel" name="sampleRateUnits_2">
<property name="text">
<string>BBF</string>
<string>S/s</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="bbFilter">
<property name="toolTip">
<string>RF bandpas filter</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -365,10 +391,17 @@
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QLabel" name="sampleRateUnits">
<item>
<widget class="QLabel" name="bbFiltLabel">
<property name="text">
<string>kS/s</string>
<string>BBF</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bbFilter">
<property name="toolTip">
<string>RF bandpas filter</string>
</property>
</widget>
</item>
@ -383,6 +416,9 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_txvga" columnstretch="0,0,0">
<property name="topMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>

View File

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

View File

@ -29,12 +29,12 @@ void HackRFOutputSettings::resetToDefaults()
{
m_centerFrequency = 435000 * 1000;
m_LOppmTenths = 0;
m_devSampleRate = 2400000;
m_biasT = false;
m_log2Interp = 0;
m_lnaExt = false;
m_vgaGain = 22;
m_bandwidth = 1750000;
m_devSampleRate = 2400000;
}
QByteArray HackRFOutputSettings::serialize() const
@ -42,12 +42,12 @@ QByteArray HackRFOutputSettings::serialize() const
SimpleSerializer s(1);
s.writeS32(1, m_LOppmTenths);
s.writeU32(2, m_devSampleRate);
s.writeBool(3, m_biasT);
s.writeU32(4, m_log2Interp);
s.writeBool(5, m_lnaExt);
s.writeU32(6, m_vgaGain);
s.writeU32(7, m_bandwidth);
s.writeU64(8, m_devSampleRate);
return s.final();
}
@ -67,12 +67,12 @@ bool HackRFOutputSettings::deserialize(const QByteArray& data)
int intval;
d.readS32(1, &m_LOppmTenths, 0);
d.readU32(2, &m_devSampleRate, 2400000);
d.readBool(3, &m_biasT, false);
d.readU32(4, &m_log2Interp, 0);
d.readBool(5, &m_lnaExt, false);
d.readU32(6, &m_vgaGain, 30);
d.readU32(7, &m_bandwidth, 1750000);
d.readU64(8, &m_devSampleRate, 2400000);
return true;
}

View File

@ -22,10 +22,10 @@
struct HackRFOutputSettings {
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devSampleRate;
quint32 m_bandwidth;
quint32 m_vgaGain;
quint32 m_log2Interp;
quint64 m_devSampleRate;
bool m_biasT;
bool m_lnaExt;

View File

@ -247,13 +247,6 @@ void HackRFInputGui::on_iqImbalance_toggled(bool checked)
sendSettings();
}
void HackRFInputGui::on_sampleRate_currentIndexChanged(int index)
{
// int newrate = HackRFSampleRates::getRate(index);
// m_settings.m_devOldSampleRate = newrate;
// sendSettings();
}
void HackRFInputGui::on_bbFilter_currentIndexChanged(int index)
{
int newBandwidth = HackRFBandwidths::getBandwidth(index);
@ -279,7 +272,7 @@ void HackRFInputGui::on_centerFrequency_changed(quint64 value)
sendSettings();
}
void HackRFInputGui::on_newSampleRate_changed(quint64 value)
void HackRFInputGui::on_sampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;
sendSettings();

View File

@ -78,11 +78,10 @@ private:
private slots:
void handleDSPMessages();
void on_centerFrequency_changed(quint64 value);
void on_newSampleRate_changed(quint64 value);
void on_sampleRate_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_sampleRate_currentIndexChanged(int index);
void on_biasT_stateChanged(int state);
void on_decim_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);

View File

@ -29,7 +29,6 @@ void HackRFInputSettings::resetToDefaults()
{
m_centerFrequency = 435000 * 1000;
m_LOppmTenths = 0;
m_devOldSampleRate = 2400000;
m_biasT = false;
m_log2Decim = 0;
m_fcPos = FC_POS_CENTER;
@ -39,6 +38,7 @@ void HackRFInputSettings::resetToDefaults()
m_vgaGain = 16;
m_dcBlock = false;
m_iqCorrection = false;
m_devSampleRate = 2400000;
}
QByteArray HackRFInputSettings::serialize() const
@ -46,7 +46,6 @@ QByteArray HackRFInputSettings::serialize() const
SimpleSerializer s(1);
s.writeS32(1, m_LOppmTenths);
s.writeU32(2, m_devOldSampleRate);
s.writeBool(3, m_biasT);
s.writeU32(4, m_log2Decim);
s.writeS32(5, m_fcPos);
@ -76,7 +75,6 @@ bool HackRFInputSettings::deserialize(const QByteArray& data)
int intval;
d.readS32(1, &m_LOppmTenths, 0);
d.readU32(2, &m_devOldSampleRate, 2400000);
d.readBool(3, &m_biasT, false);
d.readU32(4, &m_log2Decim, 0);
d.readS32(5, &intval, 0);

View File

@ -28,7 +28,6 @@ struct HackRFInputSettings {
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devOldSampleRate;
quint32 m_bandwidth;
quint32 m_lnaGain;
quint32 m_vgaGain;