1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

Prepare scope trigger #1

This commit is contained in:
f4exb 2015-07-13 10:46:51 +02:00
parent 5f427454a6
commit 9fa737ec67
6 changed files with 250 additions and 46 deletions

View File

@ -3,6 +3,7 @@
#include "dsp/samplesink.h" #include "dsp/samplesink.h"
#include "util/export.h" #include "util/export.h"
#include "util/message.h"
class GLScope; class GLScope;
class MessageQueue; class MessageQueue;
@ -12,12 +13,15 @@ public:
enum TriggerChannel { enum TriggerChannel {
TriggerFreeRun, TriggerFreeRun,
TriggerChannelI, TriggerChannelI,
TriggerChannelQ TriggerChannelQ,
TriggerMagLin,
TriggerMagDb,
TriggerPhase
}; };
ScopeVis(GLScope* glScope = NULL); ScopeVis(GLScope* glScope = NULL);
void configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevelHigh, Real triggerLevelLow); void configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevel, bool triggerPositiveEdge);
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void start(); void start();
@ -29,6 +33,32 @@ public:
int getSampleRate() const { return m_sampleRate; } int getSampleRate() const { return m_sampleRate; }
private: private:
class MsgConfigureScopeVis : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getTriggerChannel() const { return m_triggerChannel; }
Real getTriggerLevel() const { return m_triggerLevel; }
Real getTriggerPositiveEdge() const { return m_triggerPositiveEdge; }
static MsgConfigureScopeVis* create(int triggerChannel, Real triggerLevel, bool triggerPositiveEdge)
{
return new MsgConfigureScopeVis(triggerChannel, triggerLevel, triggerPositiveEdge);
}
private:
int m_triggerChannel;
Real m_triggerLevel;
bool m_triggerPositiveEdge;
MsgConfigureScopeVis(int triggerChannel, Real triggerLevel, bool triggerPositiveEdge) :
Message(),
m_triggerChannel(triggerChannel),
m_triggerLevel(triggerLevel),
m_triggerPositiveEdge(triggerPositiveEdge)
{ }
};
enum TriggerState { enum TriggerState {
Untriggered, Untriggered,
Triggered, Triggered,
@ -42,6 +72,7 @@ private:
TriggerChannel m_triggerChannel; TriggerChannel m_triggerChannel;
FixReal m_triggerLevelHigh; FixReal m_triggerLevelHigh;
FixReal m_triggerLevelLow; FixReal m_triggerLevelLow;
bool m_triggerPositiveEdge;
int m_sampleRate; int m_sampleRate;
}; };

View File

@ -47,6 +47,9 @@ private:
qint32 m_amplification; qint32 m_amplification;
qint32 m_ampOffset; qint32 m_ampOffset;
int m_displayGridIntensity; int m_displayGridIntensity;
qint32 m_triggerChannel;
Real m_triggerLevel;
bool m_triggerPositiveEdge;
static const qreal amps[11]; static const qreal amps[11];

View File

@ -22,22 +22,4 @@ bool NullSink::handleMessage(Message* message)
{ {
message->completed(); message->completed();
return true; return true;
/*
if(DSPSignalNotification::match(message)) {
DSPSignalNotification* signal = (DSPSignalNotification*)message;
m_sampleRate = signal->getSampleRate();
message->completed();
return true;
} else if(DSPConfigureScopeVis::match(message)) {
DSPConfigureScopeVis* conf = (DSPConfigureScopeVis*)message;
m_triggerState = Untriggered;
m_triggerChannel = (TriggerChannel)conf->getTriggerChannel();
m_triggerLevelHigh = conf->getTriggerLevelHigh() * 32767;
m_triggerLevelLow = conf->getTriggerLevelLow() * 32767;
message->completed();
return true;
} else {
return false;
}
*/
} }

View File

@ -5,6 +5,8 @@
#include <cstdio> #include <cstdio>
MESSAGE_CLASS_DEFINITION(ScopeVis::MsgConfigureScopeVis, Message)
ScopeVis::ScopeVis(GLScope* glScope) : ScopeVis::ScopeVis(GLScope* glScope) :
m_glScope(glScope), m_glScope(glScope),
m_trace(96000), m_trace(96000),
@ -13,20 +15,39 @@ ScopeVis::ScopeVis(GLScope* glScope) :
m_triggerChannel(TriggerFreeRun), m_triggerChannel(TriggerFreeRun),
m_triggerLevelHigh(0.01 * 32768), m_triggerLevelHigh(0.01 * 32768),
m_triggerLevelLow(0.01 * 32768 - 1024), m_triggerLevelLow(0.01 * 32768 - 1024),
m_triggerPositiveEdge(true),
m_sampleRate(0) m_sampleRate(0)
{ {
} }
void ScopeVis::configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevelHigh, Real triggerLevelLow) void ScopeVis::configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevel, bool triggerPositiveEdge)
{ {
Message* cmd = DSPConfigureScopeVis::create(triggerChannel, triggerLevelHigh, triggerLevelLow); Message* cmd = MsgConfigureScopeVis::create(triggerChannel, triggerLevel, triggerPositiveEdge);
cmd->submit(msgQueue, this); cmd->submit(msgQueue, this);
} }
void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{ {
while(begin < end) { while(begin < end)
if(m_triggerChannel == TriggerChannelI) { {
if (m_triggerChannel == TriggerFreeRun)
{
int count = end - begin;
if(count > (int)(m_trace.size() - m_fill))
count = m_trace.size() - m_fill;
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
for(int i = 0; i < count; ++i) {
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
++begin;
}
m_fill += count;
if(m_fill >= m_trace.size()) {
m_glScope->newTrace(m_trace, m_sampleRate);
m_fill = 0;
}
}
else if (m_triggerChannel == TriggerChannelI)
{
if(m_triggerState == Untriggered) { if(m_triggerState == Untriggered) {
while(begin < end) { while(begin < end) {
if(begin->real() >= m_triggerLevelHigh) { if(begin->real() >= m_triggerLevelHigh) {
@ -61,7 +82,9 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter
++begin; ++begin;
} }
} }
} else if(m_triggerChannel == TriggerChannelQ) { }
else if (m_triggerChannel == TriggerChannelQ)
{
if(m_triggerState == Untriggered) { if(m_triggerState == Untriggered) {
while(begin < end) { while(begin < end) {
if(begin->imag() >= m_triggerLevelHigh) { if(begin->imag() >= m_triggerLevelHigh) {
@ -96,20 +119,6 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter
++begin; ++begin;
} }
} }
} else {
int count = end - begin;
if(count > (int)(m_trace.size() - m_fill))
count = m_trace.size() - m_fill;
std::vector<Complex>::iterator it = m_trace.begin() + m_fill;
for(int i = 0; i < count; ++i) {
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
++begin;
}
m_fill += count;
if(m_fill >= m_trace.size()) {
m_glScope->newTrace(m_trace, m_sampleRate);
m_fill = 0;
}
} }
} }
} }
@ -129,13 +138,21 @@ bool ScopeVis::handleMessageKeep(Message* message)
//fprintf(stderr, "ScopeVis::handleMessage @%x : %d samples/sec, %lld Hz offset\n", this, signal->getSampleRate(), signal->getFrequencyOffset()); //fprintf(stderr, "ScopeVis::handleMessage @%x : %d samples/sec, %lld Hz offset\n", this, signal->getSampleRate(), signal->getFrequencyOffset());
m_sampleRate = signal->getSampleRate(); m_sampleRate = signal->getSampleRate();
return true; return true;
} else if(MsgConfigureScopeVis::match(message)) {
MsgConfigureScopeVis* conf = (MsgConfigureScopeVis*)message;
m_triggerState = Untriggered;
m_triggerChannel = (TriggerChannel) conf->getTriggerChannel();
m_triggerLevelHigh = conf->getTriggerLevel() * 32767;
m_triggerPositiveEdge = conf->getTriggerPositiveEdge();
return true;
/*
} else if(DSPConfigureScopeVis::match(message)) { } else if(DSPConfigureScopeVis::match(message)) {
DSPConfigureScopeVis* conf = (DSPConfigureScopeVis*)message; DSPConfigureScopeVis* conf = (DSPConfigureScopeVis*)message;
m_triggerState = Untriggered; m_triggerState = Untriggered;
m_triggerChannel = (TriggerChannel)conf->getTriggerChannel(); m_triggerChannel = (TriggerChannel)conf->getTriggerChannel();
m_triggerLevelHigh = conf->getTriggerLevelHigh() * 32767; m_triggerLevelHigh = conf->getTriggerLevelHigh() * 32767;
m_triggerLevelLow = conf->getTriggerLevelLow() * 32767; m_triggerLevelLow = conf->getTriggerLevelLow() * 32767;
return true; return true;*/
} else { } else {
return false; return false;
} }

View File

@ -24,7 +24,10 @@ GLScopeGUI::GLScopeGUI(QWidget* parent) :
m_timeOffset(0), m_timeOffset(0),
m_amplification(0), m_amplification(0),
m_ampOffset(0), m_ampOffset(0),
m_displayGridIntensity(1) m_displayGridIntensity(1),
m_triggerChannel(ScopeVis::TriggerFreeRun),
m_triggerLevel(0.0),
m_triggerPositiveEdge(true)
{ {
ui->setupUi(this); ui->setupUi(this);
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>807</width> <width>807</width>
<height>34</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -30,7 +30,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="row1Layout">
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
@ -72,7 +72,7 @@
</font> </font>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Grid intensity</string> <string>Displayed data</string>
</property> </property>
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContentsOnFirstShow</enum> <enum>QComboBox::AdjustToContentsOnFirstShow</enum>
@ -253,7 +253,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="tickPosition"> <property name="tickPosition">
<enum>QSlider::TicksBelow</enum> <enum>QSlider::NoTicks</enum>
</property> </property>
<property name="tickInterval"> <property name="tickInterval">
<number>5</number> <number>5</number>
@ -368,7 +368,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="tickPosition"> <property name="tickPosition">
<enum>QSlider::TicksBelow</enum> <enum>QSlider::NoTicks</enum>
</property> </property>
<property name="tickInterval"> <property name="tickInterval">
<number>1</number> <number>1</number>
@ -459,6 +459,174 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="Line" name="rowSep1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="row2Layout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="trigLabel">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Trig.</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="trigMode">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Trigger source</string>
</property>
<item>
<property name="text">
<string>Freerun</string>
</property>
</item>
<item>
<property name="text">
<string>I (lin)</string>
</property>
</item>
<item>
<property name="text">
<string>Q (lin)</string>
</property>
</item>
<item>
<property name="text">
<string>Mag (lin)</string>
</property>
</item>
<item>
<property name="text">
<string>Mag (dB)</string>
</property>
</item>
<item>
<property name="text">
<string>Phi</string>
</property>
</item>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="slopeLayout">
<item>
<widget class="QToolButton" name="slopePos">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Trigger slope positive</string>
</property>
<property name="text">
<string>+</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="slopeNeg">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Trigger slope negative</string>
</property>
<property name="text">
<string>-</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QSlider" name="trigLevel">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Trigger level</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trigText">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>