From 8a41edf24df9a24d4e6e6912d5a21da90ec3c6e1 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 14 Jul 2015 00:04:34 +0200 Subject: [PATCH] Scope falling edge trigger --- include-gpl/dsp/scopevis.h | 1 + sdrbase/dsp/scopevis.cpp | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include-gpl/dsp/scopevis.h b/include-gpl/dsp/scopevis.h index 7a44a3482..ec59f0f27 100644 --- a/include-gpl/dsp/scopevis.h +++ b/include-gpl/dsp/scopevis.h @@ -72,6 +72,7 @@ private: TriggerChannel m_triggerChannel; Real m_triggerLevel; bool m_triggerPositiveEdge; + bool m_armed; int m_sampleRate; bool triggerCondition(SampleVector::const_iterator& it); diff --git a/sdrbase/dsp/scopevis.cpp b/sdrbase/dsp/scopevis.cpp index 87f9ad69e..fe2eaccc6 100644 --- a/sdrbase/dsp/scopevis.cpp +++ b/sdrbase/dsp/scopevis.cpp @@ -16,6 +16,7 @@ ScopeVis::ScopeVis(GLScope* glScope) : m_triggerChannel(TriggerFreeRun), m_triggerLevel(0.0), m_triggerPositiveEdge(true), + m_armed(false), m_sampleRate(0) { } @@ -48,16 +49,25 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter } else { - if(m_triggerState == Untriggered) { - while(begin < end) { - if (triggerCondition(begin)) { - m_triggerState = Triggered; - break; + if(m_triggerState == Untriggered) + { + while(begin < end) + { + if (triggerCondition(begin) ^ !m_triggerPositiveEdge) { + if (m_armed) { + m_triggerState = Triggered; + m_armed = false; + break; + } + } + else { + m_armed = true; } ++begin; } } - if(m_triggerState == Triggered) { + if(m_triggerState == Triggered) + { int count = end - begin; if(count > (int)(m_trace.size() - m_fill)) count = m_trace.size() - m_fill;