1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

ATV Demodulator: implemented channel power display

This commit is contained in:
f4exb 2017-03-16 18:56:20 +01:00
parent 701c853cff
commit 72943911d9
4 changed files with 38 additions and 5 deletions

View File

@ -59,6 +59,8 @@ ATVDemod::ATVDemod() :
m_blnInitialized=false;
m_intNumberOfRowsToDisplay=0;
m_objMagSqAverage.resize(16, 1.0);
memset((void*)m_fltBufferI,0,6*sizeof(float));
memset((void*)m_fltBufferQ,0,6*sizeof(float));
@ -239,9 +241,12 @@ void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
//********** demodulation **********
fltNorm = sqrt(fltI*fltI + fltQ*fltQ);
double magSq = fltI*fltI + fltQ*fltQ;
m_objMagSqAverage.feed(magSq);
if(m_enmModulation!=ATV_AM)
fltNorm = sqrt(magSq);
if ((m_enmModulation == ATV_FM1) || (m_enmModulation == ATV_FM2))
{
//Amplitude FM
@ -290,7 +295,7 @@ void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_fltBufferQ[0]=fltNormQ;
}
else
else if (m_enmModulation == ATV_AM)
{
//Amplitude AM
fltVal = fltNorm;
@ -311,6 +316,10 @@ void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
fltVal -= m_fltAmpMin;
fltVal /=m_fltAmpDelta;
}
else
{
fltVal = 0.0f;
}
m_fltAmpLineAverage += fltVal;

View File

@ -101,6 +101,7 @@ public:
bool blnHSync,
bool blnVSync);
int GetSampleRate();
double getMagSq() const { return m_objMagSqAverage.average(); } //!< Beware this is scaled to 2^30
private:
@ -144,6 +145,10 @@ private:
int m_intColIndex;
int m_intRowIndex;
//*************** RF ***************
MovingAverage<double> m_objMagSqAverage;
//QElapsedTimer m_objTimer;
private:

View File

@ -181,6 +181,7 @@ void ATVDemodGUI::viewChanged()
void ATVDemodGUI::channelSampleRateChanged()
{
qDebug("ATVDemodGUI::channelSampleRateChanged");
ui->channelSampleRateText->setText(tr("%1k").arg(m_objChannelizer->getInputSampleRate()/1000.0f, 0, 'f', 0));
applySettings();
}
@ -207,7 +208,8 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI,
m_objDeviceAPI(objDeviceAPI),
m_objChannelMarker(this),
m_blnBasicSettingsShown(false),
m_blnDoApplySettings(true)
m_blnDoApplySettings(true),
m_intTickCount(0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -221,7 +223,7 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI,
m_objThreadedChannelizer = new ThreadedBasebandSampleSink(m_objChannelizer, this);
m_objDeviceAPI->addThreadedSink(m_objThreadedChannelizer);
//connect(&m_objPluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
connect(&m_objPluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
@ -332,6 +334,21 @@ void ATVDemodGUI::enterEvent(QEvent*)
void ATVDemodGUI::tick()
{
if (m_intTickCount < 10) // ~500 ms
{
m_intTickCount++;
}
else
{
if (m_objATVDemod)
{
double magSqDB = CalcDb::dbPower(m_objATVDemod->getMagSq() / (1<<30));
ui->channePowerText->setText(tr("%1 dB").arg(magSqDB, 0, 'f', 1));
}
m_intTickCount = 0;
}
return;
}

View File

@ -85,6 +85,8 @@ private:
bool m_blnBasicSettingsShown;
bool m_blnDoApplySettings;
int m_intTickCount;
explicit ATVDemodGUI(PluginAPI* objPluginAPI, DeviceSourceAPI *objDeviceAPI, QWidget* objParent = NULL);
virtual ~ATVDemodGUI();