diff --git a/plugins/samplesource/xtrxinput/xtrxinputgui.cpp b/plugins/samplesource/xtrxinput/xtrxinputgui.cpp index 1570bc425..0a1f0babc 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputgui.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinputgui.cpp @@ -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(); } diff --git a/plugins/samplesource/xtrxinput/xtrxinputgui.h b/plugins/samplesource/xtrxinput/xtrxinputgui.h index b4bc30d28..2473169c3 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputgui.h +++ b/plugins/samplesource/xtrxinput/xtrxinputgui.h @@ -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); diff --git a/plugins/samplesource/xtrxinput/xtrxinputgui.ui b/plugins/samplesource/xtrxinput/xtrxinputgui.ui index aa77215d6..4ea9dd7d4 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputgui.ui +++ b/plugins/samplesource/xtrxinput/xtrxinputgui.ui @@ -6,7 +6,7 @@ 0 0 - 373 + 370 290 @@ -240,23 +240,7 @@ - - - - 22 - 22 - - - - Reset the NCO to zero frequency - - - R - - - - - + 0 @@ -1122,6 +1106,12 @@ QToolTip{background-color: white; color: black;} QToolButton
gui/externalclockbutton.h
+ + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +