1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-11-10 08:10:25 -05:00
sdrangel/plugins/channelrx/demodlora/lorademodsettings.cpp

107 lines
3.2 KiB
C++
Raw Normal View History

2020-02-08 18:21:38 +01:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019-2020 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
2017-10-07 22:18:33 +02:00
#include "lorademodsettings.h"
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "lorademodsettings.h"
const int LoRaDemodSettings::bandwidths[] = {2500, 7813, 10417, 15625, 20833, 31250, 41667, 62500, 125000, 250000, 500000};
const int LoRaDemodSettings::nbBandwidths = 11;
2017-10-08 00:28:42 +02:00
2017-10-07 22:18:33 +02:00
LoRaDemodSettings::LoRaDemodSettings() :
2020-02-08 18:21:38 +01:00
m_inputFrequencyOffset(0),
2017-10-07 22:18:33 +02:00
m_channelMarker(0),
m_spectrumGUI(0)
{
resetToDefaults();
}
void LoRaDemodSettings::resetToDefaults()
{
2020-02-08 18:21:38 +01:00
m_bandwidthIndex = 5;
m_spreadFactor = 7;
m_deBits = 0;
2017-10-08 01:42:18 +02:00
m_rgbColor = QColor(255, 0, 255).rgb();
m_title = "LoRa Demodulator";
2017-10-07 22:18:33 +02:00
}
QByteArray LoRaDemodSettings::serialize() const
{
SimpleSerializer s(1);
2020-02-08 18:21:38 +01:00
s.writeS32(1, m_inputFrequencyOffset);
2017-10-08 00:28:42 +02:00
s.writeS32(2, m_bandwidthIndex);
2020-01-30 18:26:43 +01:00
s.writeS32(3, m_spreadFactor);
2017-10-07 22:18:33 +02:00
if (m_spectrumGUI) {
s.writeBlob(4, m_spectrumGUI->serialize());
}
if (m_channelMarker) {
s.writeBlob(5, m_channelMarker->serialize());
}
s.writeString(6, m_title);
2020-02-08 18:21:38 +01:00
s.writeS32(7, m_deBits);
2017-10-07 22:18:33 +02: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;
2020-02-08 18:21:38 +01:00
d.readS32(1, &m_inputFrequencyOffset, 0);
2017-10-08 00:28:42 +02:00
d.readS32(2, &m_bandwidthIndex, 0);
2020-01-30 18:26:43 +01:00
d.readS32(3, &m_spreadFactor, 0);
2017-10-07 22:18:33 +02:00
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");
2020-02-08 18:21:38 +01:00
d.readS32(7, &m_deBits, 0);
2017-10-07 22:18:33 +02:00
return true;
}
else
{
resetToDefaults();
return false;
}
}