mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-23 18:52:28 -04:00
Transverter frequency shift logic. Implemented it for RTLSDR
This commit is contained in:
parent
83f9705e96
commit
43a1e0e14b
@ -28,6 +28,7 @@
|
|||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
|
|
||||||
|
|
||||||
RTLSDRGui::RTLSDRGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
RTLSDRGui::RTLSDRGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::RTLSDRGui),
|
ui(new Ui::RTLSDRGui),
|
||||||
@ -40,10 +41,10 @@ RTLSDRGui::RTLSDRGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
|||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||||
ui->centerFrequency->setValueRange(7, 24000U, 1900000U);
|
updateFrequencyLimits();
|
||||||
|
|
||||||
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
||||||
ui->sampleRate->setValueRange(7, 950000U, 2400000U);
|
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin, RTLSDRInput::sampleRateHighRangeMax);
|
||||||
|
|
||||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
@ -175,6 +176,18 @@ void RTLSDRGui::updateSampleRateAndFrequency()
|
|||||||
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5)));
|
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRGui::updateFrequencyLimits()
|
||||||
|
{
|
||||||
|
// values in kHz
|
||||||
|
qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : RTLSDRInput::frequencyHighRangeMin) + m_settings.m_transverterDeltaFrequency/1000;
|
||||||
|
qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + m_settings.m_transverterDeltaFrequency/1000;
|
||||||
|
|
||||||
|
minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit;
|
||||||
|
maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit;
|
||||||
|
|
||||||
|
ui->centerFrequency->setValueRange(7, minLimit, maxLimit);
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRGui::displayGains()
|
void RTLSDRGui::displayGains()
|
||||||
{
|
{
|
||||||
if (m_gains.size() > 0)
|
if (m_gains.size() > 0)
|
||||||
@ -214,6 +227,9 @@ void RTLSDRGui::displaySettings()
|
|||||||
ui->ppmText->setText(tr("%1").arg(m_settings.m_loPpmCorrection));
|
ui->ppmText->setText(tr("%1").arg(m_settings.m_loPpmCorrection));
|
||||||
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
||||||
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
|
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
|
||||||
|
ui->checkBox->setChecked(m_settings.m_noModMode);
|
||||||
|
ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency);
|
||||||
|
ui->transverter->setChecked(m_settings.m_transverterMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTLSDRGui::sendSettings()
|
void RTLSDRGui::sendSettings()
|
||||||
@ -316,6 +332,14 @@ void RTLSDRGui::on_record_toggled(bool checked)
|
|||||||
m_sampleSource->getInputMessageQueue()->push(message);
|
m_sampleSource->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRGui::on_transverter_toggled(bool checked)
|
||||||
|
{
|
||||||
|
m_settings.m_transverterMode = checked;
|
||||||
|
m_settings.m_transverterDeltaFrequency = checked ? ui->transverter->getDeltaFrequency() : 0;
|
||||||
|
updateFrequencyLimits();
|
||||||
|
sendSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRGui::updateHardware()
|
void RTLSDRGui::updateHardware()
|
||||||
{
|
{
|
||||||
RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings);
|
RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings);
|
||||||
@ -356,18 +380,17 @@ void RTLSDRGui::on_checkBox_stateChanged(int state)
|
|||||||
{
|
{
|
||||||
if (state == Qt::Checked)
|
if (state == Qt::Checked)
|
||||||
{
|
{
|
||||||
// Direct Modes: 0: off, 1: I, 2: Q, 3: NoMod.
|
|
||||||
((RTLSDRInput*)m_sampleSource)->set_ds_mode(3);
|
|
||||||
ui->gain->setEnabled(false);
|
ui->gain->setEnabled(false);
|
||||||
ui->centerFrequency->setValueRange(7, 1000U, 275000U);
|
m_settings.m_noModMode = true;
|
||||||
|
updateFrequencyLimits();
|
||||||
ui->centerFrequency->setValue(7000);
|
ui->centerFrequency->setValue(7000);
|
||||||
m_settings.m_centerFrequency = 7000 * 1000;
|
m_settings.m_centerFrequency = 7000 * 1000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((RTLSDRInput*)m_sampleSource)->set_ds_mode(0);
|
|
||||||
ui->gain->setEnabled(true);
|
ui->gain->setEnabled(true);
|
||||||
ui->centerFrequency->setValueRange(7, 28500U, 1700000U);
|
m_settings.m_noModMode = false;
|
||||||
|
updateFrequencyLimits();
|
||||||
ui->centerFrequency->setValue(434000);
|
ui->centerFrequency->setValue(434000);
|
||||||
ui->gain->setValue(0);
|
ui->gain->setValue(0);
|
||||||
m_settings.m_centerFrequency = 435000 * 1000;
|
m_settings.m_centerFrequency = 435000 * 1000;
|
||||||
@ -391,9 +414,9 @@ void RTLSDRGui::on_sampleRate_changed(quint64 value)
|
|||||||
void RTLSDRGui::on_lowSampleRate_toggled(bool checked)
|
void RTLSDRGui::on_lowSampleRate_toggled(bool checked)
|
||||||
{
|
{
|
||||||
if (checked) {
|
if (checked) {
|
||||||
ui->sampleRate->setValueRange(7, 230000U, 300000U);
|
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateLowRangeMin, RTLSDRInput::sampleRateLowRangeMax);
|
||||||
} else {
|
} else {
|
||||||
ui->sampleRate->setValueRange(7, 950000U, 2400000U);
|
ui->sampleRate->setValueRange(7, RTLSDRInput::sampleRateHighRangeMin, RTLSDRInput::sampleRateHighRangeMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
||||||
|
@ -69,6 +69,7 @@ private:
|
|||||||
void displaySettings();
|
void displaySettings();
|
||||||
void sendSettings();
|
void sendSettings();
|
||||||
void updateSampleRateAndFrequency();
|
void updateSampleRateAndFrequency();
|
||||||
|
void updateFrequencyLimits();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleInputMessages();
|
void handleInputMessages();
|
||||||
@ -86,6 +87,7 @@ private slots:
|
|||||||
void on_agc_stateChanged(int state);
|
void on_agc_stateChanged(int state);
|
||||||
void on_startStop_toggled(bool checked);
|
void on_startStop_toggled(bool checked);
|
||||||
void on_record_toggled(bool checked);
|
void on_record_toggled(bool checked);
|
||||||
|
void on_transverter_toggled(bool checked);
|
||||||
void updateHardware();
|
void updateHardware();
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
};
|
};
|
||||||
|
@ -299,7 +299,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="6">
|
<item row="0" column="6">
|
||||||
<widget class="TransverterButton" name="toolButton">
|
<widget class="TransverterButton" name="transverter">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Transverter frequency translation toggle</string>
|
<string>Transverter frequency translation toggle</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -32,6 +32,15 @@ MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
|
|||||||
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
|
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message)
|
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message)
|
||||||
|
|
||||||
|
const quint64 RTLSDRInput::frequencyLowRangeMin = 1000UL;
|
||||||
|
const quint64 RTLSDRInput::frequencyLowRangeMax = 275000UL;
|
||||||
|
const quint64 RTLSDRInput::frequencyHighRangeMin = 24000UL;
|
||||||
|
const quint64 RTLSDRInput::frequencyHighRangeMax = 1900000UL;
|
||||||
|
const int RTLSDRInput::sampleRateLowRangeMin = 230000U;
|
||||||
|
const int RTLSDRInput::sampleRateLowRangeMax = 300000U;
|
||||||
|
const int RTLSDRInput::sampleRateHighRangeMin = 950000U;
|
||||||
|
const int RTLSDRInput::sampleRateHighRangeMax = 2400000U;
|
||||||
|
|
||||||
RTLSDRInput::RTLSDRInput(DeviceSourceAPI *deviceAPI) :
|
RTLSDRInput::RTLSDRInput(DeviceSourceAPI *deviceAPI) :
|
||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
m_settings(),
|
m_settings(),
|
||||||
@ -354,35 +363,43 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||||
|| (m_settings.m_fcPos != settings.m_fcPos))
|
|| (m_settings.m_fcPos != settings.m_fcPos)
|
||||||
|
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
||||||
|
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency))
|
||||||
{
|
{
|
||||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
||||||
|
m_settings.m_transverterMode = settings.m_transverterMode;
|
||||||
|
m_settings.m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
|
||||||
|
qint64 deviceCenterFrequency = m_settings.m_centerFrequency;
|
||||||
|
|
||||||
|
deviceCenterFrequency -= m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency : 0;
|
||||||
|
|
||||||
|
qint64 f_img = deviceCenterFrequency;
|
||||||
|
quint32 devSampleRate = m_settings.m_devSampleRate;
|
||||||
|
|
||||||
forwardChange = true;
|
forwardChange = true;
|
||||||
|
|
||||||
if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == RTLSDRSettings::FC_POS_CENTER))
|
if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == RTLSDRSettings::FC_POS_CENTER))
|
||||||
{
|
{
|
||||||
deviceCenterFrequency = m_settings.m_centerFrequency;
|
|
||||||
f_img = deviceCenterFrequency;
|
f_img = deviceCenterFrequency;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (settings.m_fcPos == RTLSDRSettings::FC_POS_INFRA)
|
if (settings.m_fcPos == RTLSDRSettings::FC_POS_INFRA)
|
||||||
{
|
{
|
||||||
deviceCenterFrequency = m_settings.m_centerFrequency + (devSampleRate / 4);
|
deviceCenterFrequency += (devSampleRate / 4);
|
||||||
f_img = deviceCenterFrequency + devSampleRate/2;
|
f_img = deviceCenterFrequency + devSampleRate/2;
|
||||||
}
|
}
|
||||||
else if (settings.m_fcPos == RTLSDRSettings::FC_POS_SUPRA)
|
else if (settings.m_fcPos == RTLSDRSettings::FC_POS_SUPRA)
|
||||||
{
|
{
|
||||||
deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4);
|
deviceCenterFrequency -= (devSampleRate / 4);
|
||||||
f_img = deviceCenterFrequency - devSampleRate/2;
|
f_img = deviceCenterFrequency - devSampleRate/2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
|
||||||
|
|
||||||
if (m_dev != 0)
|
if (m_dev != 0)
|
||||||
{
|
{
|
||||||
if (rtlsdr_set_center_freq( m_dev, deviceCenterFrequency ) != 0)
|
if (rtlsdr_set_center_freq( m_dev, deviceCenterFrequency ) != 0)
|
||||||
@ -411,6 +428,18 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((m_settings.m_noModMode != settings.m_noModMode) || force)
|
||||||
|
{
|
||||||
|
m_settings.m_noModMode = settings.m_noModMode;
|
||||||
|
|
||||||
|
// Direct Modes: 0: off, 1: I, 2: Q, 3: NoMod.
|
||||||
|
if (m_settings.m_noModMode) {
|
||||||
|
set_ds_mode(3);
|
||||||
|
} else {
|
||||||
|
set_ds_mode(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (forwardChange)
|
if (forwardChange)
|
||||||
{
|
{
|
||||||
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
|
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
|
||||||
|
@ -106,6 +106,15 @@ public:
|
|||||||
const std::vector<int>& getGains() const { return m_gains; }
|
const std::vector<int>& getGains() const { return m_gains; }
|
||||||
void set_ds_mode(int on);
|
void set_ds_mode(int on);
|
||||||
|
|
||||||
|
static const quint64 frequencyLowRangeMin;
|
||||||
|
static const quint64 frequencyLowRangeMax;
|
||||||
|
static const quint64 frequencyHighRangeMin;
|
||||||
|
static const quint64 frequencyHighRangeMax;
|
||||||
|
static const int sampleRateLowRangeMin;
|
||||||
|
static const int sampleRateLowRangeMax;
|
||||||
|
static const int sampleRateHighRangeMin;
|
||||||
|
static const int sampleRateHighRangeMax;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceSourceAPI *m_deviceAPI;
|
DeviceSourceAPI *m_deviceAPI;
|
||||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
|
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
|
||||||
QString("RTL-SDR Input"),
|
QString("RTL-SDR Input"),
|
||||||
QString("3.7.2"),
|
QString("3.7.3"),
|
||||||
QString("(c) Edouard Griffiths, F4EXB"),
|
QString("(c) Edouard Griffiths, F4EXB"),
|
||||||
QString("https://github.com/f4exb/sdrangel"),
|
QString("https://github.com/f4exb/sdrangel"),
|
||||||
true,
|
true,
|
||||||
|
@ -35,6 +35,9 @@ void RTLSDRSettings::resetToDefaults()
|
|||||||
m_dcBlock = false;
|
m_dcBlock = false;
|
||||||
m_iqImbalance = false;
|
m_iqImbalance = false;
|
||||||
m_agc = false;
|
m_agc = false;
|
||||||
|
m_noModMode = false;
|
||||||
|
m_transverterMode = false;
|
||||||
|
m_transverterDeltaFrequency = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RTLSDRSettings::serialize() const
|
QByteArray RTLSDRSettings::serialize() const
|
||||||
@ -50,6 +53,9 @@ QByteArray RTLSDRSettings::serialize() const
|
|||||||
s.writeS32(8, m_devSampleRate);
|
s.writeS32(8, m_devSampleRate);
|
||||||
s.writeBool(9, m_lowSampleRate);
|
s.writeBool(9, m_lowSampleRate);
|
||||||
s.writeBool(10, m_agc);
|
s.writeBool(10, m_agc);
|
||||||
|
s.writeBool(11, m_noModMode);
|
||||||
|
s.writeBool(12, m_transverterMode);
|
||||||
|
s.writeS64(13, m_transverterDeltaFrequency);
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
@ -78,6 +84,9 @@ bool RTLSDRSettings::deserialize(const QByteArray& data)
|
|||||||
d.readS32(8, &m_devSampleRate, 1024*1000);
|
d.readS32(8, &m_devSampleRate, 1024*1000);
|
||||||
d.readBool(9, &m_lowSampleRate, false);
|
d.readBool(9, &m_lowSampleRate, false);
|
||||||
d.readBool(10, &m_agc, false);
|
d.readBool(10, &m_agc, false);
|
||||||
|
d.readBool(11, &m_noModMode, false);
|
||||||
|
d.readBool(12, &m_transverterMode, false);
|
||||||
|
d.readS64(13, &m_transverterDeltaFrequency, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ struct RTLSDRSettings {
|
|||||||
bool m_dcBlock;
|
bool m_dcBlock;
|
||||||
bool m_iqImbalance;
|
bool m_iqImbalance;
|
||||||
bool m_agc;
|
bool m_agc;
|
||||||
|
bool m_noModMode;
|
||||||
|
bool m_transverterMode;
|
||||||
|
qint64 m_transverterDeltaFrequency;
|
||||||
|
|
||||||
RTLSDRSettings();
|
RTLSDRSettings();
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
@ -33,7 +33,7 @@ void TransverterButton::onToggled(bool checked)
|
|||||||
if (checked) {
|
if (checked) {
|
||||||
TransverterDialog transverterDialog(&m_deltaFrequency, this);
|
TransverterDialog transverterDialog(&m_deltaFrequency, this);
|
||||||
transverterDialog.exec();
|
transverterDialog.exec();
|
||||||
setToolTip(tr("Transverter frequency translation toggle. Delta frequency %1 kHz").arg(m_deltaFrequency));
|
setToolTip(tr("Transverter frequency translation toggle. Delta frequency %1 kHz").arg(m_deltaFrequency/1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ TransverterDialog::TransverterDialog(qint64 *deltaFrequency, QWidget* parent) :
|
|||||||
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
||||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||||
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
||||||
ui->deltaFrequency->setValue(*m_deltaFrequency);
|
ui->deltaFrequency->setValue(*m_deltaFrequency/1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransverterDialog::~TransverterDialog()
|
TransverterDialog::~TransverterDialog()
|
||||||
@ -42,6 +42,6 @@ TransverterDialog::~TransverterDialog()
|
|||||||
|
|
||||||
void TransverterDialog::accept()
|
void TransverterDialog::accept()
|
||||||
{
|
{
|
||||||
*m_deltaFrequency = ui->deltaFrequency->getValueNew();
|
*m_deltaFrequency = ui->deltaFrequency->getValueNew()*1000;
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user