mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-02 14:04:46 -04:00
XTRX input: use NCO value as a delta from LO (like with LimeSDR)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user