mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
RTLSDR: reviewed apply settings
This commit is contained in:
parent
1174875551
commit
038d9c2f41
@ -125,7 +125,7 @@ QByteArray RTLSDRGui::serialize() const
|
||||
|
||||
bool RTLSDRGui::deserialize(const QByteArray& data)
|
||||
{
|
||||
if (m_settings.deserialize(data))
|
||||
if(m_settings.deserialize(data))
|
||||
{
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
|
@ -199,10 +199,13 @@ bool RTLSDRInput::handleMessage(const Message& message)
|
||||
if (MsgConfigureRTLSDR::match(message))
|
||||
{
|
||||
MsgConfigureRTLSDR& conf = (MsgConfigureRTLSDR&) message;
|
||||
qDebug() << "RTLSDRInput::handleMessage: MsgConfigureRTLSDR";
|
||||
|
||||
if (!applySettings(conf.getSettings(), false))
|
||||
bool success = applySettings(conf.getSettings(), false);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
qDebug("RTLSDR config error");
|
||||
qDebug("RTLSDRInput::handleMessage: config error");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -215,39 +218,18 @@ bool RTLSDRInput::handleMessage(const Message& message)
|
||||
|
||||
bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
bool forwardChange = false;
|
||||
|
||||
if ((m_settings.m_gain != settings.m_gain) || force)
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
||||
{
|
||||
m_settings.m_gain = settings.m_gain;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
if(rtlsdr_set_tuner_gain(m_dev, m_settings.m_gain) != 0)
|
||||
{
|
||||
qDebug("rtlsdr_set_tuner_gain() failed");
|
||||
}
|
||||
}
|
||||
m_settings.m_dcBlock = settings.m_dcBlock;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
|
||||
}
|
||||
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
||||
if ((m_settings.m_iqImbalance != settings.m_iqImbalance) || force)
|
||||
{
|
||||
forwardChange = true;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0)
|
||||
{
|
||||
qCritical("RTLSDRInput::applySettings: could not set sample rate: %d", settings.m_devSampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
||||
m_rtlSDRThread->setSamplerate(settings.m_devSampleRate);
|
||||
qDebug("RTLSDRInput::applySettings: sample rate set to %d", m_settings.m_devSampleRate);
|
||||
}
|
||||
}
|
||||
m_settings.m_iqImbalance = settings.m_iqImbalance;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
|
||||
}
|
||||
|
||||
if ((m_settings.m_loPpmCorrection != settings.m_loPpmCorrection) || force)
|
||||
@ -265,30 +247,45 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
||||
{
|
||||
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
||||
forwardChange = true;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0)
|
||||
{
|
||||
qCritical("RTLSDRInput::applySettings: could not set sample rate: %d", settings.m_devSampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rtlSDRThread->setSamplerate(settings.m_devSampleRate);
|
||||
qDebug("RTLSDRInput::applySettings: sample rate set to %d", m_settings.m_devSampleRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
{
|
||||
m_settings.m_log2Decim = settings.m_log2Decim;
|
||||
forwardChange = true;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
m_rtlSDRThread->setLog2Decimation(settings.m_log2Decim);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
{
|
||||
forwardChange = true;
|
||||
}
|
||||
|
||||
qint64 deviceCenterFrequency = m_settings.m_centerFrequency;
|
||||
qint64 f_img = deviceCenterFrequency;
|
||||
quint32 devSampleRate = m_settings.m_devSampleRate;
|
||||
quint32 devSampleRate =m_settings.m_devSampleRate;
|
||||
|
||||
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
|| (m_settings.m_fcPos != settings.m_fcPos))
|
||||
{
|
||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
||||
forwardChange = true;
|
||||
|
||||
if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == RTLSDRSettings::FC_POS_CENTER))
|
||||
{
|
||||
@ -337,38 +334,6 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_dev != 0)
|
||||
{
|
||||
qint64 centerFrequency = m_settings.m_centerFrequency + (m_settings.m_devSampleRate / 4);
|
||||
|
||||
if (m_settings.m_log2Decim == 0)
|
||||
{ // Little wooby-doop if no decimation
|
||||
centerFrequency = m_settings.m_centerFrequency;
|
||||
}
|
||||
else
|
||||
{
|
||||
centerFrequency = m_settings.m_centerFrequency + (m_settings.m_devSampleRate / 4);
|
||||
}
|
||||
|
||||
if (rtlsdr_set_center_freq( m_dev, centerFrequency ) != 0)
|
||||
{
|
||||
qDebug("rtlsdr_set_center_freq(%lld) failed", m_settings.m_centerFrequency);
|
||||
}
|
||||
}*/
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
||||
{
|
||||
m_settings.m_dcBlock = settings.m_dcBlock;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqImbalance != settings.m_iqImbalance) || force)
|
||||
{
|
||||
m_settings.m_iqImbalance = settings.m_iqImbalance;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqImbalance);
|
||||
}
|
||||
|
||||
if (forwardChange)
|
||||
{
|
||||
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
|
||||
|
Loading…
Reference in New Issue
Block a user