From 692686684e9e58deb6ff7ff466b421576029136c Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 27 Mar 2016 05:44:35 +0200 Subject: [PATCH] AM dempd: light audio mute button in green when the squelch is open --- plugins/channel/demodam/amdemod.cpp | 4 +++- plugins/channel/demodam/amdemod.h | 2 ++ plugins/channel/demodam/amdemodgui.cpp | 15 ++++++++++++++- plugins/channel/demodam/amdemodgui.h | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/channel/demodam/amdemod.cpp b/plugins/channel/demodam/amdemod.cpp index 54fe75e28..669b13135 100644 --- a/plugins/channel/demodam/amdemod.cpp +++ b/plugins/channel/demodam/amdemod.cpp @@ -28,6 +28,7 @@ MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureAMDemod, Message) AMDemod::AMDemod() : + m_squelchOpen(false), m_audioFifo(4, 48000), m_settingsMutex(QMutex::Recursive) { @@ -124,11 +125,12 @@ void AMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector demod *= ((0.003 * attack) / m_volumeAGC.getValue()); demod *= m_running.m_volume; sample = demod * 32700 * 16; - + m_squelchOpen = true; } else { sample = 0; + m_squelchOpen = false; } m_audioBuffer[m_audioBufferFill].l = sample; diff --git a/plugins/channel/demodam/amdemod.h b/plugins/channel/demodam/amdemod.h index 5e5f37b4c..b37095a69 100644 --- a/plugins/channel/demodam/amdemod.h +++ b/plugins/channel/demodam/amdemod.h @@ -42,6 +42,7 @@ public: virtual bool handleMessage(const Message& cmd); Real getMagSq() const { return m_magsq; } + bool getSquelchOpen() const { return m_squelchOpen; } private: class MsgConfigureAMDemod : public Message { @@ -120,6 +121,7 @@ private: Real m_squelchLevel; int m_squelchCount; + bool m_squelchOpen; Real m_magsq; MovingAverage m_movingAverage; diff --git a/plugins/channel/demodam/amdemodgui.cpp b/plugins/channel/demodam/amdemodgui.cpp index e439cdd56..04ec9cdf5 100644 --- a/plugins/channel/demodam/amdemodgui.cpp +++ b/plugins/channel/demodam/amdemodgui.cpp @@ -207,7 +207,8 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) : m_channelMarker(this), m_basicSettingsShown(false), m_doApplySettings(true), - m_channelPowerDbAvg(20,0) + m_channelPowerDbAvg(20,0), + m_squelchOpen(false) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); @@ -290,5 +291,17 @@ void AMDemodGUI::tick() Real powDb = CalcDb::dbPower(m_amDemod->getMagSq()); m_channelPowerDbAvg.feed(powDb); ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); + bool squelchOpen = m_amDemod->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/demodam/amdemodgui.h b/plugins/channel/demodam/amdemodgui.h index 12477a389..d920485fd 100644 --- a/plugins/channel/demodam/amdemodgui.h +++ b/plugins/channel/demodam/amdemodgui.h @@ -58,6 +58,7 @@ private: Channelizer* m_channelizer; AMDemod* m_amDemod; MovingAverage m_channelPowerDbAvg; + bool m_squelchOpen; static const int m_rfBW[];