1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

AM demod: added display of channel power in dB. Changed minus radio button for a iconified toggle button

This commit is contained in:
f4exb 2015-10-04 11:22:37 +02:00
parent 7663a9bc1d
commit bae3632fad
8 changed files with 312 additions and 243 deletions

View File

@ -48,6 +48,7 @@ AMDemod::AMDemod() :
m_movingAverage.resize(16, 0);
m_volumeAGC.resize(4096, 0.003, 0);
m_magsq = 0.0;
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
@ -80,8 +81,9 @@ void AMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector
Real magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
if (m_movingAverage.average() >= m_squelchLevel)
if (m_magsq >= m_squelchLevel)
{
m_squelchState = m_running.m_audioSampleRate / 20;
}

View File

@ -41,6 +41,8 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
private:
class MsgConfigureAMDemod : public Message {
MESSAGE_CLASS_DECLARATION
@ -113,6 +115,7 @@ private:
Real m_squelchLevel;
int m_squelchState;
Real m_magsq;
MovingAverage<Real> m_movingAverage;
SimpleAGC m_volumeAGC;

View File

@ -8,8 +8,10 @@
#include "gui/glspectrum.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h"
#include "mainwindow.h"
#include "amdemod.h"
@ -132,7 +134,7 @@ void AMDemodGUI::viewChanged()
applySettings();
}
void AMDemodGUI::on_deltaMinus_clicked(bool minus)
void AMDemodGUI::on_deltaMinus_toggled(bool minus)
{
int deltaFrequency = m_channelMarker.getCenterFrequency();
bool minusDelta = (deltaFrequency < 0);
@ -201,7 +203,8 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_pluginAPI(pluginAPI),
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true)
m_doApplySettings(true),
m_channelPowerDbAvg(20,0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -212,6 +215,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelizer = new Channelizer(m_amDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -277,3 +281,10 @@ void AMDemodGUI::enterEvent(QEvent*)
blockApplySettings(false);
}
void AMDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_amDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}

View File

@ -4,6 +4,7 @@
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
class PluginAPI;
@ -36,13 +37,14 @@ public:
private slots:
void viewChanged();
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_clicked(bool minus);
void on_deltaMinus_toggled(bool minus);
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 onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();
private:
Ui::AMDemodGUI* ui;
@ -54,6 +56,7 @@ private:
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;
AMDemod* m_amDemod;
MovingAverage<Real> m_channelPowerDbAvg;
static const int m_rfBW[];

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>302</width>
<height>138</height>
<height>390</height>
</rect>
</property>
<property name="focusPolicy">
@ -21,14 +21,17 @@
<rect>
<x>35</x>
<y>35</y>
<width>242</width>
<height>96</height>
<width>106</width>
<height>349</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
@ -41,212 +44,255 @@
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="3" column="1">
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="deltaFrequencyLayout">
<item>
<widget class="QToolButton" name="deltaMinus">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<selectedoff>:/plus.png</selectedoff>
<selectedon>:/minus.png</selectedon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPowerUnits">
<property name="text">
<string> dB</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QSlider" name="rfBW">
<property name="maximum">
<number>8</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="rfBandwidthLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>RF BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<property name="maximum">
<number>8</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>12.5kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="deltaMinus">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Minus</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="afBandwidthLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>AF BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="afBW">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Squelch</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="volumeLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vol</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>2.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>AF Bandwidth</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSlider" name="squelch">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-40</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>12.5kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>RF Bandwidth</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="afBW">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="squelchText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>-40dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Volume</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>2.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="squelchLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Sq</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="squelch">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-40</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="squelchText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>-40dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -265,6 +311,8 @@
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -312,7 +312,6 @@
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
<zorder>hSpacer1</zorder>
</widget>
</item>
<item>
@ -410,6 +409,9 @@
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
@ -530,9 +532,15 @@
</widget>
<customwidgets>
<customwidget>
<class>GLScope</class>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/glscope.h</header>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
@ -548,15 +556,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>RollupWidget</class>
<class>GLScope</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<header>gui/glscope.h</header>
<container>1</container>
</customwidget>
<customwidget>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>302</width>
<height>537</height>
<height>544</height>
</rect>
</property>
<property name="minimumSize">
@ -229,22 +229,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0.3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="lowCut">
<property name="minimum">
@ -264,6 +248,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0.3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -353,10 +353,7 @@
</widget>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true">
<zorder>glSpectrum</zorder>
<zorder>glSpectrum</zorder>
</widget>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
</item>
</layout>
</widget>

View File

@ -99,6 +99,9 @@
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>