From 2b55140d9d4d09752f61880d94937e61e7110dc6 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 13 Dec 2021 08:44:17 +0000 Subject: [PATCH] Display warnings in ADS-B and DAB if sample rate is too low --- plugins/channelrx/demodadsb/adsbdemod.cpp | 4 ++++ plugins/channelrx/demodadsb/adsbdemodgui.cpp | 19 ++++++++++++++++++- plugins/channelrx/demodadsb/adsbdemodgui.ui | 17 ++++++++++++----- plugins/channelrx/demoddab/dabdemodgui.cpp | 12 +++++++++++- plugins/channelrx/demoddab/dabdemodgui.ui | 11 +++++++++-- 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/plugins/channelrx/demodadsb/adsbdemod.cpp b/plugins/channelrx/demodadsb/adsbdemod.cpp index 959e7b1bb..99f81573e 100644 --- a/plugins/channelrx/demodadsb/adsbdemod.cpp +++ b/plugins/channelrx/demodadsb/adsbdemod.cpp @@ -150,6 +150,10 @@ bool ADSBDemod::handleMessage(const Message& cmd) DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy qDebug() << "ADSBDemod::handleMessage: DSPSignalNotification"; m_basebandSink->getInputMessageQueue()->push(rep); + // Forward to GUI if any + if (m_guiMessageQueue) { + m_guiMessageQueue->push(new DSPSignalNotification(notif)); + } return true; } diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp index a8ea98695..41d027e08 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp @@ -46,6 +46,7 @@ #include "gui/crightclickenabler.h" #include "gui/clickablelabel.h" #include "dsp/dspengine.h" +#include "dsp/dspcommands.h" #include "mainwindow.h" #include "adsbdemodreport.h" @@ -1535,7 +1536,20 @@ QString ADSBDemodGUI::subAircraftString(Aircraft *aircraft, const QString &strin bool ADSBDemodGUI::handleMessage(const Message& message) { - if (ADSBDemodReport::MsgReportADSB::match(message)) +if (DSPSignalNotification::match(message)) + { + DSPSignalNotification& notif = (DSPSignalNotification&) message; + bool srTooLow = notif.getSampleRate() < 2000000; + ui->warning->setVisible(srTooLow); + if (srTooLow) { + ui->warning->setText("Sample rate must be >= 2000000"); + } else { + ui->warning->setText(""); + } + arrangeRollups(); + return true; + } + else if (ADSBDemodReport::MsgReportADSB::match(message)) { ADSBDemodReport::MsgReportADSB& report = (ADSBDemodReport::MsgReportADSB&) message; handleADSB( @@ -2542,6 +2556,9 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue); + ui->warning->setVisible(false); + ui->warning->setStyleSheet("QLabel { background-color: red; }"); + ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.ui b/plugins/channelrx/demodadsb/adsbdemodgui.ui index 7856d1513..2df681c6c 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.ui +++ b/plugins/channelrx/demodadsb/adsbdemodgui.ui @@ -744,6 +744,13 @@ + + + + + + + @@ -1276,11 +1283,6 @@ QToolButton
gui/buttonswitch.h
- - ClickableLabel - QLabel -
gui/clickablelabel.h
-
ValueDialZ QWidget @@ -1293,6 +1295,11 @@
gui/levelmeter.h
1
+ + ClickableLabel + QLabel +
gui/clickablelabel.h
+
deltaFrequency diff --git a/plugins/channelrx/demoddab/dabdemodgui.cpp b/plugins/channelrx/demoddab/dabdemodgui.cpp index 975b23ec7..fc5e5bc59 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.cpp +++ b/plugins/channelrx/demoddab/dabdemodgui.cpp @@ -35,7 +35,6 @@ #include "gui/audioselectdialog.h" #include "gui/basicchannelsettingsdialog.h" #include "gui/devicestreamselectiondialog.h" -#include "dsp/dspengine.h" #include "gui/crightclickenabler.h" #include "channel/channelwebapiutils.h" #include "maincore.h" @@ -202,6 +201,14 @@ bool DABDemodGUI::handleMessage(const Message& message) { DSPSignalNotification& notif = (DSPSignalNotification&) message; m_basebandSampleRate = notif.getSampleRate(); + bool srTooLow = m_basebandSampleRate < 2048000; + ui->warning->setVisible(srTooLow); + if (srTooLow) { + ui->warning->setText("Sample rate must be >= 2048000"); + } else { + ui->warning->setText(""); + } + arrangeRollups(); return true; } else if (DABDemod::MsgDABEnsembleName::match(message)) @@ -450,6 +457,9 @@ DABDemodGUI::DABDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms + ui->warning->setVisible(false); + ui->warning->setStyleSheet("QLabel { background-color: red; }"); + ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03))); ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); diff --git a/plugins/channelrx/demoddab/dabdemodgui.ui b/plugins/channelrx/demoddab/dabdemodgui.ui index 929281888..250be1722 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.ui +++ b/plugins/channelrx/demoddab/dabdemodgui.ui @@ -43,7 +43,7 @@ 0 0 390 - 131 + 151 @@ -610,13 +610,20 @@ + + + + + + +
0 - 140 + 160 381 211