From 2c38a8b9a07e46bcd61ac333a27c8399643c8adf Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 27 Mar 2016 05:37:15 +0200 Subject: [PATCH] NFM dempd: light audio mute button in green when the squelch is open --- plugins/channel/demodnfm/nfmdemod.cpp | 6 +++--- plugins/channel/demodnfm/nfmdemod.h | 2 ++ plugins/channel/demodnfm/nfmdemodgui.cpp | 13 +++++++++++++ plugins/channel/demodnfm/nfmdemodgui.h | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/channel/demodnfm/nfmdemod.cpp b/plugins/channel/demodnfm/nfmdemod.cpp index 3621b1bf9..677ca19fb 100644 --- a/plugins/channel/demodnfm/nfmdemod.cpp +++ b/plugins/channel/demodnfm/nfmdemod.cpp @@ -36,6 +36,7 @@ NFMDemod::NFMDemod() : m_squelchCount(0), m_agcAttack(2400), m_audioMute(false), + m_squelchOpen(false), m_afSquelch(2, afSqTones), m_audioFifo(4, 48000), m_fmExcursion(2400), @@ -122,7 +123,6 @@ Real angleDist(Real a, Real b) void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst) { - bool squelchOpen; Complex ci; m_settingsMutex.lock(); @@ -162,7 +162,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto } //squelchOpen = (getMag() > m_squelchLevel); - squelchOpen = m_squelchCount == m_agcAttack; // wait for AGC to stabilize + m_squelchOpen = m_squelchCount == m_agcAttack; // wait for AGC to stabilize /* if (m_afSquelch.analyze(demod)) @@ -170,7 +170,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto squelchOpen = m_afSquelch.evaluate(); }*/ - if ((squelchOpen) && !m_running.m_audioMute) + if ((m_squelchOpen) && !m_running.m_audioMute) //if (m_AGC.getAverage() > m_squelchLevel) { if (m_running.m_ctcssOn) diff --git a/plugins/channel/demodnfm/nfmdemod.h b/plugins/channel/demodnfm/nfmdemod.h index 55cc4b593..e24eb59a6 100644 --- a/plugins/channel/demodnfm/nfmdemod.h +++ b/plugins/channel/demodnfm/nfmdemod.h @@ -67,6 +67,7 @@ public: } Real getMag() { return m_AGC.getAverage() / (1<<15); } + bool getSquelchOpen() const { return m_squelchOpen; } private: class MsgConfigureNFMDemod : public Message { @@ -169,6 +170,7 @@ private: bool m_audioMute; double m_squelchLevel; + bool m_squelchOpen; Real m_lastArgument; //Complex m_m1Sample; diff --git a/plugins/channel/demodnfm/nfmdemodgui.cpp b/plugins/channel/demodnfm/nfmdemodgui.cpp index fe8cf450d..9f93bab8f 100644 --- a/plugins/channel/demodnfm/nfmdemodgui.cpp +++ b/plugins/channel/demodnfm/nfmdemodgui.cpp @@ -240,6 +240,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : m_channelMarker(this), m_basicSettingsShown(false), m_doApplySettings(true), + m_squelchOpen(false), m_channelPowerDbAvg(20,0) { ui->setupUi(this); @@ -353,4 +354,16 @@ 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 (squelchOpen != m_squelchOpen) + { + m_squelchOpen = squelchOpen; + + if (m_squelchOpen) { + ui->audioMute->setStyleSheet("QToolButton { background-color : green; }"); + } else { + ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); + } + } } diff --git a/plugins/channel/demodnfm/nfmdemodgui.h b/plugins/channel/demodnfm/nfmdemodgui.h index 0d9a7fa15..e044a8f00 100644 --- a/plugins/channel/demodnfm/nfmdemodgui.h +++ b/plugins/channel/demodnfm/nfmdemodgui.h @@ -63,6 +63,7 @@ private: NFMDemod* m_nfmDemod; bool m_ctcssOn; bool m_audioMute; + bool m_squelchOpen; MovingAverage m_channelPowerDbAvg; static const int m_rfBW[];