summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daniel <cd@maintech.de>2013-11-04 22:01:28 +0100
committerChristian Daniel <cd@maintech.de>2013-11-04 22:01:28 +0100
commitba220b717a1ce135ccc756d1382b4bb38ee50f47 (patch)
treeda309f1ca4b537bfd6768d8f31b9a04c5414c4ee
parent221869a8986cdec8717db7f540278fbb904f8118 (diff)
NFMDemod: ported to reworked API - credits go to Dimitri "horizon" Stolnikov
-rw-r--r--plugins/channel/CMakeLists.txt2
-rw-r--r--plugins/channel/nfm/nfmdemod.cpp4
-rw-r--r--plugins/channel/nfm/nfmdemodgui.cpp53
-rw-r--r--plugins/channel/nfm/nfmdemodgui.h14
-rw-r--r--plugins/channel/nfm/nfmdemodgui.ui411
-rw-r--r--plugins/channel/nfm/nfmplugin.cpp18
-rw-r--r--plugins/channel/nfm/nfmplugin.h4
7 files changed, 290 insertions, 216 deletions
diff --git a/plugins/channel/CMakeLists.txt b/plugins/channel/CMakeLists.txt
index 19c7962..e59574e 100644
--- a/plugins/channel/CMakeLists.txt
+++ b/plugins/channel/CMakeLists.txt
@@ -1,5 +1,5 @@
project(demod)
-#add_subdirectory(nfm)
+add_subdirectory(nfm)
add_subdirectory(tcpsrc)
#add_subdirectory(tetra)
diff --git a/plugins/channel/nfm/nfmdemod.cpp b/plugins/channel/nfm/nfmdemod.cpp
index fde579b..843a6aa 100644
--- a/plugins/channel/nfm/nfmdemod.cpp
+++ b/plugins/channel/nfm/nfmdemod.cpp
@@ -140,6 +140,8 @@ bool NFMDemod::handleMessage(Message* cmd)
cmd->completed();
return true;
} else {
- return false;
+ if(m_sampleSink != NULL)
+ return m_sampleSink->handleMessage(cmd);
+ else return false;
}
}
diff --git a/plugins/channel/nfm/nfmdemodgui.cpp b/plugins/channel/nfm/nfmdemodgui.cpp
index d507cfd..53f2de0 100644
--- a/plugins/channel/nfm/nfmdemodgui.cpp
+++ b/plugins/channel/nfm/nfmdemodgui.cpp
@@ -11,6 +11,7 @@
#include "gui/glspectrum.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
+#include "gui/basicchannelsettingswidget.h"
const int NFMDemodGUI::m_rfBW[] = {
5000, 6250, 8330, 10000, 12500, 15000, 20000, 25000, 40000
@@ -18,22 +19,18 @@ const int NFMDemodGUI::m_rfBW[] = {
NFMDemodGUI* NFMDemodGUI::create(PluginAPI* pluginAPI)
{
- QDockWidget* dock = pluginAPI->createMainWindowDock(Qt::RightDockWidgetArea, tr("NFM Demodulator"));
- dock->setObjectName(QString::fromUtf8("NFM Demodulator"));
- NFMDemodGUI* gui = new NFMDemodGUI(pluginAPI, dock);
- dock->setWidget(gui);
+ NFMDemodGUI* gui = new NFMDemodGUI(pluginAPI);
return gui;
}
void NFMDemodGUI::destroy()
{
- delete m_dockWidget;
+ delete this;
}
-void NFMDemodGUI::setWidgetName(const QString& name)
+void NFMDemodGUI::setName(const QString& name)
{
- qDebug("NFM: %s", qPrintable(name));
- m_dockWidget->setObjectName(name);
+ setObjectName(name);
}
void NFMDemodGUI::resetToDefaults()
@@ -42,6 +39,7 @@ void NFMDemodGUI::resetToDefaults()
ui->afBW->setValue(3);
ui->volume->setValue(20);
ui->squelch->setValue(-40);
+ ui->spectrumGUI->resetToDefaults();
applySettings();
}
@@ -53,6 +51,8 @@ QByteArray NFMDemodGUI::serialize() const
s.writeS32(3, ui->afBW->value());
s.writeS32(4, ui->volume->value());
s.writeS32(5, ui->squelch->value());
+ s.writeBlob(6, ui->spectrumGUI->serialize());
+ s.writeU32(7, m_channelMarker->getColor().rgb());
return s.final();
}
@@ -66,6 +66,8 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
}
if(d.getVersion() == 1) {
+ QByteArray bytetmp;
+ quint32 u32tmp;
qint32 tmp;
d.readS32(1, &tmp, 0);
m_channelMarker->setCenterFrequency(tmp);
@@ -77,6 +79,10 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
ui->volume->setValue(tmp);
d.readS32(5, &tmp, -40);
ui->squelch->setValue(tmp);
+ d.readBlob(6, &bytetmp);
+ ui->spectrumGUI->deserialize(bytetmp);
+ if(d.readU32(7, &u32tmp))
+ m_channelMarker->setColor(u32tmp);
applySettings();
return true;
} else {
@@ -120,13 +126,34 @@ void NFMDemodGUI::on_squelch_valueChanged(int value)
applySettings();
}
-NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QDockWidget* dockWidget, QWidget* parent) :
- PluginGUI(parent),
+
+void NFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
+{
+ /*
+ if((widget == ui->spectrumContainer) && (m_nfmDemod != NULL))
+ m_nfmDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown);
+ */
+}
+
+void NFMDemodGUI::onMenuDoubleClicked()
+{
+ if(!m_basicSettingsShown) {
+ m_basicSettingsShown = true;
+ BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(m_channelMarker, this);
+ bcsw->show();
+ }
+}
+
+NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
+ RollupWidget(parent),
ui(new Ui::NFMDemodGUI),
m_pluginAPI(pluginAPI),
- m_dockWidget(dockWidget)
+ m_basicSettingsShown(false)
{
ui->setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
+ connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_audioFifo = new AudioFifo(4, 44100 / 4);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
@@ -150,11 +177,14 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QDockWidget* dockWidget, QWidget*
connect(m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
m_pluginAPI->addChannelMarker(m_channelMarker);
+ ui->spectrumGUI->setBuddies(m_threadedSampleSink->getMessageQueue(), m_spectrumVis, ui->glSpectrum);
+
applySettings();
}
NFMDemodGUI::~NFMDemodGUI()
{
+ m_pluginAPI->removeChannelInstance(this);
m_pluginAPI->removeAudioSource(m_audioFifo);
m_pluginAPI->removeSampleSink(m_threadedSampleSink);
delete m_threadedSampleSink;
@@ -168,6 +198,7 @@ NFMDemodGUI::~NFMDemodGUI()
void NFMDemodGUI::applySettings()
{
+ setTitleColor(m_channelMarker->getColor());
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(),
44100,
m_channelMarker->getCenterFrequency());
diff --git a/plugins/channel/nfm/nfmdemodgui.h b/plugins/channel/nfm/nfmdemodgui.h
index 1381b5a..edfb808 100644
--- a/plugins/channel/nfm/nfmdemodgui.h
+++ b/plugins/channel/nfm/nfmdemodgui.h
@@ -1,10 +1,9 @@
#ifndef INCLUDE_NFMDEMODGUI_H
#define INCLUDE_NFMDEMODGUI_H
+#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
-class QDockWidget;
-
class PluginAPI;
class ChannelMarker;
@@ -18,14 +17,14 @@ namespace Ui {
class NFMDemodGUI;
}
-class NFMDemodGUI : public PluginGUI {
+class NFMDemodGUI : public RollupWidget, public PluginGUI {
Q_OBJECT
public:
static NFMDemodGUI* create(PluginAPI* pluginAPI);
void destroy();
- void setWidgetName(const QString& name);
+ void setName(const QString& name);
void resetToDefaults();
QByteArray serialize() const;
@@ -39,12 +38,14 @@ private slots:
void on_afBW_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
+ void onWidgetRolled(QWidget* widget, bool rollDown);
+ void onMenuDoubleClicked();
private:
Ui::NFMDemodGUI* ui;
PluginAPI* m_pluginAPI;
- QDockWidget* m_dockWidget;
ChannelMarker* m_channelMarker;
+ bool m_basicSettingsShown;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedSampleSink;
@@ -52,10 +53,9 @@ private:
NFMDemod* m_nfmDemod;
SpectrumVis* m_spectrumVis;
- static const QString m_demodName;
static const int m_rfBW[];
- explicit NFMDemodGUI(PluginAPI* pluginAPI, QDockWidget* dockWidget, QWidget* parent = NULL);
+ explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
~NFMDemodGUI();
void applySettings();
diff --git a/plugins/channel/nfm/nfmdemodgui.ui b/plugins/channel/nfm/nfmdemodgui.ui
index 5087276..64cc449 100644
--- a/plugins/channel/nfm/nfmdemodgui.ui
+++ b/plugins/channel/nfm/nfmdemodgui.ui
@@ -1,202 +1,229 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NFMDemodGUI</class>
- <widget class="QWidget" name="NFMDemodGUI">
+ <widget class="RollupWidget" name="NFMDemodGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>208</width>
- <height>226</height>
+ <width>302</width>
+ <height>410</height>
</rect>
</property>
<property name="windowTitle">
- <string>Form</string>
+ <string>NFM Demodulator</string>
</property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>3</number>
+ <widget class="QWidget" name="settingsContainer" native="true">
+ <property name="geometry">
+ <rect>
+ <x>35</x>
+ <y>35</y>
+ <width>242</width>
+ <height>96</height>
+ </rect>
</property>
- <property name="margin">
- <number>0</number>
+ <property name="windowTitle">
+ <string>Settings</string>
</property>
- <item>
- <widget class="GLSpectrum" name="glSpectrum" native="true">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>150</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>2</number>
- </property>
- <property name="spacing">
- <number>3</number>
- </property>
- <item row="0" column="1">
- <widget class="QSlider" name="rfBW">
- <property name="maximum">
- <number>8</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="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>RF Bandwidth</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>AF Bandwidth</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Squelch</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Volume</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="rfBWText">
- <property name="minimumSize">
- <size>
- <width>50</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>12.5kHz</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QSlider" name="afBW">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>20</number>
- </property>
- <property name="pageStep">
- <number>1</number>
- </property>
- <property name="value">
- <number>3</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSlider" name="volume">
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="value">
- <number>20</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QSlider" name="squelch">
- <property name="minimum">
- <number>-100</number>
- </property>
- <property name="maximum">
- <number>0</number>
- </property>
- <property name="value">
- <number>-40</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QLabel" name="afBWText">
- <property name="minimumSize">
- <size>
- <width>50</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>3 kHz</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QLabel" name="volumeText">
- <property name="minimumSize">
- <size>
- <width>50</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>2.0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QLabel" name="squelchText">
- <property name="minimumSize">
- <size>
- <width>50</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>-40dB</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>RF Bandwidth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSlider" name="rfBW">
+ <property name="maximum">
+ <number>8</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="rfBWText">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>12.5kHz</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>AF Bandwidth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="afBW">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>20</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>3</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="afBWText">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>3 kHz</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Volume</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSlider" name="volume">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="volumeText">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>2.0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Squelch</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSlider" name="squelch">
+ <property name="minimum">
+ <number>-100</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-40</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QLabel" name="squelchText">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>-40dB</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="spectrumContainer" native="true">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>140</y>
+ <width>218</width>
+ <height>184</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Channel Spectrum</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="GLSpectrum" name="glSpectrum" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>150</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
+ </item>
+ </layout>
+ </widget>
</widget>
<customwidgets>
<customwidget>
@@ -205,6 +232,18 @@
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>GLSpectrumGUI</class>
+ <extends>QWidget</extends>
+ <header>gui/glspectrumgui.h</header>
+ <container>1</container>
+ </customwidget>
+ <customwidget>
+ <class>RollupWidget</class>
+ <extends>QWidget</extends>
+ <header>gui/rollupwidget.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/plugins/channel/nfm/nfmplugin.cpp b/plugins/channel/nfm/nfmplugin.cpp
index f252a3a..57b5b92 100644
--- a/plugins/channel/nfm/nfmplugin.cpp
+++ b/plugins/channel/nfm/nfmplugin.cpp
@@ -28,16 +28,17 @@ void NFMPlugin::initPlugin(PluginAPI* pluginAPI)
m_pluginAPI = pluginAPI;
// register NFM demodulator
- QAction* action = new QAction(tr("&NFM"), this);
+ QAction* action = new QAction(tr("&NFM Demodulator"), this);
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceNFM()));
- m_pluginAPI->registerDemodulator("de.maintech.sdrangelove.demod.nfm", this, action);
+ m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.nfm", this, action);
}
-PluginGUI* NFMPlugin::createDemod(const QString& demodName)
+PluginGUI* NFMPlugin::createChannel(const QString& channelName)
{
- if(demodName == "de.maintech.sdrangelove.demod.nfm") {
- PluginGUI* gui = NFMDemodGUI::create(m_pluginAPI);
- m_pluginAPI->registerDemodulatorInstance("de.maintech.sdrangelove.demod.nfm", gui);
+ if(channelName == "de.maintech.sdrangelove.channel.nfm") {
+ NFMDemodGUI* gui = NFMDemodGUI::create(m_pluginAPI);
+ m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.nfm", gui);
+ m_pluginAPI->addChannelRollup(gui);
return gui;
} else {
return NULL;
@@ -46,6 +47,7 @@ PluginGUI* NFMPlugin::createDemod(const QString& demodName)
void NFMPlugin::createInstanceNFM()
{
- m_pluginAPI->registerDemodulatorInstance("de.maintech.sdrangelove.demod.nfm", NFMDemodGUI::create(m_pluginAPI));
+ NFMDemodGUI* gui = NFMDemodGUI::create(m_pluginAPI);
+ m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.nfm", gui);
+ m_pluginAPI->addChannelRollup(gui);
}
-
diff --git a/plugins/channel/nfm/nfmplugin.h b/plugins/channel/nfm/nfmplugin.h
index 78db600..0cd345b 100644
--- a/plugins/channel/nfm/nfmplugin.h
+++ b/plugins/channel/nfm/nfmplugin.h
@@ -7,7 +7,7 @@
class NFMPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
- Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.demod.nfm")
+ Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.channel.nfm")
public:
explicit NFMPlugin(QObject* parent = NULL);
@@ -15,7 +15,7 @@ public:
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
- PluginGUI* createDemod(const QString& demodName);
+ PluginGUI* createChannel(const QString& channelName);
private:
static const PluginDescriptor m_pluginDescriptor;