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:
parent
5f427454a6
commit
9fa737ec67
@ -3,6 +3,7 @@
|
||||
|
||||
#include "dsp/samplesink.h"
|
||||
#include "util/export.h"
|
||||
#include "util/message.h"
|
||||
|
||||
class GLScope;
|
||||
class MessageQueue;
|
||||
@ -12,12 +13,15 @@ public:
|
||||
enum TriggerChannel {
|
||||
TriggerFreeRun,
|
||||
TriggerChannelI,
|
||||
TriggerChannelQ
|
||||
TriggerChannelQ,
|
||||
TriggerMagLin,
|
||||
TriggerMagDb,
|
||||
TriggerPhase
|
||||
};
|
||||
|
||||
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 start();
|
||||
@ -29,6 +33,32 @@ public:
|
||||
int getSampleRate() const { return m_sampleRate; }
|
||||
|
||||
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 {
|
||||
Untriggered,
|
||||
Triggered,
|
||||
@ -42,6 +72,7 @@ private:
|
||||
TriggerChannel m_triggerChannel;
|
||||
FixReal m_triggerLevelHigh;
|
||||
FixReal m_triggerLevelLow;
|
||||
bool m_triggerPositiveEdge;
|
||||
int m_sampleRate;
|
||||
};
|
||||
|
||||
|
@ -47,6 +47,9 @@ private:
|
||||
qint32 m_amplification;
|
||||
qint32 m_ampOffset;
|
||||
int m_displayGridIntensity;
|
||||
qint32 m_triggerChannel;
|
||||
Real m_triggerLevel;
|
||||
bool m_triggerPositiveEdge;
|
||||
|
||||
static const qreal amps[11];
|
||||
|
||||
|
@ -22,22 +22,4 @@ bool NullSink::handleMessage(Message* message)
|
||||
{
|
||||
message->completed();
|
||||
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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(ScopeVis::MsgConfigureScopeVis, Message)
|
||||
|
||||
ScopeVis::ScopeVis(GLScope* glScope) :
|
||||
m_glScope(glScope),
|
||||
m_trace(96000),
|
||||
@ -13,20 +15,39 @@ ScopeVis::ScopeVis(GLScope* glScope) :
|
||||
m_triggerChannel(TriggerFreeRun),
|
||||
m_triggerLevelHigh(0.01 * 32768),
|
||||
m_triggerLevelLow(0.01 * 32768 - 1024),
|
||||
m_triggerPositiveEdge(true),
|
||||
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);
|
||||
}
|
||||
|
||||
void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||
{
|
||||
while(begin < end) {
|
||||
if(m_triggerChannel == TriggerChannelI) {
|
||||
while(begin < end)
|
||||
{
|
||||
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) {
|
||||
while(begin < end) {
|
||||
if(begin->real() >= m_triggerLevelHigh) {
|
||||
@ -61,7 +82,9 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
++begin;
|
||||
}
|
||||
}
|
||||
} else if(m_triggerChannel == TriggerChannelQ) {
|
||||
}
|
||||
else if (m_triggerChannel == TriggerChannelQ)
|
||||
{
|
||||
if(m_triggerState == Untriggered) {
|
||||
while(begin < end) {
|
||||
if(begin->imag() >= m_triggerLevelHigh) {
|
||||
@ -96,20 +119,6 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
++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());
|
||||
m_sampleRate = signal->getSampleRate();
|
||||
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)) {
|
||||
DSPConfigureScopeVis* conf = (DSPConfigureScopeVis*)message;
|
||||
m_triggerState = Untriggered;
|
||||
m_triggerChannel = (TriggerChannel)conf->getTriggerChannel();
|
||||
m_triggerLevelHigh = conf->getTriggerLevelHigh() * 32767;
|
||||
m_triggerLevelLow = conf->getTriggerLevelLow() * 32767;
|
||||
return true;
|
||||
return true;*/
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ GLScopeGUI::GLScopeGUI(QWidget* parent) :
|
||||
m_timeOffset(0),
|
||||
m_amplification(0),
|
||||
m_ampOffset(0),
|
||||
m_displayGridIntensity(1)
|
||||
m_displayGridIntensity(1),
|
||||
m_triggerChannel(ScopeVis::TriggerFreeRun),
|
||||
m_triggerLevel(0.0),
|
||||
m_triggerPositiveEdge(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>807</width>
|
||||
<height>34</height>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -30,7 +30,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="row1Layout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
@ -72,7 +72,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Grid intensity</string>
|
||||
<string>Displayed data</string>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContentsOnFirstShow</enum>
|
||||
@ -253,7 +253,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>5</number>
|
||||
@ -368,7 +368,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
@ -459,6 +459,174 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</widget>
|
||||
<resources>
|
||||
|
Loading…
Reference in New Issue
Block a user