1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-07-22 10:45:24 -04:00

GLScope: trigger on phase derivative (instantaneous frequebcy)

This commit is contained in:
f4exb 2015-11-04 04:29:26 +01:00
parent 2305357324
commit 1c7bab1762
4 changed files with 55 additions and 11 deletions

View File

@ -17,7 +17,8 @@ public:
TriggerChannelQ, TriggerChannelQ,
TriggerMagLin, TriggerMagLin,
TriggerMagDb, TriggerMagDb,
TriggerPhase TriggerPhase,
TriggerDPhase
}; };
static const uint m_traceChunkSize; static const uint m_traceChunkSize;
@ -149,6 +150,8 @@ private:
uint m_triggerDelayCount; //!< trace sizes delay counter uint m_triggerDelayCount; //!< trace sizes delay counter
int m_sampleRate; int m_sampleRate;
SampleVector::const_iterator m_triggerPoint; SampleVector::const_iterator m_triggerPoint;
Real m_prevArg;
bool m_firstArg;
bool triggerCondition(SampleVector::const_iterator& it); bool triggerCondition(SampleVector::const_iterator& it);
bool nextTrigger(); //!< move to next trigger. Returns true if next trigger is active. bool nextTrigger(); //!< move to next trigger. Returns true if next trigger is active.

View File

@ -21,7 +21,9 @@ ScopeVis::ScopeVis(GLScope* glScope) :
m_triggerDelayCount(0), m_triggerDelayCount(0),
m_triggerOneShot(false), m_triggerOneShot(false),
m_armed(false), m_armed(false),
m_sampleRate(0) m_sampleRate(0),
m_prevArg(0.0),
m_firstArg(true)
{ {
setObjectName("ScopeVis"); setObjectName("ScopeVis");
m_trace.reserve(100*m_traceChunkSize); m_trace.reserve(100*m_traceChunkSize);
@ -276,6 +278,11 @@ bool ScopeVis::handleMessage(const Message& message)
m_triggerBothEdges[index] = conf.getTriggerBothEdges(); m_triggerBothEdges[index] = conf.getTriggerBothEdges();
m_triggerPre = conf.getTriggerPre(); m_triggerPre = conf.getTriggerPre();
if (m_triggerChannel[index] == TriggerDPhase)
{
m_firstArg = true;
}
if (m_triggerPre >= m_traceback.size()) if (m_triggerPre >= m_traceback.size())
{ {
m_triggerPre = m_traceback.size() - 1; // top sample in FIFO is always the triggering one (pre-trigger delay = 0) m_triggerPre = m_traceback.size() - 1; // top sample in FIFO is always the triggering one (pre-trigger delay = 0)
@ -322,28 +329,56 @@ bool ScopeVis::triggerCondition(SampleVector::const_iterator& it)
Complex c(it->real()/32768.0f, it->imag()/32768.0f); Complex c(it->real()/32768.0f, it->imag()/32768.0f);
m_traceback.push_back(c); // store into trace memory FIFO m_traceback.push_back(c); // store into trace memory FIFO
if (m_tracebackCount < m_traceback.size()) { // increment count up to trace memory size if (m_tracebackCount < m_traceback.size())
{ // increment count up to trace memory size
m_tracebackCount++; m_tracebackCount++;
} }
if (m_triggerChannel[m_triggerIndex] == TriggerChannelI) { if (m_triggerChannel[m_triggerIndex] == TriggerChannelI)
{
return c.real() > m_triggerLevel[m_triggerIndex]; return c.real() > m_triggerLevel[m_triggerIndex];
} }
else if (m_triggerChannel[m_triggerIndex] == TriggerChannelQ) { else if (m_triggerChannel[m_triggerIndex] == TriggerChannelQ)
{
return c.imag() > m_triggerLevel[m_triggerIndex]; return c.imag() > m_triggerLevel[m_triggerIndex];
} }
else if (m_triggerChannel[m_triggerIndex] == TriggerMagLin) { else if (m_triggerChannel[m_triggerIndex] == TriggerMagLin)
{
return abs(c) > m_triggerLevel[m_triggerIndex]; return abs(c) > m_triggerLevel[m_triggerIndex];
} }
else if (m_triggerChannel[m_triggerIndex] == TriggerMagDb) { else if (m_triggerChannel[m_triggerIndex] == TriggerMagDb)
{
Real mult = (10.0f / log2f(10.0f)); Real mult = (10.0f / log2f(10.0f));
Real v = c.real() * c.real() + c.imag() * c.imag(); Real v = c.real() * c.real() + c.imag() * c.imag();
return mult * log2f(v) > m_triggerLevel[m_triggerIndex]; return mult * log2f(v) > m_triggerLevel[m_triggerIndex];
} }
else if (m_triggerChannel[m_triggerIndex] == TriggerPhase) { else if (m_triggerChannel[m_triggerIndex] == TriggerPhase)
{
return arg(c) / M_PI > m_triggerLevel[m_triggerIndex]; return arg(c) / M_PI > m_triggerLevel[m_triggerIndex];
} }
else { else if (m_triggerChannel[m_triggerIndex] == TriggerDPhase)
{
Real curArg = arg(c) - m_prevArg;
m_prevArg = arg(c);
if (curArg < -M_PI) {
curArg += 2.0 * M_PI;
} else if (curArg > M_PI) {
curArg -= 2.0 * M_PI;
}
if (m_firstArg)
{
m_firstArg = false;
return false;
}
else
{
return curArg / M_PI > m_triggerLevel[m_triggerIndex];
}
}
else
{
return false; return false;
} }
} }

View File

@ -546,7 +546,7 @@ void GLScope::paintGL()
glPopMatrix(); glPopMatrix();
// paint trigger level #2 // paint trigger level #2
if ((m_triggerChannel == ScopeVis::TriggerPhase) || (m_triggerChannel == ScopeVis::TriggerChannelQ)) if ((m_triggerChannel == ScopeVis::TriggerPhase) || (m_triggerChannel == ScopeVis::TriggerDPhase) || (m_triggerChannel == ScopeVis::TriggerChannelQ))
{ {
glPushMatrix(); glPushMatrix();
glTranslatef(m_glScopeRect2.x(), m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0, 0); glTranslatef(m_glScopeRect2.x(), m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0, 0);
@ -562,7 +562,8 @@ void GLScope::paintGL()
float negLimit = -1.0 / m_amp2; float negLimit = -1.0 / m_amp2;
if ((m_triggerChannel == ScopeVis::TriggerChannelQ) if ((m_triggerChannel == ScopeVis::TriggerChannelQ)
|| (m_triggerChannel == ScopeVis::TriggerPhase)) || (m_triggerChannel == ScopeVis::TriggerPhase)
|| (m_triggerChannel == ScopeVis::TriggerDPhase))
{ {
if ((m_triggerLevelDis2 > negLimit) && (m_triggerLevelDis2 < posLimit)) if ((m_triggerLevelDis2 > negLimit) && (m_triggerLevelDis2 < posLimit))
{ {

View File

@ -828,6 +828,11 @@
<string>Phi</string> <string>Phi</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>dPhi</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>