mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-04 16:01:14 -05:00
LoRa demod: created settings class
This commit is contained in:
parent
71055aa8ad
commit
bb2c114dd2
@ -3,12 +3,14 @@ project(lora)
|
||||
set(lora_SOURCES
|
||||
lorademod.cpp
|
||||
lorademodgui.cpp
|
||||
lorademodsettings.cpp
|
||||
loraplugin.cpp
|
||||
)
|
||||
|
||||
set(lora_HEADERS
|
||||
lorademod.h
|
||||
lorademodgui.h
|
||||
lorademodsettings.h
|
||||
loraplugin.h
|
||||
)
|
||||
|
||||
|
@ -25,10 +25,12 @@ CONFIG(Debug):build_subdir = debug
|
||||
|
||||
SOURCES += lorademod.cpp\
|
||||
lorademodgui.cpp\
|
||||
lorademodsettings.cpp\
|
||||
loraplugin.cpp
|
||||
|
||||
HEADERS += lorademod.h\
|
||||
lorademodgui.h\
|
||||
lorademodsettings.h\
|
||||
loraplugin.h
|
||||
|
||||
FORMS += lorademodgui.ui
|
||||
|
76
plugins/channelrx/demodlora/lorademodsettings.cpp
Normal file
76
plugins/channelrx/demodlora/lorademodsettings.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "lorademodsettings.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include "dsp/dspengine.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "settings/serializable.h"
|
||||
#include "lorademodsettings.h"
|
||||
|
||||
LoRaDemodSettings::LoRaDemodSettings() :
|
||||
m_channelMarker(0),
|
||||
m_spectrumGUI(0)
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void LoRaDemodSettings::resetToDefaults()
|
||||
{
|
||||
m_bandwidth = 0;
|
||||
m_spread = 0;
|
||||
}
|
||||
|
||||
QByteArray LoRaDemodSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, m_centerFrequency);
|
||||
s.writeS32(2, m_bandwidth);
|
||||
s.writeS32(3, m_spread);
|
||||
|
||||
if (m_spectrumGUI) {
|
||||
s.writeBlob(4, m_spectrumGUI->serialize());
|
||||
}
|
||||
|
||||
if (m_channelMarker) {
|
||||
s.writeBlob(5, m_channelMarker->serialize());
|
||||
}
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool LoRaDemodSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if(!d.isValid())
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(d.getVersion() == 1)
|
||||
{
|
||||
QByteArray bytetmp;
|
||||
|
||||
d.readS32(1, &m_centerFrequency, 0);
|
||||
d.readS32(2, &m_bandwidth, 0);
|
||||
d.readS32(3, &m_spread, 0);
|
||||
|
||||
if (m_spectrumGUI) {
|
||||
d.readBlob(4, &bytetmp);
|
||||
m_spectrumGUI->deserialize(bytetmp);
|
||||
}
|
||||
|
||||
if (m_channelMarker) {
|
||||
d.readBlob(5, &bytetmp);
|
||||
m_channelMarker->deserialize(bytetmp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
30
plugins/channelrx/demodlora/lorademodsettings.h
Normal file
30
plugins/channelrx/demodlora/lorademodsettings.h
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#ifndef PLUGINS_CHANNELRX_DEMODLORA_LORADEMODSETTINGS_H_
|
||||
#define PLUGINS_CHANNELRX_DEMODLORA_LORADEMODSETTINGS_H_
|
||||
|
||||
#include <QByteArray>
|
||||
#include <stdint.h>
|
||||
|
||||
class Serializable;
|
||||
|
||||
struct LoRaDemodSettings
|
||||
{
|
||||
int m_centerFrequency;
|
||||
int m_bandwidth;
|
||||
int m_spread;
|
||||
uint32_t m_rgbColor;
|
||||
|
||||
Serializable *m_channelMarker;
|
||||
Serializable *m_spectrumGUI;
|
||||
|
||||
LoRaDemodSettings();
|
||||
void resetToDefaults();
|
||||
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
|
||||
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; }
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* PLUGINS_CHANNELRX_DEMODLORA_LORADEMODSETTINGS_H_ */
|
Loading…
Reference in New Issue
Block a user