mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-28 07:46:37 -04:00
RTLSDR: implemented Fc position adjustment
This commit is contained in:
parent
2ceacfa107
commit
dc81e2dd9c
@ -136,6 +136,7 @@ void RTLSDRGui::displaySettings()
|
|||||||
ui->ppmText->setText(tr("%1").arg(m_settings.m_loPpmCorrection));
|
ui->ppmText->setText(tr("%1").arg(m_settings.m_loPpmCorrection));
|
||||||
ui->decimText->setText(tr("%1").arg(1<<m_settings.m_log2Decim));
|
ui->decimText->setText(tr("%1").arg(1<<m_settings.m_log2Decim));
|
||||||
ui->decim->setValue(m_settings.m_log2Decim);
|
ui->decim->setValue(m_settings.m_log2Decim);
|
||||||
|
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
|
||||||
|
|
||||||
if (m_gains.size() > 0)
|
if (m_gains.size() > 0)
|
||||||
{
|
{
|
||||||
@ -191,6 +192,20 @@ void RTLSDRGui::on_decim_valueChanged(int value)
|
|||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRGui::on_fcPos_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if (index == 0) {
|
||||||
|
m_settings.m_fcPos = RTLSDRSettings::FC_POS_INFRA;
|
||||||
|
sendSettings();
|
||||||
|
} else if (index == 1) {
|
||||||
|
m_settings.m_fcPos = RTLSDRSettings::FC_POS_SUPRA;
|
||||||
|
sendSettings();
|
||||||
|
} else if (index == 2) {
|
||||||
|
m_settings.m_fcPos = RTLSDRSettings::FC_POS_CENTER;
|
||||||
|
sendSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRGui::on_ppm_valueChanged(int value)
|
void RTLSDRGui::on_ppm_valueChanged(int value)
|
||||||
{
|
{
|
||||||
if ((value > 99) || (value < -99))
|
if ((value > 99) || (value < -99))
|
||||||
|
@ -47,6 +47,7 @@ private slots:
|
|||||||
void on_dcOffset_toggled(bool checked);
|
void on_dcOffset_toggled(bool checked);
|
||||||
void on_iqImbalance_toggled(bool checked);
|
void on_iqImbalance_toggled(bool checked);
|
||||||
void on_decim_valueChanged(int value);
|
void on_decim_valueChanged(int value);
|
||||||
|
void on_fcPos_currentIndexChanged(int index);
|
||||||
void on_ppm_valueChanged(int value);
|
void on_ppm_valueChanged(int value);
|
||||||
void on_gain_valueChanged(int value);
|
void on_gain_valueChanged(int value);
|
||||||
void on_samplerate_valueChanged(int value);
|
void on_samplerate_valueChanged(int value);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>247</width>
|
<width>247</width>
|
||||||
<height>189</height>
|
<height>219</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -275,6 +275,49 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_fcPos">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="fcPos">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Inf</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sup</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cent</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="fcPosLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fc pos</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<spacer name="horizontalSpacer_fcPos">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_3">
|
<widget class="Line" name="line_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -235,12 +235,13 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
{
|
{
|
||||||
if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0)
|
if( rtlsdr_set_sample_rate(m_dev, settings.m_devSampleRate) < 0)
|
||||||
{
|
{
|
||||||
qCritical("could not set sample rate: %d", settings.m_devSampleRate);
|
qCritical("RTLSDRInput::applySettings: could not set sample rate: %d", settings.m_devSampleRate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
m_settings.m_devSampleRate = settings.m_devSampleRate;
|
||||||
m_rtlSDRThread->setSamplerate(settings.m_devSampleRate);
|
m_rtlSDRThread->setSamplerate(settings.m_devSampleRate);
|
||||||
|
qDebug("RTLSDRInput::applySettings: sample rate set to %d", m_settings.m_devSampleRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,8 +277,63 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
forwardChange = true;
|
forwardChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
qint64 deviceCenterFrequency = m_settings.m_centerFrequency;
|
||||||
|
qint64 f_img = deviceCenterFrequency;
|
||||||
|
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;
|
||||||
|
|
||||||
|
if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == RTLSDRSettings::FC_POS_CENTER))
|
||||||
|
{
|
||||||
|
deviceCenterFrequency = m_settings.m_centerFrequency;
|
||||||
|
f_img = deviceCenterFrequency;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (settings.m_fcPos == RTLSDRSettings::FC_POS_INFRA)
|
||||||
|
{
|
||||||
|
deviceCenterFrequency = m_settings.m_centerFrequency + (devSampleRate / 4);
|
||||||
|
f_img = deviceCenterFrequency + devSampleRate/2;
|
||||||
|
}
|
||||||
|
else if (settings.m_fcPos == RTLSDRSettings::FC_POS_SUPRA)
|
||||||
|
{
|
||||||
|
deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4);
|
||||||
|
f_img = deviceCenterFrequency - devSampleRate/2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_dev != 0)
|
||||||
|
{
|
||||||
|
if (rtlsdr_set_center_freq( m_dev, deviceCenterFrequency ) != 0)
|
||||||
|
{
|
||||||
|
qDebug("rtlsdr_set_center_freq(%lld) failed", deviceCenterFrequency);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "RTLSDRInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"
|
||||||
|
<< " device center freq: " << deviceCenterFrequency << " Hz"
|
||||||
|
<< " device sample rate: " << devSampleRate << "Hz"
|
||||||
|
<< " Actual sample rate: " << devSampleRate/(1<<m_settings.m_log2Decim) << "Hz"
|
||||||
|
<< " img: " << f_img << "Hz";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||||
|
{
|
||||||
|
m_settings.m_fcPos = settings.m_fcPos;
|
||||||
|
|
||||||
|
if(m_dev != 0)
|
||||||
|
{
|
||||||
|
m_rtlSDRThread->setFcPos((int) m_settings.m_fcPos);
|
||||||
|
qDebug() << "RTLSDRInput: set fc pos (enum) to " << (int) m_settings.m_fcPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(m_dev != 0)
|
if(m_dev != 0)
|
||||||
{
|
{
|
||||||
qint64 centerFrequency = m_settings.m_centerFrequency + (m_settings.m_devSampleRate / 4);
|
qint64 centerFrequency = m_settings.m_centerFrequency + (m_settings.m_devSampleRate / 4);
|
||||||
@ -295,7 +351,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
{
|
{
|
||||||
qDebug("rtlsdr_set_center_freq(%lld) failed", m_settings.m_centerFrequency);
|
qDebug("rtlsdr_set_center_freq(%lld) failed", m_settings.m_centerFrequency);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ void RTLSDRSettings::resetToDefaults()
|
|||||||
m_gain = 0;
|
m_gain = 0;
|
||||||
m_loPpmCorrection = 0;
|
m_loPpmCorrection = 0;
|
||||||
m_log2Decim = 4;
|
m_log2Decim = 4;
|
||||||
|
m_fcPos = FC_POS_CENTER;
|
||||||
m_dcBlock = false;
|
m_dcBlock = false;
|
||||||
m_iqImbalance = false;
|
m_iqImbalance = false;
|
||||||
}
|
}
|
||||||
@ -44,6 +45,7 @@ QByteArray RTLSDRSettings::serialize() const
|
|||||||
s.writeU32(4, m_log2Decim);
|
s.writeU32(4, m_log2Decim);
|
||||||
s.writeBool(5, m_dcBlock);
|
s.writeBool(5, m_dcBlock);
|
||||||
s.writeBool(6, m_iqImbalance);
|
s.writeBool(6, m_iqImbalance);
|
||||||
|
s.writeS32(7, (int) m_fcPos);
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
@ -60,12 +62,16 @@ bool RTLSDRSettings::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
if (d.getVersion() == 1)
|
if (d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
|
int intval;
|
||||||
|
|
||||||
d.readS32(1, &m_devSampleRate, 0);
|
d.readS32(1, &m_devSampleRate, 0);
|
||||||
d.readS32(2, &m_gain, 0);
|
d.readS32(2, &m_gain, 0);
|
||||||
d.readS32(3, &m_loPpmCorrection, 0);
|
d.readS32(3, &m_loPpmCorrection, 0);
|
||||||
d.readU32(4, &m_log2Decim, 4);
|
d.readU32(4, &m_log2Decim, 4);
|
||||||
d.readBool(5, &m_dcBlock, false);
|
d.readBool(5, &m_dcBlock, false);
|
||||||
d.readBool(6, &m_iqImbalance, false);
|
d.readBool(6, &m_iqImbalance, false);
|
||||||
|
d.readS32(7, &intval, 0);
|
||||||
|
m_fcPos = (fcPos_t) intval;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,18 @@
|
|||||||
#define _RTLSDR_RTLSDRSETTINGS_H_
|
#define _RTLSDR_RTLSDRSETTINGS_H_
|
||||||
|
|
||||||
struct RTLSDRSettings {
|
struct RTLSDRSettings {
|
||||||
|
typedef enum {
|
||||||
|
FC_POS_INFRA = 0,
|
||||||
|
FC_POS_SUPRA,
|
||||||
|
FC_POS_CENTER
|
||||||
|
} fcPos_t;
|
||||||
|
|
||||||
int m_devSampleRate;
|
int m_devSampleRate;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
qint32 m_gain;
|
qint32 m_gain;
|
||||||
qint32 m_loPpmCorrection;
|
qint32 m_loPpmCorrection;
|
||||||
quint32 m_log2Decim;
|
quint32 m_log2Decim;
|
||||||
|
fcPos_t m_fcPos;
|
||||||
bool m_dcBlock;
|
bool m_dcBlock;
|
||||||
bool m_iqImbalance;
|
bool m_iqImbalance;
|
||||||
|
|
||||||
|
@ -63,6 +63,11 @@ void RTLSDRThread::setLog2Decimation(unsigned int log2_decim)
|
|||||||
m_log2Decim = log2_decim;
|
m_log2Decim = log2_decim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRThread::setFcPos(int fcPos)
|
||||||
|
{
|
||||||
|
m_fcPos = fcPos;
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRThread::run()
|
void RTLSDRThread::run()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -85,25 +90,72 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
|||||||
{
|
{
|
||||||
SampleVector::iterator it = m_convertBuffer.begin();
|
SampleVector::iterator it = m_convertBuffer.begin();
|
||||||
|
|
||||||
switch (m_log2Decim)
|
if (m_log2Decim == 0)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
m_decimators.decimate1(&it, buf, len);
|
m_decimators.decimate1(&it, buf, len);
|
||||||
break;
|
}
|
||||||
case 1:
|
else
|
||||||
m_decimators.decimate2_inf(&it, buf, len);
|
{
|
||||||
break;
|
if (m_fcPos == 0) // Infradyne
|
||||||
case 2:
|
{
|
||||||
m_decimators.decimate4_inf(&it, buf, len);
|
switch (m_log2Decim)
|
||||||
break;
|
{
|
||||||
case 3:
|
case 1:
|
||||||
m_decimators.decimate8_inf(&it, buf, len);
|
m_decimators.decimate2_inf(&it, buf, len);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 2:
|
||||||
m_decimators.decimate16_inf(&it, buf, len);
|
m_decimators.decimate4_inf(&it, buf, len);
|
||||||
break;
|
break;
|
||||||
default:
|
case 3:
|
||||||
break;
|
m_decimators.decimate8_inf(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_decimators.decimate16_inf(&it, buf, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_fcPos == 1) // Supradyne
|
||||||
|
{
|
||||||
|
switch (m_log2Decim)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
m_decimators.decimate2_sup(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
m_decimators.decimate4_sup(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
m_decimators.decimate8_sup(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_decimators.decimate16_sup(&it, buf, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Centered
|
||||||
|
{
|
||||||
|
switch (m_log2Decim)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
m_decimators.decimate2_cen(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
m_decimators.decimate4_cen(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
m_decimators.decimate8_cen(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_decimators.decimate16_cen(&it, buf, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
void stopWork();
|
void stopWork();
|
||||||
void setSamplerate(int samplerate);
|
void setSamplerate(int samplerate);
|
||||||
void setLog2Decimation(unsigned int log2_decim);
|
void setLog2Decimation(unsigned int log2_decim);
|
||||||
|
void setFcPos(int fcPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_startWaitMutex;
|
QMutex m_startWaitMutex;
|
||||||
@ -49,6 +50,7 @@ private:
|
|||||||
|
|
||||||
int m_samplerate;
|
int m_samplerate;
|
||||||
unsigned int m_log2Decim;
|
unsigned int m_log2Decim;
|
||||||
|
int m_fcPos;
|
||||||
|
|
||||||
Decimators<quint8, SDR_SAMP_SZ, 8> m_decimators;
|
Decimators<quint8, SDR_SAMP_SZ, 8> m_decimators;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user