1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

XTRX input: use NCO value as a delta from LO (like with LimeSDR)

This commit is contained in:
f4exb 2018-12-30 02:07:10 +01:00
parent 961607ae8d
commit cf953496b9
3 changed files with 55 additions and 40 deletions

View File

@ -105,12 +105,12 @@ void XTRXInputGUI::resetToDefaults()
qint64 XTRXInputGUI::getCenterFrequency() const
{
return m_settings.m_centerFrequency;
return m_settings.m_centerFrequency + (m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0);
}
void XTRXInputGUI::setCenterFrequency(qint64 centerFrequency)
{
m_settings.m_centerFrequency = centerFrequency;
m_settings.m_centerFrequency = centerFrequency - (m_settings.m_ncoEnable ? m_settings.m_ncoFrequency : 0);
displaySettings();
sendSettings();
}
@ -264,7 +264,7 @@ void XTRXInputGUI::displaySettings()
ui->extClock->setExternalClockFrequency(m_settings.m_extClockFreq);
ui->extClock->setExternalClockActive(m_settings.m_extClock);
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
setCenterFrequencyDisplay();
ui->sampleRate->setValue(m_settings.m_devSampleRate);
ui->dcOffset->setChecked(m_settings.m_dcBlock);
@ -310,11 +310,42 @@ void XTRXInputGUI::displaySettings()
void XTRXInputGUI::setNCODisplay()
{
int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardDecim)))/2;
int lowBoundary = std::max(0, (int) m_settings.m_centerFrequency - ncoHalfRange);
ui->ncoFrequency->setValueRange(7,
lowBoundary/1000,
(m_settings.m_centerFrequency + ncoHalfRange)/1000); // frequency dial is in kHz
ui->ncoFrequency->setValue((m_settings.m_centerFrequency + m_settings.m_ncoFrequency)/1000);
ui->ncoFrequency->setValueRange(
false,
8,
-ncoHalfRange,
ncoHalfRange);
ui->ncoFrequency->blockSignals(true);
ui->ncoFrequency->setToolTip(QString("NCO frequency shift in Hz (Range: +/- %1 kHz)").arg(ncoHalfRange/1000));
ui->ncoFrequency->setValue(m_settings.m_ncoFrequency);
ui->ncoFrequency->blockSignals(false);
}
void XTRXInputGUI::setCenterFrequencyDisplay()
{
int64_t centerFrequency = m_settings.m_centerFrequency;
ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000));
if (m_settings.m_ncoEnable) {
centerFrequency += m_settings.m_ncoFrequency;
}
ui->centerFrequency->blockSignals(true);
ui->centerFrequency->setValue(centerFrequency < 0 ? 0 : (uint64_t) centerFrequency/1000); // kHz
ui->centerFrequency->blockSignals(false);
}
void XTRXInputGUI::setCenterFrequencySetting(uint64_t kHzValue)
{
int64_t centerFrequency = kHzValue*1000;
if (m_settings.m_ncoEnable) {
centerFrequency -= m_settings.m_ncoFrequency;
}
m_settings.m_centerFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency;
ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000));
}
void XTRXInputGUI::sendSettings()
@ -418,28 +449,21 @@ void XTRXInputGUI::on_record_toggled(bool checked)
void XTRXInputGUI::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
setNCODisplay();
setCenterFrequencySetting(value);
sendSettings();
}
void XTRXInputGUI::on_ncoFrequency_changed(quint64 value)
void XTRXInputGUI::on_ncoFrequency_changed(qint64 value)
{
m_settings.m_ncoFrequency = (int64_t) value - (int64_t) m_settings.m_centerFrequency/1000;
m_settings.m_ncoFrequency *= 1000;
m_settings.m_ncoFrequency = value;
setCenterFrequencyDisplay();
sendSettings();
}
void XTRXInputGUI::on_ncoEnable_toggled(bool checked)
{
m_settings.m_ncoEnable = checked;
sendSettings();
}
void XTRXInputGUI::on_ncoReset_clicked(bool checked __attribute__((unused)))
{
m_settings.m_ncoFrequency = 0;
ui->ncoFrequency->setValue(m_settings.m_centerFrequency/1000);
setCenterFrequencyDisplay();
sendSettings();
}

View File

@ -70,6 +70,8 @@ private:
void displaySettings();
void setNCODisplay();
void setCenterFrequencyDisplay();
void setCenterFrequencySetting(uint64_t kHzValue);
void sendSettings();
void updateSampleRateAndFrequency();
void updateADCRate();
@ -80,9 +82,8 @@ private slots:
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void on_centerFrequency_changed(quint64 value);
void on_ncoFrequency_changed(quint64 value);
void on_ncoFrequency_changed(qint64 value);
void on_ncoEnable_toggled(bool checked);
void on_ncoReset_clicked(bool checked);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_sampleRate_changed(quint64 value);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>373</width>
<width>370</width>
<height>290</height>
</rect>
</property>
@ -240,23 +240,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="ncoReset">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Reset the NCO to zero frequency</string>
</property>
<property name="text">
<string>R</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDial" name="ncoFrequency" native="true">
<widget class="ValueDialZ" name="ncoFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@ -1122,6 +1106,12 @@ QToolTip{background-color: white; color: black;}</string>
<extends>QToolButton</extends>
<header>gui/externalclockbutton.h</header>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>