From 0d5ecaca9f49e06f9daea42bf2a802f59e934b54 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 15 May 2020 23:12:46 +0200 Subject: [PATCH] Websocket spectrum: adapted LoRa demod --- plugins/channelrx/demodlora/lorademod.cpp | 4 +++- plugins/channelrx/demodlora/lorademod.h | 4 +++- plugins/channelrx/demodlora/lorademodgui.cpp | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/channelrx/demodlora/lorademod.cpp b/plugins/channelrx/demodlora/lorademod.cpp index fadc006bb..a8a6c52d7 100644 --- a/plugins/channelrx/demodlora/lorademod.cpp +++ b/plugins/channelrx/demodlora/lorademod.cpp @@ -35,12 +35,14 @@ const QString LoRaDemod::m_channelId = "LoRaDemod"; LoRaDemod::LoRaDemod(DeviceAPI* deviceAPI) : ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink), - m_deviceAPI(deviceAPI) + m_deviceAPI(deviceAPI), + m_spectrumVis(SDR_RX_SCALEF) { setObjectName(m_channelId); m_thread = new QThread(this); m_basebandSink = new LoRaDemodBaseband(); + m_basebandSink->setSpectrumSink(&m_spectrumVis); m_basebandSink->moveToThread(m_thread); applySettings(m_settings, true); diff --git a/plugins/channelrx/demodlora/lorademod.h b/plugins/channelrx/demodlora/lorademod.h index cca244ed6..53ce37d19 100644 --- a/plugins/channelrx/demodlora/lorademod.h +++ b/plugins/channelrx/demodlora/lorademod.h @@ -22,6 +22,7 @@ #include #include "dsp/basebandsamplesink.h" +#include "dsp/spectrumvis.h" #include "channel/channelapi.h" #include "util/message.h" @@ -58,7 +59,7 @@ public: LoRaDemod(DeviceAPI* deviceAPI); virtual ~LoRaDemod(); virtual void destroy() { delete this; } - void setSpectrumSink(BasebandSampleSink* sampleSink) { m_basebandSink->setSpectrumSink(sampleSink); } + SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO); virtual void start(); @@ -90,6 +91,7 @@ private: QThread *m_thread; LoRaDemodBaseband* m_basebandSink; LoRaDemodSettings m_settings; + SpectrumVis m_spectrumVis; int m_basebandSampleRate; void applySettings(const LoRaDemodSettings& settings, bool force = false); diff --git a/plugins/channelrx/demodlora/lorademodgui.cpp b/plugins/channelrx/demodlora/lorademodgui.cpp index f08cc493b..6d82449ff 100644 --- a/plugins/channelrx/demodlora/lorademodgui.cpp +++ b/plugins/channelrx/demodlora/lorademodgui.cpp @@ -119,9 +119,9 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_LoRaDemod = (LoRaDemod*) rxChannel; //new LoRaDemod(m_deviceUISet->m_deviceSourceAPI); - m_LoRaDemod->setSpectrumSink(m_spectrumVis); + m_spectrumVis = m_LoRaDemod->getSpectrumVis(); + m_spectrumVis->setGLSpectrum(ui->glSpectrum); ui->glSpectrum->setCenterFrequency(16000); ui->glSpectrum->setSampleRate(32000); @@ -150,7 +150,6 @@ LoRaDemodGUI::~LoRaDemodGUI() { m_deviceUISet->removeRxChannelInstance(this); delete m_LoRaDemod; // TODO: check this: when the GUI closes it has to delete the demodulator - delete m_spectrumVis; delete ui; }