2016-10-02 07:18:07 -04:00
|
|
|
|
2017-10-31 03:24:05 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2015-01-10 19:12:58 -05:00
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
2016-10-03 09:55:16 -04:00
|
|
|
|
2015-01-10 19:12:58 -05:00
|
|
|
#include "ui_lorademodgui.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
2015-08-17 02:29:34 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2017-10-07 18:28:42 -04:00
|
|
|
|
|
|
|
#include "lorademod.h"
|
|
|
|
#include "lorademodgui.h"
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2017-11-08 19:03:05 -05:00
|
|
|
LoRaDemodGUI* LoRaDemodGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
2015-01-10 19:12:58 -05:00
|
|
|
{
|
2017-11-08 19:03:05 -05:00
|
|
|
LoRaDemodGUI* gui = new LoRaDemodGUI(pluginAPI, deviceUISet, rxChannel);
|
2015-01-10 19:12:58 -05:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoRaDemodGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoRaDemodGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
QString LoRaDemodGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2015-07-18 20:07:40 -04:00
|
|
|
qint64 LoRaDemodGUI::getCenterFrequency() const {
|
2015-08-24 17:56:12 -04:00
|
|
|
return m_channelMarker.getCenterFrequency();
|
2015-07-18 20:07:40 -04:00
|
|
|
}
|
|
|
|
|
2015-09-28 21:35:14 -04:00
|
|
|
void LoRaDemodGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2015-01-10 19:12:58 -05:00
|
|
|
void LoRaDemodGUI::resetToDefaults()
|
|
|
|
{
|
2017-10-07 18:28:42 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray LoRaDemodGUI::serialize() const
|
|
|
|
{
|
2017-10-07 18:28:42 -04:00
|
|
|
return m_settings.serialize();
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LoRaDemodGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
2017-10-07 18:28:42 -04:00
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
bool LoRaDemodGUI::handleMessage(const Message& message)
|
2015-01-10 19:12:58 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) message;
|
2015-01-10 19:12:58 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoRaDemodGUI::viewChanged()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoRaDemodGUI::on_BW_valueChanged(int value)
|
|
|
|
{
|
2017-10-07 18:28:42 -04:00
|
|
|
if (value < 0) {
|
|
|
|
m_settings.m_bandwidthIndex = 0;
|
|
|
|
} else if (value < LoRaDemodSettings::nb_bandwidths) {
|
|
|
|
m_settings.m_bandwidthIndex = value;
|
|
|
|
} else {
|
|
|
|
m_settings.m_bandwidthIndex = LoRaDemodSettings::nb_bandwidths - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int thisBW = LoRaDemodSettings::bandwidths[value];
|
2015-01-12 09:25:16 -05:00
|
|
|
ui->BWText->setText(QString("%1 Hz").arg(thisBW));
|
2015-08-24 17:56:12 -04:00
|
|
|
m_channelMarker.setBandwidth(thisBW);
|
2017-10-07 18:28:42 -04:00
|
|
|
|
2015-01-10 19:12:58 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void LoRaDemodGUI::on_Spread_valueChanged(int value)
|
2015-01-12 09:25:16 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) value;
|
2015-01-12 09:25:16 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void LoRaDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
2015-01-10 19:12:58 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
|
|
|
|
2017-11-08 19:03:05 -05:00
|
|
|
LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
2015-01-10 19:12:58 -05:00
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::LoRaDemodGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2015-08-24 17:56:12 -04:00
|
|
|
m_channelMarker(this),
|
2015-08-18 19:02:52 -04:00
|
|
|
m_doApplySettings(true)
|
2015-01-10 19:12:58 -05:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
|
2017-11-08 19:03:05 -05:00
|
|
|
m_LoRaDemod = (LoRaDemod*) rxChannel; //new LoRaDemod(m_deviceUISet->m_deviceSourceAPI);
|
2020-05-15 17:12:46 -04:00
|
|
|
m_spectrumVis = m_LoRaDemod->getSpectrumVis();
|
|
|
|
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2015-01-12 09:25:16 -05:00
|
|
|
ui->glSpectrum->setCenterFrequency(16000);
|
|
|
|
ui->glSpectrum->setSampleRate(32000);
|
2015-01-10 19:12:58 -05:00
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
|
2017-11-13 19:45:13 -05:00
|
|
|
m_channelMarker.setMovable(false);
|
2015-08-24 17:56:12 -04:00
|
|
|
m_channelMarker.setVisible(true);
|
2016-05-16 13:37:53 -04:00
|
|
|
|
2017-11-13 19:45:13 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(viewChanged()));
|
2016-05-16 13:37:53 -04:00
|
|
|
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceUISet->addRollupWidget(this);
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2020-05-15 17:30:44 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
2015-01-10 19:12:58 -05:00
|
|
|
|
2017-10-07 19:42:18 -04:00
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
|
|
|
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
LoRaDemodGUI::~LoRaDemodGUI()
|
|
|
|
{
|
2017-10-31 17:37:57 -04:00
|
|
|
m_deviceUISet->removeRxChannelInstance(this);
|
2017-11-08 19:03:05 -05:00
|
|
|
delete m_LoRaDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
|
2015-01-10 19:12:58 -05:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-08-18 19:02:52 -04:00
|
|
|
void LoRaDemodGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2017-10-07 18:28:42 -04:00
|
|
|
void LoRaDemodGUI::applySettings(bool force)
|
2015-01-10 19:12:58 -05:00
|
|
|
{
|
2015-08-23 22:09:36 -04:00
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2017-10-07 19:42:18 -04:00
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
LoRaDemod::MsgConfigureLoRaDemod* message = LoRaDemod::MsgConfigureLoRaDemod::create( m_settings, force);
|
|
|
|
m_LoRaDemod->getInputMessageQueue()->push(message);
|
2015-08-23 22:09:36 -04:00
|
|
|
}
|
2015-01-10 19:12:58 -05:00
|
|
|
}
|
2017-10-07 18:28:42 -04:00
|
|
|
|
|
|
|
void LoRaDemodGUI::displaySettings()
|
|
|
|
{
|
|
|
|
int thisBW = LoRaDemodSettings::bandwidths[m_settings.m_bandwidthIndex];
|
2017-10-07 19:42:18 -04:00
|
|
|
|
|
|
|
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);
|
2017-10-11 19:21:30 -04:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->BWText->setText(QString("%1 Hz").arg(thisBW));
|
|
|
|
ui->BW->setValue(m_settings.m_bandwidthIndex);
|
|
|
|
blockApplySettings(false);
|
2017-10-07 18:28:42 -04:00
|
|
|
}
|