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

RTLSDR: DC offset and IQ imbalance buttons. Standard device ID in plugin

This commit is contained in:
f4exb 2015-10-01 05:05:46 +02:00
parent 3cc73fbf61
commit df2077caa7
6 changed files with 170 additions and 119 deletions

View File

@ -62,6 +62,18 @@ void RTLSDRGui::setCenterFrequency(qint64 centerFrequency)
sendSettings();
}
void RTLSDRGui::on_dcOffset_toggled(bool checked)
{
m_settings.m_dcBlock = checked;
sendSettings();
}
void RTLSDRGui::on_iqImbalance_toggled(bool checked)
{
m_settings.m_iqImbalance = checked;
sendSettings();
}
QByteArray RTLSDRGui::serialize() const
{
return m_settings.serialize();
@ -115,6 +127,8 @@ void RTLSDRGui::handleSourceMessages()
void RTLSDRGui::displaySettings()
{
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
ui->samplerateText->setText(tr("%1k").arg(m_settings.m_devSampleRate / 1000));
unsigned int sampleRateIndex = RTLSDRSampleRates::getRateIndex(m_settings.m_devSampleRate);
ui->samplerate->setValue(sampleRateIndex);

View File

@ -44,6 +44,8 @@ private:
private slots:
void on_centerFrequency_changed(quint64 value);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_decim_valueChanged(int value);
void on_ppm_valueChanged(int value);
void on_gain_valueChanged(int value);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>198</width>
<height>173</height>
<width>247</width>
<height>189</height>
</rect>
</property>
<property name="sizePolicy">
@ -36,7 +36,7 @@
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -96,6 +96,80 @@
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_ppm">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="1">
<widget class="QSlider" name="ppm">
<property name="minimum">
<number>-99</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="ppmText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="ppmLabel">
<property name="text">
<string>LO ppm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_corr">
<item row="0" column="1">
<widget class="ButtonSwitch" name="dcOffset">
<property name="toolTip">
<string>Automatic DC offset removal</string>
</property>
<property name="text">
<string>DC offset</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="ButtonSwitch" name="iqImbalance">
<property name="toolTip">
<string>Automatic IQ imbalance correction</string>
</property>
<property name="text">
<string>IQ imbalance</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="corrLabel">
<property name="text">
<string>Auto corr</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
@ -104,10 +178,26 @@
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="gridLayout_rate">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="2">
<widget class="QLabel" name="samplerateText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1024k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="samplerate">
<property name="toolTip">
@ -125,7 +215,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="samplerateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -137,8 +227,38 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_decim" columnstretch="0,0,0">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_decim">
<property name="text">
<string>Dec.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="decim">
<property name="maximum">
<number>4</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="samplerateText">
<widget class="QLabel" name="decimText">
<property name="minimumSize">
<size>
<width>40</width>
@ -146,7 +266,7 @@
</size>
</property>
<property name="text">
<string>1024k</string>
<string>16</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -163,12 +283,12 @@
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_gain">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="gainLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -225,110 +345,7 @@
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_1">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="1">
<widget class="QSlider" name="ppm">
<property name="minimum">
<number>-99</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="ppmText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>ppm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_decim">
<property name="text">
<string>Dec.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="decim">
<property name="maximum">
<number>4</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="decimText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>16</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_direct">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
@ -364,7 +381,7 @@
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -297,6 +297,18 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
}
}
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
{
m_settings.m_dcBlock = settings.m_dcBlock;
DSPEngine::instance()->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
}
if ((m_settings.m_iqImbalance != settings.m_iqImbalance) || force)
{
m_settings.m_iqImbalance = settings.m_iqImbalance;
DSPEngine::instance()->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
}
if (forwardChange)
{
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);

View File

@ -15,6 +15,8 @@ const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
QString("https://github.com/f4exb/sdrangel")
};
const QString RTLSDRPlugin::m_deviceTypeID = RTLSDR_DEVICE_TYPE_ID;
RTLSDRPlugin::RTLSDRPlugin(QObject* parent) :
QObject(parent)
{
@ -29,7 +31,7 @@ void RTLSDRPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
m_pluginAPI->registerSampleSource("org.osmocom.sdr.samplesource.rtl-sdr", this);
m_pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
PluginInterface::SampleSourceDevices RTLSDRPlugin::enumSampleSources()
@ -47,10 +49,10 @@ PluginInterface::SampleSourceDevices RTLSDRPlugin::enumSampleSources()
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
continue;
QString displayedName(QString("RTL-SDR #%1 (%2 #%3)").arg(i + 1).arg(product).arg(serial));
QString displayedName(QString("RTL-SDR #%1 %2").arg(i).arg(serial));
result.append(SampleSourceDevice(displayedName,
"org.osmocom.sdr.samplesource.rtl-sdr",
m_deviceTypeID,
QString(serial),
i));
}
@ -59,7 +61,7 @@ PluginInterface::SampleSourceDevices RTLSDRPlugin::enumSampleSources()
PluginGUI* RTLSDRPlugin::createSampleSourcePluginGUI(const QString& sourceId)
{
if(sourceId == "org.osmocom.sdr.samplesource.rtl-sdr") {
if(sourceId == m_deviceTypeID) {
RTLSDRGui* gui = new RTLSDRGui(m_pluginAPI);
m_pluginAPI->setInputGUI(gui);
return gui;

View File

@ -4,10 +4,12 @@
#include <QObject>
#include "plugin/plugininterface.h"
#define RTLSDR_DEVICE_TYPE_ID "sdrangel.samplesource.rtlsdr"
class RTLSDRPlugin : public QObject, public PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "org.osmocom.sdr.samplesource.rtl-sdr")
Q_PLUGIN_METADATA(IID RTLSDR_DEVICE_TYPE_ID)
public:
explicit RTLSDRPlugin(QObject* parent = NULL);
@ -18,6 +20,8 @@ public:
virtual SampleSourceDevices enumSampleSources();
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId);
static const QString m_deviceTypeID;
private:
static const PluginDescriptor m_pluginDescriptor;