diff --git a/plugins/channelrx/demodlora/lorademod.cpp b/plugins/channelrx/demodlora/lorademod.cpp
index a4c333703..ab64a9621 100644
--- a/plugins/channelrx/demodlora/lorademod.cpp
+++ b/plugins/channelrx/demodlora/lorademod.cpp
@@ -16,23 +16,29 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#include "../../channelrx/demodlora/lorademod.h"
-#include
#include
#include
#include
-#include "../../channelrx/demodlora/lorabits.h"
+
+#include
+#include "dsp/threadedbasebandsamplesink.h"
+#include
+
+#include "lorademod.h"
+#include "lorabits.h"
MESSAGE_CLASS_DEFINITION(LoRaDemod::MsgConfigureLoRaDemod, Message)
+MESSAGE_CLASS_DEFINITION(LoRaDemod::MsgConfigureChannelizer, Message)
-LoRaDemod::LoRaDemod(BasebandSampleSink* sampleSink) :
- m_sampleSink(sampleSink),
+LoRaDemod::LoRaDemod(DeviceSourceAPI* deviceAPI) :
+ m_deviceAPI(deviceAPI),
+ m_sampleSink(0),
m_settingsMutex(QMutex::Recursive)
{
setObjectName("LoRaDemod");
- m_Bandwidth = 7813;
+ m_Bandwidth = LoRaDemodSettings::bandwidths[0];
m_sampleRate = 96000;
m_frequency = 0;
m_nco.setFreq(m_frequency, m_sampleRate);
@@ -48,6 +54,10 @@ LoRaDemod::LoRaDemod(BasebandSampleSink* sampleSink) :
m_time = 0;
m_tune = 0;
+ m_channelizer = new DownChannelizer(this);
+ m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer);
+ m_deviceAPI->addThreadedSink(m_threadedChannelizer);
+
loraFilter = new sfft(LORA_SFFT_LEN);
negaFilter = new sfft(LORA_SFFT_LEN);
@@ -68,12 +78,10 @@ LoRaDemod::~LoRaDemod()
delete [] history;
if (finetune)
delete [] finetune;
-}
-void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
-{
- Message* cmd = MsgConfigureLoRaDemod::create(Bandwidth);
- messageQueue->push(cmd);
+ m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
+ delete m_threadedChannelizer;
+ delete m_channelizer;
}
void LoRaDemod::dumpRaw()
@@ -302,18 +310,34 @@ bool LoRaDemod::handleMessage(const Message& cmd)
return true;
}
+ else if (MsgConfigureChannelizer::match(cmd))
+ {
+ MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
+
+ m_channelizer->configure(m_channelizer->getInputMessageQueue(),
+ cfg.getSampleRate(),
+ cfg.getCenterFrequency());
+
+ qDebug() << "LoRaDemod::handleMessage: MsgConfigureChannelizer: sampleRate: " << cfg.getSampleRate()
+ << " centerFrequency: " << cfg.getCenterFrequency();
+
+ return true;
+ }
else if (MsgConfigureLoRaDemod::match(cmd))
{
MsgConfigureLoRaDemod& cfg = (MsgConfigureLoRaDemod&) cmd;
m_settingsMutex.lock();
- m_Bandwidth = cfg.getBandwidth();
+ LoRaDemodSettings settings = cfg.getSettings();
+
+ m_Bandwidth = LoRaDemodSettings::bandwidths[settings.m_bandwidthIndex];
m_interpolator.create(16, m_sampleRate, m_Bandwidth/1.9);
m_settingsMutex.unlock();
- qDebug() << " MsgConfigureLoRaDemod: m_Bandwidth: " << m_Bandwidth;
+ m_settings = settings;
+ qDebug() << "LoRaDemod::handleMessage: MsgConfigureLoRaDemod: m_Bandwidth: " << m_Bandwidth;
return true;
}
diff --git a/plugins/channelrx/demodlora/lorademod.h b/plugins/channelrx/demodlora/lorademod.h
index 4e7c5db7b..032016e25 100644
--- a/plugins/channelrx/demodlora/lorademod.h
+++ b/plugins/channelrx/demodlora/lorademod.h
@@ -18,26 +18,78 @@
#ifndef INCLUDE_LoRaDEMOD_H
#define INCLUDE_LoRaDEMOD_H
-#include
#include
#include
+
+#include
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/message.h"
#include "dsp/fftfilt.h"
+#include "lorademodsettings.h"
+
#define DATA_BITS (6)
#define SAMPLEBITS (DATA_BITS + 2)
#define SPREADFACTOR (1 << SAMPLEBITS)
#define LORA_SFFT_LEN (SPREADFACTOR / 2)
#define LORA_SQUELCH (3)
+class DeviceSourceAPI;
+class ThreadedBasebandSampleSink;
+class DownChannelizer;
+
class LoRaDemod : public BasebandSampleSink {
public:
- LoRaDemod(BasebandSampleSink* sampleSink);
- virtual ~LoRaDemod();
+ class MsgConfigureLoRaDemod : public Message {
+ MESSAGE_CLASS_DECLARATION
- void configure(MessageQueue* messageQueue, Real Bandwidth);
+ public:
+ const LoRaDemodSettings& getSettings() const { return m_settings; }
+ bool getForce() const { return m_force; }
+
+ static MsgConfigureLoRaDemod* create(const LoRaDemodSettings& settings, bool force)
+ {
+ return new MsgConfigureLoRaDemod(settings, force);
+ }
+
+ private:
+ LoRaDemodSettings m_settings;
+ bool m_force;
+
+ MsgConfigureLoRaDemod(const LoRaDemodSettings& settings, bool force) :
+ Message(),
+ m_settings(settings),
+ m_force(force)
+ { }
+ };
+
+ class MsgConfigureChannelizer : public Message {
+ MESSAGE_CLASS_DECLARATION
+
+ public:
+ int getSampleRate() const { return m_sampleRate; }
+ int getCenterFrequency() const { return m_centerFrequency; }
+
+ static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
+ {
+ return new MsgConfigureChannelizer(sampleRate, centerFrequency);
+ }
+
+ private:
+ int m_sampleRate;
+ int m_centerFrequency;
+
+ MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
+ Message(),
+ m_sampleRate(sampleRate),
+ m_centerFrequency(centerFrequency)
+ { }
+ };
+
+ LoRaDemod(DeviceSourceAPI* deviceAPI);
+ virtual ~LoRaDemod();
+ void setSpectrumSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO);
virtual void start();
@@ -53,26 +105,10 @@ private:
void hamming6(char* inout, int size);
void prng6(char* inout, int size);
- class MsgConfigureLoRaDemod : public Message {
- MESSAGE_CLASS_DECLARATION
-
- public:
- Real getBandwidth() const { return m_Bandwidth; }
-
- static MsgConfigureLoRaDemod* create(Real Bandwidth)
- {
- return new MsgConfigureLoRaDemod(Bandwidth);
- }
-
- private:
- Real m_Bandwidth;
-
- MsgConfigureLoRaDemod(Real Bandwidth) :
- Message(),
- m_Bandwidth(Bandwidth)
- {
- }
- };
+ DeviceSourceAPI *m_deviceAPI;
+ ThreadedBasebandSampleSink* m_threadedChannelizer;
+ DownChannelizer* m_channelizer;
+ LoRaDemodSettings m_settings;
Real m_Bandwidth;
int m_sampleRate;
diff --git a/plugins/channelrx/demodlora/lorademodgui.cpp b/plugins/channelrx/demodlora/lorademodgui.cpp
index 926dc3ee5..1db479e77 100644
--- a/plugins/channelrx/demodlora/lorademodgui.cpp
+++ b/plugins/channelrx/demodlora/lorademodgui.cpp
@@ -4,8 +4,6 @@
#include
#include
-#include "dsp/threadedbasebandsamplesink.h"
-#include "ui_lorademodgui.h"
#include "ui_lorademodgui.h"
#include "dsp/spectrumvis.h"
#include "gui/glspectrum.h"
@@ -137,21 +135,19 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWi
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
- m_LoRaDemod = new LoRaDemod(m_spectrumVis);
- m_channelizer = new DownChannelizer(m_LoRaDemod);
- m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer);
- m_deviceAPI->addThreadedSink(m_threadedChannelizer);
+ m_LoRaDemod = new LoRaDemod(m_deviceAPI);
+ m_LoRaDemod->setSpectrumSink(m_spectrumVis);
ui->glSpectrum->setCenterFrequency(16000);
ui->glSpectrum->setSampleRate(32000);
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
- setTitleColor(Qt::magenta);
-
- m_channelMarker.setColor(Qt::magenta);
- m_channelMarker.setBandwidth(LoRaDemodSettings::bandwidths[0]);
- m_channelMarker.setCenterFrequency(0);
+// setTitleColor(Qt::magenta);
+//
+// m_channelMarker.setColor(Qt::magenta);
+// m_channelMarker.setBandwidth(LoRaDemodSettings::bandwidths[0]);
+// m_channelMarker.setCenterFrequency(0);
m_channelMarker.setVisible(true);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
@@ -160,17 +156,18 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWi
m_deviceAPI->addChannelMarker(&m_channelMarker);
m_deviceAPI->addRollupWidget(this);
- ui->spectrumGUI->setBuddies(m_channelizer->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
+ ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
- applySettings();
+ m_settings.setChannelMarker(&m_channelMarker);
+ m_settings.setSpectrumGUI(ui->spectrumGUI);
+
+ displaySettings();
+ applySettings(true);
}
LoRaDemodGUI::~LoRaDemodGUI()
{
m_deviceAPI->removeChannelInstance(this);
- m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
- delete m_threadedChannelizer;
- delete m_channelizer;
delete m_LoRaDemod;
delete m_spectrumVis;
delete ui;
@@ -185,11 +182,15 @@ void LoRaDemodGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
- m_channelizer->configure(m_channelizer->getInputMessageQueue(),
- LoRaDemodSettings::bandwidths[m_settings.m_bandwidthIndex],
- m_channelMarker.getCenterFrequency());
+ setTitleColor(m_channelMarker.getColor());
- m_LoRaDemod->configure(m_LoRaDemod->getInputMessageQueue(), m_settings.m_bandwidthIndex);
+ LoRaDemod::MsgConfigureChannelizer* channelConfigMsg = LoRaDemod::MsgConfigureChannelizer::create(
+ LoRaDemodSettings::bandwidths[m_settings.m_bandwidthIndex],
+ m_channelMarker.getCenterFrequency());
+ m_LoRaDemod->getInputMessageQueue()->push(channelConfigMsg);
+
+ LoRaDemod::MsgConfigureLoRaDemod* message = LoRaDemod::MsgConfigureLoRaDemod::create( m_settings, force);
+ m_LoRaDemod->getInputMessageQueue()->push(message);
}
}
@@ -201,4 +202,11 @@ void LoRaDemodGUI::displaySettings()
ui->BW->setValue(m_settings.m_bandwidthIndex);
m_channelMarker.setBandwidth(thisBW);
blockApplySettings(false);
+
+ m_channelMarker.blockSignals(true);
+ m_channelMarker.setBandwidth(thisBW);
+ m_channelMarker.setCenterFrequency(0);
+ m_channelMarker.setColor(m_settings.m_rgbColor);
+ setTitleColor(m_settings.m_rgbColor);
+ m_channelMarker.blockSignals(false);
}
diff --git a/plugins/channelrx/demodlora/lorademodgui.h b/plugins/channelrx/demodlora/lorademodgui.h
index 59b116c57..812aedc86 100644
--- a/plugins/channelrx/demodlora/lorademodgui.h
+++ b/plugins/channelrx/demodlora/lorademodgui.h
@@ -10,8 +10,6 @@
class PluginAPI;
class DeviceSourceAPI;
-class ThreadedBasebandSampleSink;
-class DownChannelizer;
class LoRaDemod;
class SpectrumVis;
@@ -55,8 +53,6 @@ private:
bool m_basicSettingsShown;
bool m_doApplySettings;
- ThreadedBasebandSampleSink* m_threadedChannelizer;
- DownChannelizer* m_channelizer;
LoRaDemod* m_LoRaDemod;
SpectrumVis* m_spectrumVis;
MessageQueue m_inputMessageQueue;
diff --git a/plugins/channelrx/demodlora/lorademodsettings.cpp b/plugins/channelrx/demodlora/lorademodsettings.cpp
index 67ef5fb2a..c00d9a63e 100644
--- a/plugins/channelrx/demodlora/lorademodsettings.cpp
+++ b/plugins/channelrx/demodlora/lorademodsettings.cpp
@@ -21,6 +21,7 @@ void LoRaDemodSettings::resetToDefaults()
{
m_bandwidthIndex = 0;
m_spread = 0;
+ m_rgbColor = QColor(255, 0, 255).rgb();
}
QByteArray LoRaDemodSettings::serialize() const