From 7c3cebf2e145c07526c46e79697d0ff17167e6e8 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 5 Dec 2016 02:09:08 +0100 Subject: [PATCH] NFM Demod: added signal meter. Corrected squelch. Turned frequency dial green --- plugins/channelrx/demodam/amdemodgui.cpp | 2 +- plugins/channelrx/demodam/amdemodgui.ui | 40 +++++--------- plugins/channelrx/demodnfm/nfmdemod.cpp | 17 +++++- plugins/channelrx/demodnfm/nfmdemod.h | 13 +++++ plugins/channelrx/demodnfm/nfmdemodgui.cpp | 42 +++++++++++--- plugins/channelrx/demodnfm/nfmdemodgui.h | 1 + plugins/channelrx/demodnfm/nfmdemodgui.ui | 61 ++++++++++++++++++--- plugins/channelrx/demodnfm/nfmplugin.cpp | 2 +- sdrbase/resources/minusrx.png | Bin 0 -> 231 bytes sdrbase/resources/plusrx.png | Bin 0 -> 373 bytes sdrbase/resources/res.qrc | 2 + 11 files changed, 132 insertions(+), 48 deletions(-) create mode 100644 sdrbase/resources/minusrx.png create mode 100644 sdrbase/resources/plusrx.png diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index ff39731d4..30966dc26 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -234,7 +234,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms - ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); + ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGreenYellow)); ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenYellow); //m_channelMarker = new ChannelMarker(this); diff --git a/plugins/channelrx/demodam/amdemodgui.ui b/plugins/channelrx/demodam/amdemodgui.ui index 2ce7a430d..d6cf1d3d6 100644 --- a/plugins/channelrx/demodam/amdemodgui.ui +++ b/plugins/channelrx/demodam/amdemodgui.ui @@ -6,10 +6,16 @@ 0 0 - 303 + 302 170 + + + 302 + 0 + + Sans Serif @@ -25,15 +31,15 @@ - 10 - 10 - 280 + 0 + 0 + 300 131 - 280 + 300 0 @@ -61,8 +67,8 @@ - :/plus.png - :/minus.png + :/plusrx.png + :/minusrx.png @@ -366,26 +372,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/channelrx/demodnfm/nfmdemod.cpp b/plugins/channelrx/demodnfm/nfmdemod.cpp index 4e778194c..c89f0fb78 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.cpp +++ b/plugins/channelrx/demodnfm/nfmdemod.cpp @@ -38,6 +38,9 @@ NFMDemod::NFMDemod() : m_agcAttack(2400), m_audioMute(false), m_squelchOpen(false), + m_magsqSum(0.0f), + m_magsqPeak(0.0f), + m_magsqCount(0), m_afSquelch(2, afSqTones), m_audioFifo(4, 48000), m_fmExcursion(2400), @@ -146,6 +149,16 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto qint16 sample; m_AGC.feed(ci); + Real magsq = m_AGC.getMagSq(); + magsq /= (1<<30); + m_magsqSum += magsq; + + if (magsq > m_magsqPeak) + { + m_magsqPeak = magsq; + } + + m_magsqCount++; Real demod = m_phaseDiscri.phaseDiscriminator2(ci); @@ -155,7 +168,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto // AF processing - if (getMag() > m_squelchLevel) + if (m_AGC.getAverage()/(1<<30) > m_squelchLevel) { if (m_squelchCount < m_agcAttack) { @@ -369,7 +382,7 @@ void NFMDemod::apply() if (m_config.m_squelch != m_running.m_squelch) { // input is a value in tenths of dB - m_squelchLevel = std::pow(10.0, m_config.m_squelch / 200.0); + m_squelchLevel = std::pow(10.0, m_config.m_squelch / 10.0); //m_squelchLevel *= m_squelchLevel; m_afSquelch.setThreshold(m_squelchLevel); } diff --git a/plugins/channelrx/demodnfm/nfmdemod.h b/plugins/channelrx/demodnfm/nfmdemod.h index 66f7d5f9d..fa03ccabc 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.h +++ b/plugins/channelrx/demodnfm/nfmdemod.h @@ -71,6 +71,16 @@ public: Real getMag() { return m_AGC.getAverage() / (1<<15); } bool getSquelchOpen() const { return m_squelchOpen; } + void getMagSqLevels(Real& avg, Real& peak, int& nbSamples) + { + avg = m_magsqSum / m_magsqCount; + peak = m_magsqPeak; + nbSamples = m_magsqCount; + m_magsqSum = 0.0f; + m_magsqPeak = 0.0f; + m_magsqCount = 0; + } + private: class MsgConfigureNFMDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -187,6 +197,9 @@ private: double m_squelchLevel; bool m_squelchOpen; + Real m_magsqSum; + Real m_magsqPeak; + int m_magsqCount; Real m_lastArgument; //Complex m_m1Sample; diff --git a/plugins/channelrx/demodnfm/nfmdemodgui.cpp b/plugins/channelrx/demodnfm/nfmdemodgui.cpp index e85cdee26..f5290b412 100644 --- a/plugins/channelrx/demodnfm/nfmdemodgui.cpp +++ b/plugins/channelrx/demodnfm/nfmdemodgui.cpp @@ -291,7 +291,8 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg ui->ctcss->addItem(QString("%1").arg(ctcss_tones[i])); } - ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); + ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGreenYellow)); + ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenYellow); m_channelizer = new DownChannelizer(m_nfmDemod); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); @@ -337,15 +338,15 @@ void NFMDemodGUI::applySettings() ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency())); ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0); - ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0, 0, 'f', 0)); + ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0f, 0, 'f', 0)); m_nfmDemod->configure(m_nfmDemod->getInputMessageQueue(), m_rfBW[ui->rfBW->currentIndex()], - ui->afBW->value() * 1000.0, + ui->afBW->value() * 1000.0f, m_fmDev[ui->rfBW->currentIndex()], - ui->volume->value() / 10.0, + ui->volume->value() / 10.0f, ui->squelchGate->value(), // in 10ths of ms - ui->squelch->value(), + ui->squelch->value() / 10.0f, ui->ctcssOn->isChecked(), ui->audioMute->isChecked()); } @@ -384,10 +385,33 @@ void NFMDemodGUI::blockApplySettings(bool block) void NFMDemodGUI::tick() { - Real powDb = CalcDb::dbPower(m_nfmDemod->getMag()) * 2; - m_channelPowerDbAvg.feed(powDb); - ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); - bool squelchOpen = m_nfmDemod->getSquelchOpen(); + if (m_powerMeterTickCount < 4) // 200 ms + { + m_powerMeterTickCount++; + } + else + { + Real magsqAvg, magsqPeak; + int nbMagsqSamples; + m_nfmDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); + Real powDbAvg = CalcDb::dbPower(magsqAvg); + Real powDbPeak = CalcDb::dbPower(magsqPeak); + + ui->channelPowerMeter->levelChanged( + (100.0f + powDbAvg) / 100.0f, + (100.0f + powDbPeak) / 100.0f, + nbMagsqSamples); + + ui->channelPower->setText(QString::number(powDbAvg, 'f', 1)); + + m_powerMeterTickCount = 0; + } + +// Real powDb = CalcDb::dbPower(m_nfmDemod->getMag()) * 2; +// m_channelPowerDbAvg.feed(powDb); +// ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); + + bool squelchOpen = m_nfmDemod->getSquelchOpen(); if (squelchOpen != m_squelchOpen) { diff --git a/plugins/channelrx/demodnfm/nfmdemodgui.h b/plugins/channelrx/demodnfm/nfmdemodgui.h index f8c3cab9c..eca7dc176 100644 --- a/plugins/channelrx/demodnfm/nfmdemodgui.h +++ b/plugins/channelrx/demodnfm/nfmdemodgui.h @@ -69,6 +69,7 @@ private: bool m_ctcssOn; bool m_audioMute; bool m_squelchOpen; + int m_powerMeterTickCount; MovingAverage m_channelPowerDbAvg; static const int m_rfBW[]; diff --git a/plugins/channelrx/demodnfm/nfmdemodgui.ui b/plugins/channelrx/demodnfm/nfmdemodgui.ui index c4882340a..3b069da09 100644 --- a/plugins/channelrx/demodnfm/nfmdemodgui.ui +++ b/plugins/channelrx/demodnfm/nfmdemodgui.ui @@ -6,10 +6,16 @@ 0 0 - 287 - 156 + 302 + 178 + + + 302 + 0 + + Sans Serif @@ -24,10 +30,16 @@ 0 0 - 271 + 300 141 + + + 300 + 0 + + Settings @@ -52,8 +64,8 @@ - :/plus.png - :/minus.png + :/plusrx.png + :/minusrx.png @@ -143,6 +155,36 @@ + + + + + + dB + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + Level meter (dB) light: average, dark: peak, tip: peak hold + + + + + @@ -522,9 +564,6 @@ - settingsContainer - afBW - afBWText @@ -539,6 +578,12 @@
gui/valuedial.h
1
+ + LevelMeterSignalDB + QWidget +
gui/levelmeter.h
+ 1 +
diff --git a/plugins/channelrx/demodnfm/nfmplugin.cpp b/plugins/channelrx/demodnfm/nfmplugin.cpp index 9c6b9aa5f..73b0a90c1 100644 --- a/plugins/channelrx/demodnfm/nfmplugin.cpp +++ b/plugins/channelrx/demodnfm/nfmplugin.cpp @@ -7,7 +7,7 @@ const PluginDescriptor NFMPlugin::m_pluginDescriptor = { QString("NFM Demodulator"), - QString("2.0.0"), + QString("2.4.0"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/sdrbase/resources/minusrx.png b/sdrbase/resources/minusrx.png new file mode 100644 index 0000000000000000000000000000000000000000..5e62a1268e78e3cf014713924573f5d41c01997e GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHhz^Dt>FVdQ&MBb@0L;=*tN;K2 literal 0 HcmV?d00001 diff --git a/sdrbase/resources/plusrx.png b/sdrbase/resources/plusrx.png new file mode 100644 index 0000000000000000000000000000000000000000..ced7d638e32055e8240f138e657f86c80964f8be GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt_f1s;*b zKpodXn9)gNb_Gz7y~NYkmHhz^D!tX)3=E7+o-U3d9>?Ea+33aWD8Tk0-y}?v zMKth8h*;F^h^Sk)IPF@d9<@Dq)vh^T(QID}hgehZN>#5#YT3e$eY@`*%oH{{d+7iB zGy8Xce%~_dL{QEHDRtIYiv1-4)Auj2+jT?xV0C2IyLb+j9`6qyr)2A1&=O;+SNhQA z8Tt9M$NSQg6PH>XddU;M<`K_p)<4YQmrc7$Kep~Z5oD8G-S(8}w5sca&Ci(hW#4S8 zcr;aNpSiqV)t}?P{AK4n-f*aELmPLF=m$kT!&L?cSiWCOh^JKx(b<(t0&mNO zM1DEGuRGF&ohfjm{;VhFf)b13oA^I@G^;JY{6Sx4@#pMU_nu7rRl4(jdZLBt!n=a& QfdRze>FVdQ&MBb@0IztPJOBUy literal 0 HcmV?d00001 diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index ceb6f6791..23c920318 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -1,5 +1,7 @@ + minusrx.png + plusrx.png microphone.png checkmark.png questionmark.png