LimeRFE USB support: added persistent calibration map

This commit is contained in:
f4exb 2020-01-16 18:23:29 +01:00
parent 6f14d21b1f
commit ab4f18684e
5 changed files with 138 additions and 0 deletions

View File

@ -131,6 +131,8 @@ set(sdrbase_SOURCES
device/deviceuserargs.cpp
device/deviceutils.cpp
limerfe/limerfeusbcalib.cpp
settings/preferences.cpp
settings/preset.cpp
settings/mainsettings.cpp
@ -270,6 +272,8 @@ set(sdrbase_HEADERS
device/deviceuserargs.h
device/deviceutils.h
limerfe/limerfeusbcalib.h
plugin/plugininstancegui.h
plugin/plugininterface.h
plugin/pluginapi.h

View File

@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QByteArray>
#include <QDataStream>
#include <QIODevice>
#include "util/simpleserializer.h"
#include "limerfeusbcalib.h"
QByteArray LimeRFEUSBCalib::serialize() const
{
SimpleSerializer s(1);
QByteArray data;
serializeCalibMap(data);
s.writeBlob(1, data);
return s.final();
}
bool LimeRFEUSBCalib::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if (!d.isValid()) {
return false;
}
if (d.getVersion() == 1)
{
QByteArray data;
d.readBlob(1, &data);
deserializeCalibMap(data);
return true;
}
else
{
return false;
}
}
void LimeRFEUSBCalib::serializeCalibMap(QByteArray& data) const
{
QDataStream *stream = new QDataStream(&data, QIODevice::WriteOnly);
*stream << m_calibrations;
delete stream;
}
void LimeRFEUSBCalib::deserializeCalibMap(QByteArray& data)
{
QDataStream readStream(&data, QIODevice::ReadOnly);
readStream >> m_calibrations;
}

View File

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_LIMERFE_LIMERFEUSBCALIB_H_
#define SDRBASE_LIMERFE_LIMERFEUSBCALIB_H_
#include <QMap>
#include "export.h"
class QByteArray;
class SDRBASE_API LimeRFEUSBCalib
{
public:
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
enum ChannelRange
{
WidebandLow, //!< 1 - 1000 MHz
WidebandHigh, //!< 1000 - 4000 MHz
HAM_30MHz, //!< Up to 30 MHz
HAM_50_70MHz,
HAM_144_146MHz,
HAM_220_225MHz,
HAM_430_440MHz,
HAM_902_928MHz,
HAM_1240_1325MHz,
HAM_2300_2450MHz,
HAM_3300_3500MHz,
CellularBand1,
CellularBand2,
CellularBand7,
CellularBand38
};
QMap<int, int> m_calibrations; //!< Channel range to calibration value in centi-Bels
private:
void serializeCalibMap(QByteArray& data) const;
void deserializeCalibMap(QByteArray& data);
};
#endif // SDRBASE_LIMERFE_LIMERFEUSBCALIB_H_

View File

@ -93,6 +93,7 @@ void MainSettings::load()
}
m_hardwareDeviceUserArgs.deserialize(qUncompress(QByteArray::fromBase64(s.value("hwDeviceUserArgs").toByteArray())));
m_limeRFEUSBCalib.deserialize(qUncompress(QByteArray::fromBase64(s.value("limeRFEUSBCalib").toByteArray())));
}
void MainSettings::save() const
@ -137,6 +138,7 @@ void MainSettings::save() const
}
s.setValue("hwDeviceUserArgs", qCompress(m_hardwareDeviceUserArgs.serialize()).toBase64());
s.setValue("limeRFEUSBCalib", qCompress(m_limeRFEUSBCalib.serialize()).toBase64());
}
void MainSettings::initialize()

View File

@ -3,6 +3,7 @@
#include <QString>
#include "device/deviceuserargs.h"
#include "limerfe/limerfeusbcalib.h"
#include "preferences.h"
#include "preset.h"
#include "export.h"
@ -69,6 +70,7 @@ public:
bool getUseLogFile() const { return m_preferences.getUseLogFile(); }
const QString& getLogFileName() const { return m_preferences.getLogFileName(); }
DeviceUserArgs& getDeviceUserArgs() { return m_hardwareDeviceUserArgs; }
LimeRFEUSBCalib& getLimeRFEUSBCalib() { return m_limeRFEUSBCalib; }
const AudioDeviceManager *getAudioDeviceManager() const { return m_audioDeviceManager; }
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager) { m_audioDeviceManager = audioDeviceManager; }
@ -83,6 +85,7 @@ protected:
typedef QList<Command*> Commands;
Commands m_commands;
DeviceUserArgs m_hardwareDeviceUserArgs;
LimeRFEUSBCalib m_limeRFEUSBCalib;
AMBEEngine *m_ambeEngine;
};