From a182656294869b3ec89025df77a5f91038cabbfc Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 14 Nov 2017 01:23:01 +0100 Subject: [PATCH] BFM Demod: applied new channel marker signal handling --- plugins/channelrx/demodam/amdemodgui.cpp | 3 +- plugins/channelrx/demodbfm/bfmdemodgui.cpp | 51 ++++++++++++---------- plugins/channelrx/demodbfm/bfmdemodgui.h | 46 +++++++++---------- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 60ecb2364..9b7d2692b 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -97,6 +97,7 @@ bool AMDemodGUI::handleMessage(const Message& message __attribute__((unused))) void AMDemodGUI::channelMarkerChangedByCursor() { ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); + m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); applySettings(); } @@ -236,8 +237,6 @@ void AMDemodGUI::applySettings(bool force) { if (m_doApplySettings) { - setTitleColor(m_channelMarker.getColor()); - AMDemod::MsgConfigureChannelizer* channelConfigMsg = AMDemod::MsgConfigureChannelizer::create( 48000, m_channelMarker.getCenterFrequency()); m_amDemod->getInputMessageQueue()->push(channelConfigMsg); diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.cpp b/plugins/channelrx/demodbfm/bfmdemodgui.cpp index e57bb57aa..2e939e0b7 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodgui.cpp @@ -136,12 +136,10 @@ void BFMDemodGUI::handleInputMessages() } } -void BFMDemodGUI::channelMarkerUpdate() +void BFMDemodGUI::channelMarkerChangedByCursor() { - m_settings.m_udpAddress = m_channelMarker.getUDPAddress(), - m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), - m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); - displaySettings(); + ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); + m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); applySettings(); } @@ -307,10 +305,16 @@ void BFMDemodGUI::onMenuDialogCalled(const QPoint &p) dialog.move(p); dialog.exec(); - if (dialog.hasChanged()) - { - channelMarkerUpdate(); - } + m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); + m_settings.m_udpAddress = m_channelMarker.getUDPAddress(), + m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), + m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); + + setWindowTitle(m_channelMarker.getTitle()); + setTitleColor(m_settings.m_rgbColor); + displayUDPAddress(); + + applySettings(); } BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) : @@ -347,24 +351,27 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris); connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); - m_channelMarker.setTitle("Broadcast FM Demod"); + m_channelMarker.blockSignals(true); + m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setBandwidth(12500); m_channelMarker.setCenterFrequency(0); + m_channelMarker.setTitle("Broadcast FM Demod"); m_channelMarker.setUDPAddress("127.0.0.1"); m_channelMarker.setUDPSendPort(9999); - m_channelMarker.setVisible(true); - m_channelMarker.setColor(m_settings.m_rgbColor); + m_channelMarker.blockSignals(false); + m_channelMarker.setVisible(true); // activate signal on the last setting only + setTitleColor(m_channelMarker.getColor()); m_settings.setChannelMarker(&m_channelMarker); m_settings.setSpectrumGUI(ui->spectrumGUI); - connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged())); - m_deviceUISet->registerRxChannelInstance(BFMDemod::m_channelID, this); m_deviceUISet->addChannelMarker(&m_channelMarker); m_deviceUISet->addRollupWidget(this); + connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor())); + ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); ui->g00AltFrequenciesBox->setEnabled(false); @@ -374,7 +381,6 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban rdsUpdateFixedFields(); rdsUpdate(true); displaySettings(); - displayUDPAddress(); applySettings(true); } @@ -387,7 +393,7 @@ BFMDemodGUI::~BFMDemodGUI() void BFMDemodGUI::displayUDPAddress() { - ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_channelMarker.getUDPAddress()).arg(m_channelMarker.getUDPSendPort())); + ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_settings.m_udpAddress).arg(m_settings.m_udpPort)); } void BFMDemodGUI::blockApplySettings(bool block) @@ -413,17 +419,20 @@ void BFMDemodGUI::displaySettings() { m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); - m_channelMarker.setColor(m_settings.m_rgbColor); - setTitleColor(m_settings.m_rgbColor); + m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); m_channelMarker.blockSignals(false); + m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only + setTitleColor(m_settings.m_rgbColor); setWindowTitle(m_channelMarker.getTitle()); + displayUDPAddress(); blockApplySettings(true); + ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); + ui->rfBW->setValue(BFMDemodSettings::getRFBWIndex(m_settings.m_rfBandwidth)); ui->rfBWText->setText(QString("%1 kHz").arg(m_settings.m_rfBandwidth / 1000.0)); - m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); ui->afBW->setValue(m_settings.m_afBandwidth/1000.0); ui->afBWText->setText(QString("%1 kHz").arg(m_settings.m_afBandwidth/1000.0)); @@ -445,16 +454,12 @@ void BFMDemodGUI::displaySettings() void BFMDemodGUI::leaveEvent(QEvent*) { - blockApplySettings(true); m_channelMarker.setHighlighted(false); - blockApplySettings(false); } void BFMDemodGUI::enterEvent(QEvent*) { - blockApplySettings(true); m_channelMarker.setHighlighted(true); - blockApplySettings(false); } void BFMDemodGUI::tick() diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.h b/plugins/channelrx/demodbfm/bfmdemodgui.h index 5803125f1..adb2695ad 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.h +++ b/plugins/channelrx/demodbfm/bfmdemodgui.h @@ -29,8 +29,6 @@ class PluginAPI; class DeviceUISet; class RDSParser; -class ThreadedBasebandSampleSink; -class DownChannelizer; class SpectrumVis; class BFMDemod; class BasebandSampleSink; @@ -57,26 +55,8 @@ public: virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } virtual bool handleMessage(const Message& message); -private slots: - void on_deltaFrequency_changed(qint64 value); - void on_rfBW_valueChanged(int value); - void on_afBW_valueChanged(int value); - void on_volume_valueChanged(int value); - void on_squelch_valueChanged(int value); - void on_audioStereo_toggled(bool stereo); - void on_lsbStereo_toggled(bool lsb); - void on_showPilot_clicked(); - void on_rds_clicked(); - void on_copyAudioToUDP_toggled(bool copy); - void on_g14ProgServiceNames_currentIndexChanged(int index); - void on_clearData_clicked(bool checked); - void on_g00AltFrequenciesBox_activated(int index); - void on_g14MappedFrequencies_activated(int index); - void on_g14AltFrequencies_activated(int index); - void onWidgetRolled(QWidget* widget, bool rollDown); - void onMenuDialogCalled(const QPoint& p); - void handleInputMessages(); - void tick(); +public slots: + void channelMarkerChangedByCursor(); private: Ui::BFMDemodGUI* ui; @@ -104,7 +84,6 @@ private: void displayUDPAddress(); void rdsUpdate(bool force); void rdsUpdateFixedFields(); - void channelMarkerUpdate(); void leaveEvent(QEvent*); void enterEvent(QEvent*); @@ -119,6 +98,27 @@ private: return (3*rfBW)/2; } } + +private slots: + void on_deltaFrequency_changed(qint64 value); + void on_rfBW_valueChanged(int value); + void on_afBW_valueChanged(int value); + void on_volume_valueChanged(int value); + void on_squelch_valueChanged(int value); + void on_audioStereo_toggled(bool stereo); + void on_lsbStereo_toggled(bool lsb); + void on_showPilot_clicked(); + void on_rds_clicked(); + void on_copyAudioToUDP_toggled(bool copy); + void on_g14ProgServiceNames_currentIndexChanged(int index); + void on_clearData_clicked(bool checked); + void on_g00AltFrequenciesBox_activated(int index); + void on_g14MappedFrequencies_activated(int index); + void on_g14AltFrequencies_activated(int index); + void onWidgetRolled(QWidget* widget, bool rollDown); + void onMenuDialogCalled(const QPoint& p); + void handleInputMessages(); + void tick(); }; #endif // INCLUDE_BFMDEMODGUI_H