HackRF input: continuous sample rate setting

This commit is contained in:
f4exb 2017-04-01 13:08:41 +02:00
parent ad6b33c280
commit 813d79a115
10 changed files with 119 additions and 94 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
sdrangel (3.3.3-1) unstable; urgency=medium
* HackRF, BladeRF, RTLSDR plugins: continuous sample rate setting
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Sun, 16 Apr 2017 23:14:18 +0100
sdrangel (3.3.2-1) unstable; urgency=medium
* ATV plugins: added 405 lines, 20 and 16 FPS modes

View File

@ -287,11 +287,11 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
if (rc != HACKRF_SUCCESS)
{
qCritical("HackRFInput::applySettings: could not set sample rate TO %d kS/s: %s", m_settings.m_devSampleRate, hackrf_error_name(rc));
qCritical("HackRFInput::applySettings: could not set sample rate TO %llu S/s: %s", m_settings.m_devSampleRate, hackrf_error_name(rc));
}
else
{
qDebug("HackRFInput::applySettings: sample rate set to %d kS/s", m_settings.m_devSampleRate);
qDebug("HackRFInput::applySettings: sample rate set to %llu S/s", m_settings.m_devSampleRate);
m_hackRFThread->setSamplerate(m_settings.m_devSampleRate);
}
}
@ -469,8 +469,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
qDebug() << "HackRFInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
<< " device center freq: " << deviceCenterFrequency << " Hz"
<< " device sample rate: " << m_settings.m_devSampleRate << "Hz"
<< " Actual sample rate: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim) << "Hz";
<< " device sample rate: " << m_settings.m_devSampleRate << "S/s"
<< " Actual sample rate: " << m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim) << "S/s";
return true;
}

View File

@ -43,6 +43,9 @@ HackRFInputGui::HackRFInputGui(DeviceSourceAPI *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);
@ -51,7 +54,6 @@ HackRFInputGui::HackRFInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_sampleSource = new HackRFInput(m_deviceAPI);
displaySampleRates();
displayBandwidths();
m_deviceAPI->setSource(m_sampleSource);
@ -165,7 +167,7 @@ void HackRFInputGui::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 HackRFInputGui::displaySettings()
@ -178,8 +180,7 @@ void HackRFInputGui::displaySettings()
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
unsigned int sampleRateIndex = HackRFSampleRates::getRateIndex(m_settings.m_devSampleRate);
ui->sampleRate->setCurrentIndex(sampleRateIndex);
ui->sampleRate->setValue(m_settings.m_devSampleRate);
ui->biasT->setChecked(m_settings.m_biasT);
@ -198,29 +199,6 @@ void HackRFInputGui::displaySettings()
ui->vga->setValue(m_settings.m_vgaGain);
}
void HackRFInputGui::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 HackRFInputGui::displayBandwidths()
{
int savedIndex = HackRFBandwidths::getBandwidthIndex(m_settings.m_bandwidth/1000);
@ -250,12 +228,6 @@ void HackRFInputGui::sendSettings()
m_updateTimer.start(100);
}
void HackRFInputGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
sendSettings();
}
void HackRFInputGui::on_LOppm_valueChanged(int value)
{
m_settings.m_LOppmTenths = value;
@ -277,9 +249,9 @@ void HackRFInputGui::on_iqImbalance_toggled(bool checked)
void HackRFInputGui::on_sampleRate_currentIndexChanged(int index)
{
int newrate = HackRFSampleRates::getRate(index);
m_settings.m_devSampleRate = newrate;
sendSettings();
// int newrate = HackRFSampleRates::getRate(index);
// m_settings.m_devOldSampleRate = newrate;
// sendSettings();
}
void HackRFInputGui::on_bbFilter_currentIndexChanged(int index)
@ -301,6 +273,18 @@ void HackRFInputGui::on_lnaExt_stateChanged(int state)
sendSettings();
}
void HackRFInputGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
sendSettings();
}
void HackRFInputGui::on_newSampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;
sendSettings();
}
void HackRFInputGui::on_decim_currentIndexChanged(int index)
{
if ((index <0) || (index > 6))

View File

@ -71,7 +71,6 @@ private:
int m_lastEngineState;
void displaySettings();
void displaySampleRates();
void displayBandwidths();
void sendSettings();
void updateSampleRateAndFrequency();
@ -79,6 +78,7 @@ private:
private slots:
void handleDSPMessages();
void on_centerFrequency_changed(quint64 value);
void on_newSampleRate_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);

View File

@ -2,24 +2,16 @@
<ui version="4.0">
<class>HackRFInputGui</class>
<widget class="QWidget" name="HackRFInputGui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<height>210</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>310</width>
<height>300</height>
</size>
</property>
<property name="font">
@ -49,6 +41,9 @@
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QVBoxLayout" name="deviceUILayout">
<item>
@ -118,16 +113,10 @@
</item>
<item>
<widget class="ValueDial" name="centerFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
<height>50</height>
</size>
</property>
<property name="font">
@ -171,6 +160,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>
@ -214,6 +209,12 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_corr">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item row="0" column="1">
<widget class="ButtonSwitch" name="dcOffset">
<property name="toolTip">
@ -290,11 +291,8 @@
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_samplerate">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="sampleRateLayout">
<item>
<widget class="QLabel" name="sampleRateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@ -302,40 +300,52 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</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="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="toolTip">
<string>Device sample rate</string>
</property>
<zorder>sampleRateLabel</zorder>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="bbFiltLabel">
<item>
<widget class="QLabel" name="rateUnits">
<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_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -347,10 +357,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>
@ -358,6 +375,12 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_decim" columnstretch="0,0,0,0,0">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
@ -478,6 +501,12 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_lna">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
@ -539,6 +568,9 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_vga" columnstretch="0,0,0">
<property name="topMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
@ -592,7 +624,7 @@
<item>
<layout class="QHBoxLayout" name="padLayout">
<item>
<spacer name="verticaPadlSpacer">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

View File

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

View File

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

View File

@ -28,12 +28,13 @@ struct HackRFInputSettings {
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devSampleRate;
quint32 m_devOldSampleRate;
quint32 m_bandwidth;
quint32 m_lnaGain;
quint32 m_vgaGain;
quint32 m_log2Decim;
fcPos_t m_fcPos;
quint64 m_devSampleRate;
bool m_biasT;
bool m_lnaExt;
bool m_dcBlock;

View File

@ -84,7 +84,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version 3.3.2 - Copyright (C) 2015-2017 Edouard Griffiths, F4EXB. &lt;/p&gt;&lt;p&gt;Code at &lt;a href=&quot;https://github.com/f4exb/sdrangel&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/f4exb/sdrangel&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Many thanks to the original developers:&lt;/p&gt;&lt;p&gt;The osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt;&lt;p&gt;Christian Daniel from maintech GmbH.&lt;/p&gt;&lt;p&gt;John Greb (hexameron) for the contributions in &lt;a href=&quot;https://github.com/hexameron/rtl-sdrangelove&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;RTL-SDRangelove&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The following rules apply to the SDRangel main application and libsdrbase:&lt;br/&gt;This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program. If not, see &lt;a href=&quot;http://www.gnu.org/licenses/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses/&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;For the license of installed plugins, look into the plugin list.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version 3.3.3 - Copyright (C) 2015-2017 Edouard Griffiths, F4EXB. &lt;/p&gt;&lt;p&gt;Code at &lt;a href=&quot;https://github.com/f4exb/sdrangel&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/f4exb/sdrangel&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Many thanks to the original developers:&lt;/p&gt;&lt;p&gt;The osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt;&lt;p&gt;Christian Daniel from maintech GmbH.&lt;/p&gt;&lt;p&gt;John Greb (hexameron) for the contributions in &lt;a href=&quot;https://github.com/hexameron/rtl-sdrangelove&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;RTL-SDRangelove&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The following rules apply to the SDRangel main application and libsdrbase:&lt;br/&gt;This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program. If not, see &lt;a href=&quot;http://www.gnu.org/licenses/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses/&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;For the license of installed plugins, look into the plugin list.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@ -453,9 +453,9 @@ void MainWindow::createStatusBar()
{
QString qtVersionStr = QString("Qt %1 ").arg(QT_VERSION_STR);
#if QT_VERSION >= 0x050400
m_showSystemWidget = new QLabel("SDRangel v3.3.2 " + qtVersionStr + QSysInfo::prettyProductName(), this);
m_showSystemWidget = new QLabel("SDRangel v3.3.3 " + qtVersionStr + QSysInfo::prettyProductName(), this);
#else
m_showSystemWidget = new QLabel("SDRangel v3.3.2 " + qtVersionStr, this);
m_showSystemWidget = new QLabel("SDRangel v3.3.3 " + qtVersionStr, this);
#endif
statusBar()->addPermanentWidget(m_showSystemWidget);