From eb08ef55b346c25abc1d67f570bcef997c21c047 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Oct 2015 06:34:08 +0200 Subject: [PATCH] Fixed Fc position adjustment for Airspy and HackRF --- plugins/samplesource/airspy/airspyinput.cpp | 31 +++++++++++---------- plugins/samplesource/hackrf/hackrfinput.cpp | 31 +++++++++++---------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/plugins/samplesource/airspy/airspyinput.cpp b/plugins/samplesource/airspy/airspyinput.cpp index 0d313d7ad..2c07fa4f5 100644 --- a/plugins/samplesource/airspy/airspyinput.cpp +++ b/plugins/samplesource/airspy/airspyinput.cpp @@ -276,40 +276,30 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) } } - if ((m_settings.m_fcPos != settings.m_fcPos) || force) - { - m_settings.m_fcPos = settings.m_fcPos; - - if(m_dev != 0) - { - m_airspyThread->setFcPos((int) m_settings.m_fcPos); - qDebug() << "AirspyInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; - } - } - qint64 deviceCenterFrequency = m_settings.m_centerFrequency; qint64 f_img = deviceCenterFrequency; quint32 devSampleRate = m_sampleRates[m_settings.m_devSampleRateIndex]; if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) || - (m_settings.m_LOppmTenths != settings.m_LOppmTenths)) + (m_settings.m_LOppmTenths != settings.m_LOppmTenths) || + (m_settings.m_fcPos != settings.m_fcPos)) { m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_LOppmTenths = settings.m_LOppmTenths; - if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == AirspySettings::FC_POS_CENTER)) + if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == AirspySettings::FC_POS_CENTER)) { deviceCenterFrequency = m_settings.m_centerFrequency; f_img = deviceCenterFrequency; } else { - if (m_settings.m_fcPos == AirspySettings::FC_POS_INFRA) + if (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 == AirspySettings::FC_POS_SUPRA) + else if (settings.m_fcPos == AirspySettings::FC_POS_SUPRA) { deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4); f_img = deviceCenterFrequency - devSampleRate/2; @@ -330,6 +320,17 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) forwardChange = true; } + if ((m_settings.m_fcPos != settings.m_fcPos) || force) + { + m_settings.m_fcPos = settings.m_fcPos; + + if(m_dev != 0) + { + m_airspyThread->setFcPos((int) m_settings.m_fcPos); + qDebug() << "AirspyInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; + } + } + if ((m_settings.m_lnaGain != settings.m_lnaGain) || force) { m_settings.m_lnaGain = settings.m_lnaGain; diff --git a/plugins/samplesource/hackrf/hackrfinput.cpp b/plugins/samplesource/hackrf/hackrfinput.cpp index 3df7d04e0..74b27bb8c 100644 --- a/plugins/samplesource/hackrf/hackrfinput.cpp +++ b/plugins/samplesource/hackrf/hackrfinput.cpp @@ -233,40 +233,30 @@ bool HackRFInput::applySettings(const HackRFSettings& settings, bool force) } } - if ((m_settings.m_fcPos != settings.m_fcPos) || force) - { - m_settings.m_fcPos = settings.m_fcPos; - - if(m_dev != 0) - { - m_hackRFThread->setFcPos((int) m_settings.m_fcPos); - qDebug() << "HackRFInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; - } - } - qint64 deviceCenterFrequency = m_settings.m_centerFrequency; qint64 f_img = deviceCenterFrequency; quint32 devSampleRate = HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex] * 1000; if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) || - (m_settings.m_LOppmTenths != settings.m_LOppmTenths)) + (m_settings.m_LOppmTenths != settings.m_LOppmTenths) || + (m_settings.m_fcPos != settings.m_fcPos)) { m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_LOppmTenths = settings.m_LOppmTenths; - if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == HackRFSettings::FC_POS_CENTER)) + if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == HackRFSettings::FC_POS_CENTER)) { deviceCenterFrequency = m_settings.m_centerFrequency; f_img = deviceCenterFrequency; } else { - if (m_settings.m_fcPos == HackRFSettings::FC_POS_INFRA) + if (settings.m_fcPos == HackRFSettings::FC_POS_INFRA) { deviceCenterFrequency = m_settings.m_centerFrequency + (devSampleRate / 4); f_img = deviceCenterFrequency + devSampleRate/2; } - else if (m_settings.m_fcPos == HackRFSettings::FC_POS_SUPRA) + else if (settings.m_fcPos == HackRFSettings::FC_POS_SUPRA) { deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4); f_img = deviceCenterFrequency - devSampleRate/2; @@ -287,6 +277,17 @@ bool HackRFInput::applySettings(const HackRFSettings& settings, bool force) forwardChange = true; } + if ((m_settings.m_fcPos != settings.m_fcPos) || force) + { + m_settings.m_fcPos = settings.m_fcPos; + + if(m_dev != 0) + { + m_hackRFThread->setFcPos((int) m_settings.m_fcPos); + qDebug() << "HackRFInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; + } + } + if ((m_settings.m_lnaGain != settings.m_lnaGain) || force) { m_settings.m_lnaGain = settings.m_lnaGain;