diff --git a/plugins/channelrx/localsink/localsinkgui.cpp b/plugins/channelrx/localsink/localsinkgui.cpp index 9a876bc75..ae3f2a9af 100644 --- a/plugins/channelrx/localsink/localsinkgui.cpp +++ b/plugins/channelrx/localsink/localsinkgui.cpp @@ -228,7 +228,13 @@ void LocalSinkGUI::displayRateAndShift() ui->offsetFrequencyText->setText(tr("%1 Hz").arg(loc.toString(shift))); ui->channelRateText->setText(tr("%1k").arg(QString::number(channelSampleRate / 1000.0, 'g', 5))); ui->glSpectrum->setSampleRate(channelSampleRate); - ui->glSpectrum->setCenterFrequency(m_deviceCenterFrequency + shift); + + if (ui->relativeSpectrum->isChecked()) { + ui->glSpectrum->setCenterFrequency(0); + } else { + ui->glSpectrum->setCenterFrequency(m_deviceCenterFrequency + shift); + } + m_channelMarker.setCenterFrequency(shift); m_channelMarker.setBandwidth(channelSampleRate); } @@ -399,6 +405,19 @@ void LocalSinkGUI::on_decimationFactor_currentIndexChanged(int index) applyDecimation(); } +void LocalSinkGUI::on_relativeSpectrum_toggled(bool checked) +{ + if (checked) + { + ui->glSpectrum->setCenterFrequency(0); + } + else + { + int shift = m_shiftFrequencyFactor * m_basebandSampleRate; + ui->glSpectrum->setCenterFrequency(m_deviceCenterFrequency + shift); + } +} + void LocalSinkGUI::on_position_valueChanged(int value) { m_settings.m_filterChainHash = value; @@ -572,6 +591,7 @@ void LocalSinkGUI::tick() void LocalSinkGUI::makeUIConnections() { QObject::connect(ui->decimationFactor, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalSinkGUI::on_decimationFactor_currentIndexChanged); + QObject::connect(ui->relativeSpectrum, &ButtonSwitch::toggled, this, &LocalSinkGUI::on_relativeSpectrum_toggled); QObject::connect(ui->position, &QSlider::valueChanged, this, &LocalSinkGUI::on_position_valueChanged); QObject::connect(ui->localDevice, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalSinkGUI::on_localDevice_currentIndexChanged); QObject::connect(ui->localDevicePlay, &ButtonSwitch::toggled, this, &LocalSinkGUI::on_localDevicePlay_toggled); diff --git a/plugins/channelrx/localsink/localsinkgui.h b/plugins/channelrx/localsink/localsinkgui.h index 948322816..e385077e1 100644 --- a/plugins/channelrx/localsink/localsinkgui.h +++ b/plugins/channelrx/localsink/localsinkgui.h @@ -106,6 +106,7 @@ private: private slots: void handleSourceMessages(); void on_decimationFactor_currentIndexChanged(int index); + void on_relativeSpectrum_toggled(bool checked); void on_position_valueChanged(int value); void on_localDevice_currentIndexChanged(int index); void on_localDevicePlay_toggled(bool checked); diff --git a/plugins/channelrx/localsink/localsinkgui.ui b/plugins/channelrx/localsink/localsinkgui.ui index f29e5cea7..0f315260f 100644 --- a/plugins/channelrx/localsink/localsinkgui.ui +++ b/plugins/channelrx/localsink/localsinkgui.ui @@ -194,6 +194,22 @@ + + + + + 16777215 + 24 + + + + Toggle absolute or relative frequency display on spectrum scale + + + REL + + +