1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-18 14:21:49 -05:00

GLScope: chained multiple triggers: interim state #3: multiple triggers array in UI

This commit is contained in:
f4exb 2015-11-05 01:34:21 +01:00
parent 2917f015ea
commit 8ac778714d
2 changed files with 120 additions and 63 deletions

View File

@ -5,13 +5,13 @@
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#include "util/export.h" #include "util/export.h"
#include "util/message.h" #include "util/message.h"
#include "dsp/scopevis.h"
namespace Ui { namespace Ui {
class GLScopeGUI; class GLScopeGUI;
} }
class MessageQueue; class MessageQueue;
class ScopeVis;
class GLScope; class GLScope;
class SDRANGEL_API GLScopeGUI : public QWidget { class SDRANGEL_API GLScopeGUI : public QWidget {
@ -53,14 +53,14 @@ private:
int m_displayGridIntensity; int m_displayGridIntensity;
int m_displayTraceIntensity; int m_displayTraceIntensity;
quint32 m_triggerIndex; quint32 m_triggerIndex;
qint32 m_triggerChannel; qint32 m_triggerChannel[ScopeVis::m_nbTriggers];
qint32 m_triggerLevelCoarse; // percent of full range qint32 m_triggerLevelCoarse[ScopeVis::m_nbTriggers]; // percent of full range
qint32 m_triggerLevelFine; // percent of coarse qint32 m_triggerLevelFine[ScopeVis::m_nbTriggers]; // percent of coarse
bool m_triggerPositiveEdge; bool m_triggerPositiveEdge[ScopeVis::m_nbTriggers];
bool m_triggerBothEdges; bool m_triggerBothEdges[ScopeVis::m_nbTriggers];
qint32 m_triggerPre; qint32 m_triggerPre;
qint32 m_triggerDelay; qint32 m_triggerDelay[ScopeVis::m_nbTriggers];
qint32 m_triggerCounts; qint32 m_triggerCounts[ScopeVis::m_nbTriggers];
qint32 m_traceLenMult; qint32 m_traceLenMult;
static const qreal amps[11]; static const qreal amps[11];
@ -77,6 +77,7 @@ private:
void setTrigLevelDisplay(); void setTrigLevelDisplay();
void setTrigPreDisplay(); void setTrigPreDisplay();
void setTrigDelayDisplay(); void setTrigDelayDisplay();
void setTrigUI(uint index);
private slots: private slots:
void on_amp1_valueChanged(int value); void on_amp1_valueChanged(int value);

View File

@ -30,16 +30,20 @@ GLScopeGUI::GLScopeGUI(QWidget* parent) :
m_displayGridIntensity(1), m_displayGridIntensity(1),
m_displayTraceIntensity(50), m_displayTraceIntensity(50),
m_triggerIndex(0), m_triggerIndex(0),
m_triggerChannel(ScopeVis::TriggerFreeRun),
m_triggerLevelCoarse(0),
m_triggerLevelFine(0),
m_triggerPositiveEdge(true),
m_triggerBothEdges(false),
m_triggerPre(0), m_triggerPre(0),
m_triggerDelay(0),
m_triggerCounts(0),
m_traceLenMult(20) m_traceLenMult(20)
{ {
for (int i = 0; i < ScopeVis::m_nbTriggers; i++)
{
m_triggerChannel[i] = ScopeVis::TriggerFreeRun;
m_triggerLevelCoarse[i] = 0;
m_triggerLevelFine[i] = 0;
m_triggerPositiveEdge[i] = true;
m_triggerBothEdges[i] = false;
m_triggerDelay[i] = 0;
m_triggerCounts[i] = 0;
}
ui->setupUi(this); ui->setupUi(this);
} }
@ -77,13 +81,20 @@ void GLScopeGUI::resetToDefaults()
m_amp2OffsetCoarse = 0; m_amp2OffsetCoarse = 0;
m_amp2OffsetFine = 0; m_amp2OffsetFine = 0;
m_displayGridIntensity = 5; m_displayGridIntensity = 5;
m_triggerChannel = ScopeVis::TriggerFreeRun;
m_triggerLevelCoarse = 0;
m_triggerLevelFine = 0;
m_triggerPositiveEdge = true;
m_triggerPre = 0; m_triggerPre = 0;
m_triggerDelay = 0;
m_traceLenMult = 20; m_traceLenMult = 20;
for (int i = 0; i < ScopeVis::m_nbTriggers; i++)
{
m_triggerChannel[i] = ScopeVis::TriggerFreeRun;
m_triggerLevelCoarse[i] = 0;
m_triggerLevelFine[i] = 0;
m_triggerPositiveEdge[i] = true;
m_triggerBothEdges[i] = false;
m_triggerDelay[i] = 0;
m_triggerCounts[i] = 0;
}
applySettings(); applySettings();
} }
@ -99,20 +110,31 @@ QByteArray GLScopeGUI::serialize() const
s.writeS32(6, m_displayGridIntensity); s.writeS32(6, m_displayGridIntensity);
s.writeS32(7, m_amp1OffsetCoarse); s.writeS32(7, m_amp1OffsetCoarse);
s.writeS32(8, m_displays); s.writeS32(8, m_displays);
s.writeS32(9, m_triggerChannel); //s.writeS32(9, m_triggerChannel);
s.writeS32(10, m_triggerLevelCoarse); //s.writeS32(10, m_triggerLevelCoarse);
s.writeBool(11, m_triggerPositiveEdge); //s.writeBool(11, m_triggerPositiveEdge);
s.writeS32(12, m_displayTraceIntensity); s.writeS32(12, m_displayTraceIntensity);
s.writeS32(13, m_triggerPre); s.writeS32(13, m_triggerPre);
s.writeS32(14, m_traceLenMult); s.writeS32(14, m_traceLenMult);
s.writeS32(15, m_triggerDelay); //s.writeS32(15, m_triggerDelay);
s.writeBool(16, m_triggerBothEdges); //s.writeBool(16, m_triggerBothEdges);
s.writeS32(17, m_triggerLevelFine); //s.writeS32(17, m_triggerLevelFine);
s.writeS32(18, m_amp1OffsetFine); s.writeS32(18, m_amp1OffsetFine);
s.writeS32(19, m_amplification2); s.writeS32(19, m_amplification2);
s.writeS32(20, m_amp2OffsetCoarse); s.writeS32(20, m_amp2OffsetCoarse);
s.writeS32(21, m_amp2OffsetFine); s.writeS32(21, m_amp2OffsetFine);
for (int i = 0; i < ScopeVis::m_nbTriggers; i++)
{
s.writeS32(50 + 10*i, m_triggerChannel[i]);
s.writeS32(51 + 10*i, m_triggerLevelCoarse[i]);
s.writeS32(52 + 10*i, m_triggerLevelFine[i]);
s.writeBool(53 + 10*i, m_triggerPositiveEdge[i]);
s.writeBool(54 + 10*i, m_triggerBothEdges[i]);
s.writeS32(55 + 10*i, m_triggerDelay[i]);
s.writeS32(56 + 10*i, m_triggerCounts[i]);
}
return s.final(); return s.final();
} }
@ -136,11 +158,11 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
m_timeBase = 1; m_timeBase = 1;
d.readS32(7, &m_amp1OffsetCoarse, 0); d.readS32(7, &m_amp1OffsetCoarse, 0);
d.readS32(8, &m_displays, GLScope::DisplayBoth); d.readS32(8, &m_displays, GLScope::DisplayBoth);
d.readS32(9, &m_triggerChannel, ScopeVis::TriggerFreeRun); //d.readS32(9, &m_triggerChannel, ScopeVis::TriggerFreeRun);
ui->trigMode->setCurrentIndex(m_triggerChannel); //ui->trigMode->setCurrentIndex(m_triggerChannel);
d.readS32(10, &m_triggerLevelCoarse, 0); //d.readS32(10, &m_triggerLevelCoarse, 0);
ui->trigLevelCoarse->setValue(m_triggerLevelCoarse); //ui->trigLevelCoarse->setValue(m_triggerLevelCoarse);
d.readBool(11, &m_triggerPositiveEdge, true); //d.readBool(11, &m_triggerPositiveEdge, true);
d.readS32(12, &m_displayTraceIntensity, 50); d.readS32(12, &m_displayTraceIntensity, 50);
d.readS32(13, &m_triggerPre, 0); d.readS32(13, &m_triggerPre, 0);
ui->trigPre->setValue(m_triggerPre); ui->trigPre->setValue(m_triggerPre);
@ -148,11 +170,12 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
d.readS32(14, &m_traceLenMult, 20); d.readS32(14, &m_traceLenMult, 20);
ui->traceLen->setValue(m_traceLenMult); ui->traceLen->setValue(m_traceLenMult);
setTraceLenDisplay(); setTraceLenDisplay();
d.readS32(15, &m_triggerDelay, 0); //d.readS32(15, &m_triggerDelay, 0);
ui->trigDelay->setValue(m_triggerDelay); //ui->trigDelay->setValue(m_triggerDelay);
setTrigDelayDisplay(); setTrigDelayDisplay();
d.readBool(16, &m_triggerBothEdges, false); //d.readBool(16, &m_triggerBothEdges, false);
/*
if (m_triggerBothEdges) { if (m_triggerBothEdges) {
ui->slopePos->setChecked(false); ui->slopePos->setChecked(false);
ui->slopeNeg->setChecked(false); ui->slopeNeg->setChecked(false);
@ -161,15 +184,27 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
ui->slopeBoth->setChecked(false); ui->slopeBoth->setChecked(false);
ui->slopePos->setChecked(m_triggerPositiveEdge); ui->slopePos->setChecked(m_triggerPositiveEdge);
ui->slopeNeg->setChecked(!m_triggerPositiveEdge); ui->slopeNeg->setChecked(!m_triggerPositiveEdge);
} }*/
d.readS32(17, &m_triggerLevelFine, 0); //d.readS32(17, &m_triggerLevelFine, 0);
ui->trigLevelFine->setValue(m_triggerLevelFine); //ui->trigLevelFine->setValue(m_triggerLevelFine);
d.readS32(18, &m_amp1OffsetFine, 0); d.readS32(18, &m_amp1OffsetFine, 0);
d.readS32(19, &m_amplification2, 0); d.readS32(19, &m_amplification2, 0);
d.readS32(20, &m_amp2OffsetCoarse, 0); d.readS32(20, &m_amp2OffsetCoarse, 0);
d.readS32(21, &m_amp2OffsetFine, 0); d.readS32(21, &m_amp2OffsetFine, 0);
for (int i = 0; i < ScopeVis::m_nbTriggers; i++)
{
d.readS32(50 + 10*i, &m_triggerChannel[i], ScopeVis::TriggerFreeRun);
d.readS32(51 + 10*i, &m_triggerLevelCoarse[i], 0);
d.readS32(52 + 10*i, &m_triggerLevelFine[i], 0);
d.readBool(53 + 10*i, &m_triggerPositiveEdge[i], true);
d.readBool(54 + 10*i, &m_triggerBothEdges[i], false);
d.readS32(55 + 10*i, &m_triggerDelay[i], 0);
d.readS32(56 + 10*i, &m_triggerCounts[i], 0);
}
setTrigUI(0);
setTrigLevelDisplay(); setTrigLevelDisplay();
applySettings(); applySettings();
applyTriggerSettings(); applyTriggerSettings();
@ -180,6 +215,27 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
} }
} }
void GLScopeGUI::setTrigUI(uint index)
{
index %= ScopeVis::m_nbTriggers;
ui->trigMode->setCurrentIndex(m_triggerChannel[index]);
ui->trigLevelCoarse->setValue(m_triggerLevelCoarse[index]);
ui->trigLevelFine->setValue(m_triggerLevelFine[index]);
ui->trigDelay->setValue(m_triggerDelay[index]);
ui->trigCount->setValue(m_triggerCounts[index]);
if (m_triggerBothEdges[index]) {
ui->slopePos->setChecked(false);
ui->slopeNeg->setChecked(false);
ui->slopeBoth->setChecked(true);
} else {
ui->slopeBoth->setChecked(false);
ui->slopePos->setChecked(m_triggerPositiveEdge[index]);
ui->slopeNeg->setChecked(!m_triggerPositiveEdge[index]);
}
}
void GLScopeGUI::applySettings() void GLScopeGUI::applySettings()
{ {
ui->dataMode->setCurrentIndex(m_displayData); ui->dataMode->setCurrentIndex(m_displayData);
@ -229,51 +285,51 @@ void GLScopeGUI::applySettings()
void GLScopeGUI::applyTriggerSettings() void GLScopeGUI::applyTriggerSettings()
{ {
qreal t = (m_triggerLevelCoarse / 100.0) + (m_triggerLevelFine / 20000.0); // [-1.0, 1.0] qreal t = (m_triggerLevelCoarse[m_triggerIndex] / 100.0) + (m_triggerLevelFine[m_triggerIndex] / 20000.0); // [-1.0, 1.0]
qreal triggerLevel; qreal triggerLevel;
quint32 preTriggerSamples = (m_glScope->getTraceSize() * m_triggerPre) / 100; quint32 preTriggerSamples = (m_glScope->getTraceSize() * m_triggerPre) / 100;
if (m_triggerChannel == ScopeVis::TriggerMagDb) { if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagDb) {
triggerLevel = 100.0 * (t - 1.0); // [-200.0, 0.0] triggerLevel = 100.0 * (t - 1.0); // [-200.0, 0.0]
} }
else if (m_triggerChannel == ScopeVis::TriggerMagLin) { else if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagLin) {
triggerLevel = 1.0 + t; // [0.0, 2.0] triggerLevel = 1.0 + t; // [0.0, 2.0]
} }
else { else {
triggerLevel = t; // [-1.0, 1.0] triggerLevel = t; // [-1.0, 1.0]
} }
m_glScope->setTriggerChannel((ScopeVis::TriggerChannel) m_triggerChannel); m_glScope->setTriggerChannel((ScopeVis::TriggerChannel) m_triggerChannel[m_triggerIndex]);
m_glScope->setTriggerLevel(t); // [-1.0, 1.0] m_glScope->setTriggerLevel(t); // [-1.0, 1.0]
m_glScope->setTriggerPre(m_triggerPre/100.0); // [0.0, 1.0] m_glScope->setTriggerPre(m_triggerPre/100.0); // [0.0, 1.0]
m_scopeVis->configure(m_messageQueue, m_scopeVis->configure(m_messageQueue,
0, // FIXME: trigger index m_triggerIndex,
(ScopeVis::TriggerChannel) m_triggerChannel, (ScopeVis::TriggerChannel) m_triggerChannel[m_triggerIndex],
triggerLevel, triggerLevel,
m_triggerPositiveEdge, m_triggerPositiveEdge[m_triggerIndex],
m_triggerBothEdges, m_triggerBothEdges[m_triggerIndex],
preTriggerSamples, preTriggerSamples,
m_triggerDelay, m_triggerDelay[m_triggerIndex],
m_triggerCounts, m_triggerCounts[m_triggerIndex],
m_traceLenMult * ScopeVis::m_traceChunkSize); m_traceLenMult * ScopeVis::m_traceChunkSize);
} }
void GLScopeGUI::setTrigLevelDisplay() void GLScopeGUI::setTrigLevelDisplay()
{ {
qreal t = (m_triggerLevelCoarse / 100.0) + (m_triggerLevelFine / 20000.0); qreal t = (m_triggerLevelCoarse[m_triggerIndex] / 100.0) + (m_triggerLevelFine[m_triggerIndex] / 20000.0);
ui->trigLevelCoarse->setToolTip(QString("Trigger level coarse: %1 %").arg(m_triggerLevelCoarse)); ui->trigLevelCoarse->setToolTip(QString("Trigger level coarse: %1 %").arg(m_triggerLevelCoarse[m_triggerIndex]));
ui->trigLevelFine->setToolTip(QString("Trigger level fine: %1 ppm").arg(m_triggerLevelFine * 50)); ui->trigLevelFine->setToolTip(QString("Trigger level fine: %1 ppm").arg(m_triggerLevelFine[m_triggerIndex] * 50));
if (m_triggerChannel == ScopeVis::TriggerMagDb) { if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagDb) {
ui->trigText->setText(tr("%1\ndB").arg(100.0 * (t - 1.0), 0, 'f', 1)); ui->trigText->setText(tr("%1\ndB").arg(100.0 * (t - 1.0), 0, 'f', 1));
} }
else else
{ {
qreal a; qreal a;
if (m_triggerChannel == ScopeVis::TriggerMagLin) { if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagLin) {
a = 1.0 + t; a = 1.0 + t;
} else { } else {
a = t; a = t;
@ -503,7 +559,7 @@ void GLScopeGUI::setTraceLenDisplay()
void GLScopeGUI::setTrigDelayDisplay() void GLScopeGUI::setTrigDelayDisplay()
{ {
uint n_samples_delay = m_traceLenMult * ScopeVis::m_traceChunkSize * m_triggerDelay; uint n_samples_delay = m_traceLenMult * ScopeVis::m_traceChunkSize * m_triggerDelay[m_triggerIndex];
if (n_samples_delay < 1000) { if (n_samples_delay < 1000) {
ui->trigDelayText->setToolTip(tr("%1S").arg(n_samples_delay)); ui->trigDelayText->setToolTip(tr("%1S").arg(n_samples_delay));
@ -600,7 +656,7 @@ void GLScopeGUI::on_trigDelay_valueChanged(int value)
if ((value < 0) || (value > 100)) { if ((value < 0) || (value > 100)) {
return; return;
} }
m_triggerDelay = value; m_triggerDelay[m_triggerIndex] = value;
setTrigDelayDisplay(); setTrigDelayDisplay();
applyTriggerSettings(); applyTriggerSettings();
} }
@ -720,21 +776,21 @@ void GLScopeGUI::on_traceIntensity_valueChanged(int index)
void GLScopeGUI::on_trigMode_currentIndexChanged(int index) void GLScopeGUI::on_trigMode_currentIndexChanged(int index)
{ {
m_triggerChannel = index; m_triggerChannel[m_triggerIndex] = index;
setTrigLevelDisplay(); setTrigLevelDisplay();
applyTriggerSettings(); applyTriggerSettings();
} }
void GLScopeGUI::on_trigLevelCoarse_valueChanged(int value) void GLScopeGUI::on_trigLevelCoarse_valueChanged(int value)
{ {
m_triggerLevelCoarse = value; m_triggerLevelCoarse[m_triggerIndex] = value;
setTrigLevelDisplay(); setTrigLevelDisplay();
applyTriggerSettings(); applyTriggerSettings();
} }
void GLScopeGUI::on_trigLevelFine_valueChanged(int value) void GLScopeGUI::on_trigLevelFine_valueChanged(int value)
{ {
m_triggerLevelFine = value; m_triggerLevelFine[m_triggerIndex] = value;
setTrigLevelDisplay(); setTrigLevelDisplay();
applyTriggerSettings(); applyTriggerSettings();
} }
@ -753,7 +809,7 @@ void GLScopeGUI::on_memHistory_valueChanged(int value)
void GLScopeGUI::on_trigCount_valueChanged(int value) void GLScopeGUI::on_trigCount_valueChanged(int value)
{ {
m_triggerCounts = value; m_triggerCounts[m_triggerIndex] = value;
QString text; QString text;
text.sprintf("%02d", value); text.sprintf("%02d", value);
@ -764,8 +820,8 @@ void GLScopeGUI::on_trigCount_valueChanged(int value)
void GLScopeGUI::on_slopePos_clicked() void GLScopeGUI::on_slopePos_clicked()
{ {
m_triggerPositiveEdge = true; m_triggerPositiveEdge[m_triggerIndex] = true;
m_triggerBothEdges = false; m_triggerBothEdges[m_triggerIndex] = false;
ui->slopeBoth->setChecked(false); ui->slopeBoth->setChecked(false);
@ -780,8 +836,8 @@ void GLScopeGUI::on_slopePos_clicked()
void GLScopeGUI::on_slopeNeg_clicked() void GLScopeGUI::on_slopeNeg_clicked()
{ {
m_triggerPositiveEdge = false; m_triggerPositiveEdge[m_triggerIndex] = false;
m_triggerBothEdges = false; m_triggerBothEdges[m_triggerIndex] = false;
ui->slopeBoth->setChecked(false); ui->slopeBoth->setChecked(false);
@ -800,7 +856,7 @@ void GLScopeGUI::on_slopeBoth_clicked()
ui->slopePos->setChecked(false); ui->slopePos->setChecked(false);
ui->slopeNeg->setChecked(false); ui->slopeNeg->setChecked(false);
ui->slopeBoth->setChecked(true); ui->slopeBoth->setChecked(true);
m_triggerBothEdges = true; m_triggerBothEdges[m_triggerIndex] = true;
applyTriggerSettings(); applyTriggerSettings();
} }