mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
Channel Analyzer: display trace max and average power. Interim state #1
This commit is contained in:
parent
681863b2a2
commit
ed6e078cff
@ -91,6 +91,9 @@ private:
|
||||
std::vector<Complex> m_rawTrace;
|
||||
std::vector<Complex> m_mathTrace;
|
||||
std::vector<Complex>* m_displayTrace;
|
||||
std::vector<Real> m_powTrace;
|
||||
Real m_maxPow;
|
||||
Real m_sumPow;
|
||||
int m_oldTraceSize;
|
||||
int m_sampleRate;
|
||||
Real m_amp1;
|
||||
@ -110,6 +113,7 @@ private:
|
||||
ScopeVis::TriggerChannel m_triggerChannel;
|
||||
Real m_triggerLevel;
|
||||
Real m_triggerPre;
|
||||
int m_nbPow;
|
||||
|
||||
// graphics stuff
|
||||
QRectF m_glScopeRect1;
|
||||
@ -145,6 +149,7 @@ private:
|
||||
|
||||
void handleMode();
|
||||
void applyConfig();
|
||||
void drawPowerOverlay();
|
||||
|
||||
protected slots:
|
||||
void tick();
|
||||
|
@ -6,12 +6,13 @@
|
||||
#include <algorithm>
|
||||
#include <QDebug>
|
||||
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
static double log2f(double n)
|
||||
{
|
||||
return log(n) / log(2.0);
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
GLScope::GLScope(QWidget* parent) :
|
||||
QGLWidget(parent),
|
||||
@ -360,7 +361,8 @@ void GLScope::paintGL()
|
||||
}
|
||||
|
||||
// paint trace
|
||||
if(m_displayTrace->size() > 0) {
|
||||
if(m_displayTrace->size() > 0)
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0, 0);
|
||||
glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp1, 1);
|
||||
@ -375,20 +377,55 @@ void GLScope::paintGL()
|
||||
start--;
|
||||
float posLimit = 1.0 / m_amp1;
|
||||
float negLimit = -1.0 / m_amp1;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for(int i = start; i < end; i++) {
|
||||
|
||||
for(int i = start; i < end; i++)
|
||||
{
|
||||
float v = (*m_displayTrace)[i].real() + m_ofs1;
|
||||
if(v > posLimit)
|
||||
v = posLimit;
|
||||
else if(v < negLimit)
|
||||
v = negLimit;
|
||||
glVertex2f(i - start, v);
|
||||
|
||||
if (m_mode == ModeMagdBPha)
|
||||
{
|
||||
if (i == start)
|
||||
{
|
||||
m_maxPow = m_powTrace[i];
|
||||
m_sumPow = m_powTrace[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_powTrace[i] > m_maxPow)
|
||||
{
|
||||
m_maxPow = m_powTrace[i];
|
||||
}
|
||||
|
||||
m_sumPow += m_powTrace[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_nbPow = end - start;
|
||||
|
||||
glEnd();
|
||||
|
||||
//glDisable(GL_LINE_SMOOTH);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
// Paint powers overlays
|
||||
|
||||
if (m_mode == ModeMagdBPha)
|
||||
{
|
||||
if (m_nbPow > 0)
|
||||
{
|
||||
qDebug("%.1f %.1f", 10.0f * log10f(m_maxPow), 10.0f * log10f(m_sumPow / m_nbPow));
|
||||
}
|
||||
}
|
||||
|
||||
// paint trigger time line if pretriggered
|
||||
/*
|
||||
if ((m_triggerPre > 0.0) &&
|
||||
@ -716,11 +753,15 @@ void GLScope::handleMode()
|
||||
}
|
||||
case ModeMagdBPha: {
|
||||
m_mathTrace.resize(m_rawTrace.size());
|
||||
m_powTrace.resize(m_rawTrace.size());
|
||||
std::vector<Complex>::iterator dst = m_mathTrace.begin();
|
||||
Real mult = (10.0f / log2f(10.0f));
|
||||
std::vector<Real>::iterator powDst = m_powTrace.begin();
|
||||
//Real mult = (10.0f / log2f(10.0f));
|
||||
for(std::vector<Complex>::const_iterator src = m_rawTrace.begin(); src != m_rawTrace.end(); ++src) {
|
||||
Real v = src->real() * src->real() + src->imag() * src->imag();
|
||||
v = (100.0 - m_ofs*100.0 + (mult * log2f(v))) / 100.0; // TODO: first term is the offset
|
||||
*powDst++ = v;
|
||||
//v = (100.0 - m_ofs*100.0 + (mult * log2f(v))) / 100.0; // TODO: first term is the offset
|
||||
v = (100.0f - m_ofs*100.0f + (10.0f * log10f(v))) / 100.0f; // TODO: first term is the offset
|
||||
*dst++ = Complex(v, arg(*src) / M_PI);
|
||||
}
|
||||
m_displayTrace = &m_mathTrace;
|
||||
@ -764,6 +805,11 @@ void GLScope::handleMode()
|
||||
}
|
||||
}
|
||||
|
||||
void GLScope::drawPowerOverlay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GLScope::applyConfig()
|
||||
{
|
||||
m_configChanged = false;
|
||||
|
Loading…
Reference in New Issue
Block a user