diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.cpp b/plugins/samplesink/limesdroutput/limesdroutputgui.cpp index 9cd33f6d1..b2c20c87f 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.cpp +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.cpp @@ -298,7 +298,7 @@ void LimeSDROutputGUI::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->hwInterp->setCurrentIndex(m_settings.m_log2HardInterp); @@ -324,11 +324,41 @@ void LimeSDROutputGUI::displaySettings() void LimeSDROutputGUI::setNCODisplay() { int ncoHalfRange = (m_settings.m_devSampleRate * (1<<(m_settings.m_log2HardInterp)))/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); // frequency dial is in kHz + + ui->ncoFrequency->blockSignals(true); + ui->ncoFrequency->setValue(m_settings.m_ncoFrequency); + ui->ncoFrequency->blockSignals(false); +} + +void LimeSDROutputGUI::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 LimeSDROutputGUI::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 LimeSDROutputGUI::sendSettings() @@ -420,28 +450,28 @@ void LimeSDROutputGUI::on_startStop_toggled(bool checked) void LimeSDROutputGUI::on_centerFrequency_changed(quint64 value) { - m_settings.m_centerFrequency = value * 1000; - setNCODisplay(); + setCenterFrequencySetting(value); sendSettings(); } -void LimeSDROutputGUI::on_ncoFrequency_changed(quint64 value) +void LimeSDROutputGUI::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 LimeSDROutputGUI::on_ncoEnable_toggled(bool checked) { m_settings.m_ncoEnable = checked; + setCenterFrequencyDisplay(); sendSettings(); } void LimeSDROutputGUI::on_ncoReset_clicked(bool checked __attribute__((unused))) { m_settings.m_ncoFrequency = 0; - ui->ncoFrequency->setValue(m_settings.m_centerFrequency/1000); + ui->ncoFrequency->setValue(0); sendSettings(); } diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.h b/plugins/samplesink/limesdroutput/limesdroutputgui.h index 301722131..59f050bc1 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.h +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.h @@ -70,6 +70,8 @@ private: void displaySettings(); void setNCODisplay(); + void setCenterFrequencyDisplay(); + void setCenterFrequencySetting(uint64_t kHzValue); void sendSettings(); void updateSampleRateAndFrequency(); void updateDACRate(); @@ -79,7 +81,7 @@ private slots: void handleInputMessages(); void on_startStop_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_sampleRate_changed(quint64 value); diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.ui b/plugins/samplesink/limesdroutput/limesdroutputgui.ui index 487855139..247eb4b5a 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.ui +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.ui @@ -35,16 +35,7 @@ 3 - - 2 - - - 2 - - - 2 - - + 2 @@ -233,7 +224,7 @@ - + 0 @@ -256,14 +247,14 @@ PointingHandCursor - Center frequency with NCO engaged (kHz) + NCO frequency (Hz) - kHz + Hz @@ -938,6 +929,12 @@ QToolTip{background-color: white; color: black;} QToolButton
gui/externalclockbutton.h
+ + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +