1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-09 01:56:05 -05:00
sdrangel/plugins/channelrx/demodlora/lorademodsettings.cpp

87 lines
1.8 KiB
C++
Raw Normal View History

2017-10-07 16:18:33 -04:00
#include "lorademodsettings.h"
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "lorademodsettings.h"
2017-10-07 18:28:42 -04:00
const int LoRaDemodSettings::bandwidths[] = {7813,15625,20833,31250,62500};
const int LoRaDemodSettings::nb_bandwidths = 5;
2017-10-07 16:18:33 -04:00
LoRaDemodSettings::LoRaDemodSettings() :
m_centerFrequency(0),
2017-10-07 16:18:33 -04:00
m_channelMarker(0),
m_spectrumGUI(0)
{
resetToDefaults();
}
void LoRaDemodSettings::resetToDefaults()
{
2017-10-07 18:28:42 -04:00
m_bandwidthIndex = 0;
2017-10-07 16:18:33 -04:00
m_spread = 0;
2017-10-07 19:42:18 -04:00
m_rgbColor = QColor(255, 0, 255).rgb();
m_title = "LoRa Demodulator";
2017-10-07 16:18:33 -04:00
}
QByteArray LoRaDemodSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_centerFrequency);
2017-10-07 18:28:42 -04:00
s.writeS32(2, m_bandwidthIndex);
2017-10-07 16:18:33 -04:00
s.writeS32(3, m_spread);
if (m_spectrumGUI) {
s.writeBlob(4, m_spectrumGUI->serialize());
}
if (m_channelMarker) {
s.writeBlob(5, m_channelMarker->serialize());
}
s.writeString(6, m_title);
2017-10-07 16:18:33 -04:00
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);
2017-10-07 18:28:42 -04:00
d.readS32(2, &m_bandwidthIndex, 0);
2017-10-07 16:18:33 -04:00
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);
}
d.readString(6, &m_title, "LoRa Demodulator");
2017-10-07 16:18:33 -04:00
return true;
}
else
{
resetToDefaults();
return false;
}
}