1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

New preset design (single). Applied to Airspy. Interim state #1

This commit is contained in:
Edouard Griffiths 2015-09-30 13:23:20 +02:00
parent 51e4792d77
commit 4657790fd6
5 changed files with 29 additions and 105 deletions

View File

@ -4,7 +4,7 @@ set(airspy_SOURCES
airspygui.cpp
airspyinput.cpp
airspyplugin.cpp
airspyserializer.cpp
airspysettings.cpp
airspythread.cpp
)
@ -12,7 +12,7 @@ set(airspy_HEADERS
airspygui.h
airspyinput.h
airspyplugin.h
airspyserializer.h
airspysettings.h
airspythread.h
)

View File

@ -226,13 +226,13 @@ void AirspyGui::on_decim_valueChanged(int value)
void AirspyGui::on_fcPos_currentIndexChanged(int index)
{
if (index == 0) {
m_settings.m_fcPos = AirspyInput::FC_POS_INFRA;
m_settings.m_fcPos = AirspySettings::FC_POS_INFRA;
sendSettings();
} else if (index == 1) {
m_settings.m_fcPos = AirspyInput::FC_POS_SUPRA;
m_settings.m_fcPos = AirspySettings::FC_POS_SUPRA;
sendSettings();
} else if (index == 2) {
m_settings.m_fcPos = AirspyInput::FC_POS_CENTER;
m_settings.m_fcPos = AirspySettings::FC_POS_CENTER;
sendSettings();
}
}

View File

@ -55,7 +55,7 @@ private:
Ui::AirspyGui* ui;
PluginAPI* m_pluginAPI;
AirspyInput::Settings m_settings;
AirspySettings m_settings;
QTimer m_updateTimer;
std::vector<uint32_t> m_rates;
SampleSource* m_sampleSource;

View File

@ -29,72 +29,6 @@
MESSAGE_CLASS_DEFINITION(AirspyInput::MsgConfigureAirspy, Message)
MESSAGE_CLASS_DEFINITION(AirspyInput::MsgReportAirspy, Message)
AirspyInput::Settings::Settings() :
m_centerFrequency(435000*1000),
m_devSampleRateIndex(0),
m_LOppmTenths(0),
m_lnaGain(14),
m_mixerGain(15),
m_vgaGain(4),
m_log2Decim(0),
m_fcPos(FC_POS_CENTER),
m_biasT(false)
{
}
void AirspyInput::Settings::resetToDefaults()
{
m_centerFrequency = 435000*1000;
m_devSampleRateIndex = 0;
m_LOppmTenths = 0;
m_lnaGain = 14;
m_mixerGain = 15;
m_vgaGain = 4;
m_log2Decim = 0;
m_fcPos = FC_POS_CENTER;
m_biasT = false;
}
QByteArray AirspyInput::Settings::serialize() const
{
AirspySerializer::AirspyData data;
data.m_data.m_frequency = m_centerFrequency;
data.m_LOppmTenths = m_LOppmTenths;
data.m_sampleRateIndex = m_devSampleRateIndex;
data.m_log2Decim = m_log2Decim;
data.m_fcPos = (qint32) m_fcPos;
data.m_lnaGain = m_lnaGain;
data.m_mixerGain = m_mixerGain;
data.m_vgaGain = m_vgaGain;
data.m_biasT = m_biasT;
QByteArray byteArray;
AirspySerializer::writeSerializedData(data, byteArray);
return byteArray;
}
bool AirspyInput::Settings::deserialize(const QByteArray& serializedData)
{
AirspySerializer::AirspyData data;
bool valid = AirspySerializer::readSerializedData(serializedData, data);
m_centerFrequency = data.m_data.m_frequency;
m_LOppmTenths = data.m_LOppmTenths;
m_devSampleRateIndex = data.m_sampleRateIndex;
m_log2Decim = data.m_log2Decim;
m_fcPos = (fcPos_t) data.m_fcPos;
m_lnaGain = data.m_lnaGain;
m_mixerGain = data.m_mixerGain;
m_vgaGain = data.m_vgaGain;
m_biasT = data.m_biasT;
return valid;
}
AirspyInput::AirspyInput() :
m_settings(),
m_dev(0),
@ -281,7 +215,7 @@ void AirspyInput::setCenterFrequency(quint64 freq_hz)
}
}
bool AirspyInput::applySettings(const Settings& settings, bool force)
bool AirspyInput::applySettings(const AirspySettings& settings, bool force)
{
QMutexLocker mutexLocker(&m_mutex);
@ -290,6 +224,18 @@ bool AirspyInput::applySettings(const Settings& settings, bool force)
qDebug() << "AirspyInput::applySettings";
if (m_settings.m_dcBlock != settings.m_dcBlock)
{
m_settings.m_dcBlock = settings.m_dcBlock;
DSPEngine::instance()->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if (m_settings.m_iqCorrection != settings.m_iqCorrection)
{
m_settings.m_iqCorrection = settings.m_iqCorrection;
DSPEngine::instance()->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force)
{
forwardChange = true;
@ -352,19 +298,19 @@ bool AirspyInput::applySettings(const Settings& settings, bool force)
m_settings.m_centerFrequency = settings.m_centerFrequency;
m_settings.m_LOppmTenths = settings.m_LOppmTenths;
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == FC_POS_CENTER))
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == AirspySettings::FC_POS_CENTER))
{
deviceCenterFrequency = m_settings.m_centerFrequency;
f_img = deviceCenterFrequency;
}
else
{
if (m_settings.m_fcPos == FC_POS_INFRA)
if (m_settings.m_fcPos == AirspySettings::FC_POS_INFRA)
{
deviceCenterFrequency = m_settings.m_centerFrequency + (devSampleRate / 4);
f_img = deviceCenterFrequency + devSampleRate/2;
}
else if (m_settings.m_fcPos == FC_POS_SUPRA)
else if (m_settings.m_fcPos == AirspySettings::FC_POS_SUPRA)
{
deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4);
f_img = deviceCenterFrequency - devSampleRate/2;

View File

@ -18,6 +18,7 @@
#define INCLUDE_AIRSPYINPUT_H
#include "dsp/samplesource.h"
#include "airspysettings.h"
#include <libairspy/airspy.h>
#include <QString>
@ -25,44 +26,21 @@ class AirspyThread;
class AirspyInput : public SampleSource {
public:
typedef enum {
FC_POS_INFRA = 0,
FC_POS_SUPRA,
FC_POS_CENTER
} fcPos_t;
struct Settings {
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devSampleRateIndex;
quint32 m_lnaGain;
quint32 m_mixerGain;
quint32 m_vgaGain;
quint32 m_log2Decim;
fcPos_t m_fcPos;
bool m_biasT;
Settings();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
class MsgConfigureAirspy : public Message {
MESSAGE_CLASS_DECLARATION
public:
const Settings& getSettings() const { return m_settings; }
const AirspySettings& getSettings() const { return m_settings; }
static MsgConfigureAirspy* create(const Settings& settings)
static MsgConfigureAirspy* create(const AirspySettings& settings)
{
return new MsgConfigureAirspy(settings);
}
private:
Settings m_settings;
AirspySettings m_settings;
MsgConfigureAirspy(const Settings& settings) :
MsgConfigureAirspy(const AirspySettings& settings) :
Message(),
m_settings(settings)
{ }
@ -103,12 +81,12 @@ public:
virtual bool handleMessage(const Message& message);
private:
bool applySettings(const Settings& settings, bool force);
bool applySettings(const AirspySettings& settings, bool force);
struct airspy_device *open_airspy_from_sequence(int sequence);
void setCenterFrequency(quint64 freq);
QMutex m_mutex;
Settings m_settings;
AirspySettings m_settings;
struct airspy_device* m_dev;
AirspyThread* m_airspyThread;
QString m_deviceDescription;