1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-19 14:51:47 -05:00

GLScope: individual settings for channels 1 and 2. Fine and Coarse sliders for Y offsets.

This commit is contained in:
f4exb 2015-11-01 06:27:39 +01:00
parent 1a7610a7e4
commit 98125ce93a
4 changed files with 211 additions and 71 deletions

View File

@ -58,6 +58,8 @@ public:
void setDSPEngine(DSPEngine* dspEngine); void setDSPEngine(DSPEngine* dspEngine);
void setAmp1(Real amp); void setAmp1(Real amp);
void setAmp1Ofs(Real ampOfs); void setAmp1Ofs(Real ampOfs);
void setAmp2(Real amp);
void setAmp2Ofs(Real ampOfs);
void setTimeBase(int timeBase); void setTimeBase(int timeBase);
void setTimeOfsProMill(int timeOfsProMill); void setTimeOfsProMill(int timeOfsProMill);
void setMode(Mode mode); void setMode(Mode mode);
@ -110,8 +112,8 @@ private:
ScopeVis* m_scopeVis; ScopeVis* m_scopeVis;
// config // config
Real m_amp; //Real m_amp;
Real m_ofs; //Real m_ofs;
int m_timeBase; int m_timeBase;
int m_timeOfsProMill; int m_timeOfsProMill;
ScopeVis::TriggerChannel m_triggerChannel; ScopeVis::TriggerChannel m_triggerChannel;

View File

@ -47,6 +47,9 @@ private:
qint32 m_amplification1; qint32 m_amplification1;
qint32 m_amp1OffsetCoarse; qint32 m_amp1OffsetCoarse;
qint32 m_amp1OffsetFine; qint32 m_amp1OffsetFine;
qint32 m_amplification2;
qint32 m_amp2OffsetCoarse;
qint32 m_amp2OffsetFine;
int m_displayGridIntensity; int m_displayGridIntensity;
int m_displayTraceIntensity; int m_displayTraceIntensity;
qint32 m_triggerChannel; qint32 m_triggerChannel;
@ -67,6 +70,8 @@ private:
void setTimeOfsDisplay(); void setTimeOfsDisplay();
void setAmp1ScaleDisplay(); void setAmp1ScaleDisplay();
void setAmp1OfsDisplay(); void setAmp1OfsDisplay();
void setAmp2ScaleDisplay();
void setAmp2OfsDisplay();
void setTrigLevelDisplay(); void setTrigLevelDisplay();
void setTrigPreDisplay(); void setTrigPreDisplay();
void setTrigDelayDisplay(); void setTrigDelayDisplay();
@ -75,6 +80,9 @@ private slots:
void on_amp1_valueChanged(int value); void on_amp1_valueChanged(int value);
void on_amp1OfsCoarse_valueChanged(int value); void on_amp1OfsCoarse_valueChanged(int value);
void on_amp1OfsFine_valueChanged(int value); void on_amp1OfsFine_valueChanged(int value);
void on_amp2_valueChanged(int value);
void on_amp2OfsCoarse_valueChanged(int value);
void on_amp2OfsFine_valueChanged(int value);
void on_scope_traceSizeChanged(int value); void on_scope_traceSizeChanged(int value);
void on_scope_sampleRateChanged(int value); void on_scope_sampleRateChanged(int value);
void on_time_valueChanged(int value); void on_time_valueChanged(int value);

View File

@ -30,8 +30,8 @@ GLScope::GLScope(QWidget* parent) :
m_ofs2(0.0), m_ofs2(0.0),
m_dspEngine(NULL), m_dspEngine(NULL),
m_scopeVis(NULL), m_scopeVis(NULL),
m_amp(1.0), //m_amp(1.0),
m_ofs(0.0), //m_ofs(0.0),
m_timeBase(1), m_timeBase(1),
m_timeOfsProMill(0), m_timeOfsProMill(0),
m_triggerChannel(ScopeVis::TriggerFreeRun), m_triggerChannel(ScopeVis::TriggerFreeRun),
@ -91,7 +91,6 @@ void GLScope::setSampleRate(int sampleRate) {
void GLScope::setAmp1(Real amp) void GLScope::setAmp1(Real amp)
{ {
qDebug("GLScope::setAmp1: %f", amp); qDebug("GLScope::setAmp1: %f", amp);
m_amp = amp;
m_amp1 = amp; m_amp1 = amp;
m_configChanged = true; m_configChanged = true;
update(); update();
@ -100,12 +99,27 @@ void GLScope::setAmp1(Real amp)
void GLScope::setAmp1Ofs(Real ampOfs) void GLScope::setAmp1Ofs(Real ampOfs)
{ {
qDebug("GLScope::setAmp1Ofs: %f", ampOfs); qDebug("GLScope::setAmp1Ofs: %f", ampOfs);
m_ofs = ampOfs;
m_ofs1 = ampOfs; m_ofs1 = ampOfs;
m_configChanged = true; m_configChanged = true;
update(); update();
} }
void GLScope::setAmp2(Real amp)
{
qDebug("GLScope::setAmp2: %f", amp);
m_amp2 = amp;
m_configChanged = true;
update();
}
void GLScope::setAmp2Ofs(Real ampOfs)
{
qDebug("GLScope::setAmp2Ofs: %f", ampOfs);
m_ofs2 = ampOfs;
m_configChanged = true;
update();
}
void GLScope::setTimeBase(int timeBase) void GLScope::setTimeBase(int timeBase)
{ {
m_timeBase = timeBase; m_timeBase = timeBase;
@ -535,8 +549,20 @@ void GLScope::paintGL()
glLineWidth(1.0f); glLineWidth(1.0f);
glColor4f(0, 1, 0, m_displayTraceIntensity / 100.0); glColor4f(0, 1, 0, m_displayTraceIntensity / 100.0);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f(0, m_triggerLevel);
glVertex2f(1, m_triggerLevel); float posLimit = 1.0 / m_amp2;
float negLimit = -1.0 / m_amp2;
if ((m_triggerChannel == ScopeVis::TriggerChannelQ)
|| (m_triggerChannel == ScopeVis::TriggerPhase))
{
if ((m_triggerLevelDis2 > negLimit) && (m_triggerLevelDis2 < posLimit))
{
glVertex2f(0, m_triggerLevelDis2);
glVertex2f(1, m_triggerLevelDis2);
}
}
glEnd(); glEnd();
//glDisable(GL_LINE_SMOOTH); //glDisable(GL_LINE_SMOOTH);
glPopMatrix(); glPopMatrix();
@ -640,16 +666,14 @@ void GLScope::handleMode()
m_displayTrace = &m_rawTrace; m_displayTrace = &m_rawTrace;
for(std::vector<Complex>::const_iterator src = m_rawTrace.begin(); src != m_rawTrace.end(); ++src) { for(std::vector<Complex>::const_iterator src = m_rawTrace.begin(); src != m_rawTrace.end(); ++src) {
*dst++ = Complex(src->real() - m_ofs1, src->imag() - m_ofs1); *dst++ = Complex(src->real() - m_ofs1, src->imag() - m_ofs2);
} }
m_triggerLevelDis1 = m_triggerLevel - m_ofs1; m_triggerLevelDis1 = m_triggerLevel - m_ofs1;
m_triggerLevelDis2 = m_triggerLevel - m_ofs2;
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = m_amp;
//m_amp2 = m_amp;
//m_ofs1 = m_ofs;
//m_ofs2 = m_ofs;
break; break;
} }
case ModeMagLinPha: case ModeMagLinPha:
@ -659,16 +683,14 @@ void GLScope::handleMode()
for(std::vector<Complex>::const_iterator src = m_rawTrace.begin(); src != m_rawTrace.end(); ++src) for(std::vector<Complex>::const_iterator src = m_rawTrace.begin(); src != m_rawTrace.end(); ++src)
{ {
*dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, arg(*src) / M_PI); *dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, (arg(*src) / M_PI) - m_ofs2);
} }
m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1; m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1;
m_triggerLevelDis2 = m_triggerLevel - m_ofs2;
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = m_amp;
m_amp2 = 1.0;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
break; break;
} }
case ModeMagdBPha: case ModeMagdBPha:
@ -682,17 +704,15 @@ void GLScope::handleMode()
Real v = src->real() * src->real() + src->imag() * src->imag(); Real v = src->real() * src->real() + src->imag() * src->imag();
*powDst++ = v; *powDst++ = v;
v = 1.0f + 2.0f*(((10.0f*log10f(v))/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; v = 1.0f + 2.0f*(((10.0f*log10f(v))/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1;
*dst++ = Complex(v, arg(*src) / M_PI); *dst++ = Complex(v, (arg(*src) / M_PI) - m_ofs2);
} }
Real tdB = (m_triggerLevel - 1) * 100.0f; Real tdB = (m_triggerLevel - 1) * 100.0f;
m_triggerLevelDis1 = 1.0f + 2.0f*(((tdB)/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; m_triggerLevelDis1 = 1.0f + 2.0f*(((tdB)/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1;
m_triggerLevelDis2 = m_triggerLevel - m_ofs2;
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = 2.0 * m_amp;
m_amp2 = 1.0;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
break; break;
} }
case ModeMagLinDPha: case ModeMagLinDPha:
@ -711,17 +731,15 @@ void GLScope::handleMode()
curArg -= 2.0 * M_PI; curArg -= 2.0 * M_PI;
} }
*dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, curArg / M_PI); *dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, (curArg / M_PI) - m_ofs2);
m_prevArg = arg(*src); m_prevArg = arg(*src);
} }
m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1; m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1;
m_triggerLevelDis2 = m_triggerLevel - m_ofs2;
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = m_amp;
m_amp2 = 1.0;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
break; break;
} }
case ModeMagdBDPha: case ModeMagdBDPha:
@ -745,46 +763,50 @@ void GLScope::handleMode()
curArg -= 2.0 * M_PI; curArg -= 2.0 * M_PI;
} }
*dst++ = Complex(v, curArg / M_PI); *dst++ = Complex(v, (curArg / M_PI) - m_ofs2);
m_prevArg = arg(*src); m_prevArg = arg(*src);
} }
Real tdB = (m_triggerLevel - 1) * 100.0f;
m_triggerLevelDis1 = 1.0f + 2.0f*(((tdB)/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1;
m_triggerLevelDis2 = m_triggerLevel - m_ofs2;
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = 2.0 * m_amp;
m_amp2 = 1.0;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
break; break;
} }
case ModeDerived12: { case ModeDerived12:
if(m_rawTrace.size() > 3) { {
if(m_rawTrace.size() > 3)
{
m_mathTrace.resize(m_rawTrace.size() - 3); m_mathTrace.resize(m_rawTrace.size() - 3);
std::vector<Complex>::iterator dst = m_mathTrace.begin(); std::vector<Complex>::iterator dst = m_mathTrace.begin();
for(uint i = 3; i < m_rawTrace.size() ; i++) {
for(uint i = 3; i < m_rawTrace.size() ; i++)
{
*dst++ = Complex( *dst++ = Complex(
abs(m_rawTrace[i] - m_rawTrace[i - 1]), abs(m_rawTrace[i] - m_rawTrace[i - 1]),
abs(m_rawTrace[i] - m_rawTrace[i - 1]) - abs(m_rawTrace[i - 2] - m_rawTrace[i - 3])); abs(m_rawTrace[i] - m_rawTrace[i - 1]) - abs(m_rawTrace[i - 2] - m_rawTrace[i - 3]));
} }
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = m_amp;
m_amp2 = m_amp;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
} }
break; break;
} }
case ModeCyclostationary: { case ModeCyclostationary:
if(m_rawTrace.size() > 2) { {
if(m_rawTrace.size() > 2)
{
m_mathTrace.resize(m_rawTrace.size() - 2); m_mathTrace.resize(m_rawTrace.size() - 2);
std::vector<Complex>::iterator dst = m_mathTrace.begin(); std::vector<Complex>::iterator dst = m_mathTrace.begin();
for(uint i = 2; i < m_rawTrace.size() ; i++) for(uint i = 2; i < m_rawTrace.size() ; i++)
*dst++ = Complex(abs(m_rawTrace[i] - conj(m_rawTrace[i - 1])), 0); *dst++ = Complex(abs(m_rawTrace[i] - conj(m_rawTrace[i - 1])), 0);
m_displayTrace = &m_mathTrace; m_displayTrace = &m_mathTrace;
//m_amp1 = m_amp;
m_amp2 = m_amp;
//m_ofs1 = -1.0 / m_amp1;
m_ofs2 = 0.0;
} }
break; break;
} }
} }
@ -861,10 +883,12 @@ void GLScope::applyConfig()
int leftMargin = 35; int leftMargin = 35;
int rightMargin = 5; int rightMargin = 5;
float pow_floor = -100.0 + m_ofs * 100.0; float pow_floor = -100.0 + m_ofs1 * 100.0;
float pow_range = 100.0 / m_amp; float pow_range = 100.0 / m_amp1;
float amp_range = 2.0 / m_amp; float amp1_range = 2.0 / m_amp1;
float amp_ofs = m_ofs; float amp1_ofs = m_ofs1;
float amp2_range = 2.0 / m_amp2;
float amp2_ofs = m_ofs2;
float t_start = ((m_timeOfsProMill / 1000.0) - m_triggerPre) * ((float) m_displayTrace->size() / m_sampleRate); float t_start = ((m_timeOfsProMill / 1000.0) - m_triggerPre) * ((float) m_displayTrace->size() / m_sampleRate);
float t_len = ((float) m_displayTrace->size() / m_sampleRate) / (float) m_timeBase; float t_len = ((float) m_displayTrace->size() / m_sampleRate) / (float) m_timeBase;
@ -872,51 +896,64 @@ void GLScope::applyConfig()
m_x2Scale.setRange(Unit::Time, t_start, t_start + t_len); m_x2Scale.setRange(Unit::Time, t_start, t_start + t_len);
switch(m_mode) { switch(m_mode) {
case ModeIQ: { case ModeIQ:
if (amp_range < 2.0) { {
m_y1Scale.setRange(Unit::None, - amp_range * 500.0 + amp_ofs * 1000.0, amp_range * 500.0 + amp_ofs * 1000.0); if (amp1_range < 2.0) {
m_y2Scale.setRange(Unit::None, - amp_range * 500.0 + amp_ofs * 1000.0, amp_range * 500.0 + amp_ofs * 1000.0); m_y1Scale.setRange(Unit::None, - amp1_range * 500.0 + amp1_ofs * 1000.0, amp1_range * 500.0 + amp1_ofs * 1000.0);
} else { } else {
m_y1Scale.setRange(Unit::None, - amp_range * 0.5 + amp_ofs, amp_range * 0.5 + amp_ofs); m_y1Scale.setRange(Unit::None, - amp1_range * 0.5 + amp1_ofs, amp1_range * 0.5 + amp1_ofs);
m_y2Scale.setRange(Unit::None, - amp_range * 0.5 + amp_ofs, amp_range * 0.5 + amp_ofs);
} }
if (amp1_range < 2.0) {
m_y2Scale.setRange(Unit::None, - amp2_range * 500.0 + amp2_ofs * 1000.0, amp2_range * 500.0 + amp2_ofs * 1000.0);
} else {
m_y2Scale.setRange(Unit::None, - amp2_range * 0.5 + amp2_ofs, amp2_range * 0.5 + amp2_ofs);
}
break; break;
} }
case ModeMagLinPha: case ModeMagLinPha:
case ModeMagLinDPha: case ModeMagLinDPha:
{ {
if (amp_range < 2.0) { if (amp1_range < 2.0) {
m_y1Scale.setRange(Unit::None, amp_ofs * 500.0, amp_range * 1000.0 + amp_ofs * 500.0); m_y1Scale.setRange(Unit::None, amp1_ofs * 500.0, amp1_range * 1000.0 + amp1_ofs * 500.0);
} else { } else {
m_y1Scale.setRange(Unit::None, amp_ofs/2.0, amp_range + amp_ofs/2.0); m_y1Scale.setRange(Unit::None, amp1_ofs/2.0, amp1_range + amp1_ofs/2.0);
} }
m_y2Scale.setRange(Unit::None, -1.0, 1.0); // Scale to Pi
m_y2Scale.setRange(Unit::None, -1.0/m_amp2 + amp2_ofs, 1.0/m_amp2 + amp2_ofs); // Scale to Pi*A2
break; break;
} }
case ModeMagdBPha: case ModeMagdBPha:
case ModeMagdBDPha: case ModeMagdBDPha:
{ {
m_y1Scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range); m_y1Scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
m_y2Scale.setRange(Unit::AngleDegrees, -1.0, 1.0); // Scale to Pi m_y2Scale.setRange(Unit::None, -1.0/m_amp2 + amp2_ofs, 1.0/m_amp2 + amp2_ofs); // Scale to Pi*A2
break; break;
} }
case ModeDerived12: { case ModeDerived12: {
if (amp_range < 2.0) { if (amp1_range < 2.0) {
m_y1Scale.setRange(Unit::None, 0.0, amp_range * 1000.0); m_y1Scale.setRange(Unit::None, 0.0, amp1_range * 1000.0);
m_y2Scale.setRange(Unit::None, - amp_range * 500.0, amp_range * 500.0);
} else { } else {
m_y1Scale.setRange(Unit::None, 0.0, amp_range); m_y1Scale.setRange(Unit::None, 0.0, amp1_range);
m_y2Scale.setRange(Unit::None, - amp_range * 0.5, amp_range * 0.5); }
if (amp2_range < 2.0) {
m_y2Scale.setRange(Unit::None, - amp2_range * 500.0, amp2_range * 500.0);
} else {
m_y2Scale.setRange(Unit::None, - amp2_range * 0.5, amp2_range * 0.5);
} }
break; break;
} }
case ModeCyclostationary: { case ModeCyclostationary: {
if (amp_range < 2.0) { if (amp1_range < 2.0) {
m_y1Scale.setRange(Unit::None, 0.0, amp_range * 1000.0); m_y1Scale.setRange(Unit::None, 0.0, amp1_range * 1000.0);
m_y2Scale.setRange(Unit::None, - amp_range * 500.0, amp_range * 500.0);
} else { } else {
m_y1Scale.setRange(Unit::None, 0.0, amp_range); m_y1Scale.setRange(Unit::None, 0.0, amp1_range);
m_y2Scale.setRange(Unit::None, - amp_range * 0.5, amp_range * 0.5); }
if (amp2_range < 2.0) {
m_y2Scale.setRange(Unit::None, - amp2_range * 500.0, amp2_range * 500.0);
} else {
m_y2Scale.setRange(Unit::None, - amp2_range * 0.5, amp2_range * 0.5);
} }
break; break;
} }

View File

@ -24,6 +24,9 @@ GLScopeGUI::GLScopeGUI(QWidget* parent) :
m_amplification1(0), m_amplification1(0),
m_amp1OffsetCoarse(0), m_amp1OffsetCoarse(0),
m_amp1OffsetFine(0), m_amp1OffsetFine(0),
m_amplification2(0),
m_amp2OffsetCoarse(0),
m_amp2OffsetFine(0),
m_displayGridIntensity(1), m_displayGridIntensity(1),
m_displayTraceIntensity(50), m_displayTraceIntensity(50),
m_triggerChannel(ScopeVis::TriggerFreeRun), m_triggerChannel(ScopeVis::TriggerFreeRun),
@ -65,6 +68,11 @@ void GLScopeGUI::resetToDefaults()
m_timeBase = 1; m_timeBase = 1;
m_timeOffset = 0; m_timeOffset = 0;
m_amplification1 = 0; m_amplification1 = 0;
m_amp1OffsetCoarse = 0;
m_amp1OffsetFine = 0;
m_amplification2 = 0;
m_amp2OffsetCoarse = 0;
m_amp2OffsetFine = 0;
m_displayGridIntensity = 5; m_displayGridIntensity = 5;
m_triggerChannel = ScopeVis::TriggerFreeRun; m_triggerChannel = ScopeVis::TriggerFreeRun;
m_triggerLevelCoarse = 0; m_triggerLevelCoarse = 0;
@ -98,6 +106,9 @@ QByteArray GLScopeGUI::serialize() const
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(20, m_amp2OffsetCoarse);
s.writeS32(21, m_amp2OffsetFine);
return s.final(); return s.final();
} }
@ -138,6 +149,7 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
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);
@ -147,9 +159,14 @@ bool GLScopeGUI::deserialize(const QByteArray& data)
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(20, &m_amp2OffsetCoarse, 0);
d.readS32(21, &m_amp2OffsetFine, 0);
setTrigLevelDisplay(); setTrigLevelDisplay();
applySettings(); applySettings();
applyTriggerSettings(); applyTriggerSettings();
@ -200,6 +217,9 @@ void GLScopeGUI::applySettings()
ui->amp1->setValue(m_amplification1); ui->amp1->setValue(m_amplification1);
ui->amp1OfsCoarse->setValue(m_amp1OffsetCoarse); ui->amp1OfsCoarse->setValue(m_amp1OffsetCoarse);
ui->amp1OfsFine->setValue(m_amp1OffsetFine); ui->amp1OfsFine->setValue(m_amp1OffsetFine);
ui->amp2->setValue(m_amplification2);
ui->amp2OfsCoarse->setValue(m_amp2OffsetCoarse);
ui->amp2OfsFine->setValue(m_amp2OffsetFine);
ui->gridIntensity->setSliderPosition(m_displayGridIntensity); ui->gridIntensity->setSliderPosition(m_displayGridIntensity);
ui->traceIntensity->setSliderPosition(m_displayTraceIntensity); ui->traceIntensity->setSliderPosition(m_displayTraceIntensity);
} }
@ -286,6 +306,30 @@ void GLScopeGUI::setAmp1ScaleDisplay()
} }
} }
void GLScopeGUI::setAmp2ScaleDisplay()
{
if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagdBDPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagLinPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagLinDPha))
{
ui->amp2Text->setText(tr("%1").arg(amps[m_amplification2]*5.0, 0, 'f', 3));
}
else
{
qreal a = amps[m_amplification2]*10.0;
if(a < 0.000001)
ui->amp2Text->setText(tr("%1\nn").arg(a * 1000000000.0));
else if(a < 0.001)
ui->amp2Text->setText(tr("%1\nµ").arg(a * 1000000.0));
else if(a < 1.0)
ui->amp2Text->setText(tr("%1\nm").arg(a * 1000.0));
else
ui->amp2Text->setText(tr("%1").arg(a * 1.0));
}
}
void GLScopeGUI::setAmp1OfsDisplay() void GLScopeGUI::setAmp1OfsDisplay()
{ {
qreal o = (m_amp1OffsetCoarse * 10.0) + (m_amp1OffsetFine / 20.0); qreal o = (m_amp1OffsetCoarse * 10.0) + (m_amp1OffsetFine / 20.0);
@ -318,6 +362,32 @@ void GLScopeGUI::setAmp1OfsDisplay()
} }
} }
void GLScopeGUI::setAmp2OfsDisplay()
{
qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0);
if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagdBDPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagLinPha)
|| (m_glScope->getDataMode() == GLScope::ModeMagLinDPha))
{
ui->amp2OfsText->setText(tr("%1").arg(o/1000.0, 0, 'f', 4));
}
else
{
qreal a = o/1000.0;
if(fabs(a) < 0.000001)
ui->amp2OfsText->setText(tr("%1\nn").arg(a * 1000000000.0));
else if(fabs(a) < 0.001)
ui->amp2OfsText->setText(tr("%1\nµ").arg(a * 1000000.0));
else if(fabs(a) < 1.0)
ui->amp2OfsText->setText(tr("%1\nm").arg(a * 1000.0));
else
ui->amp2OfsText->setText(tr("%1").arg(a * 1.0));
}
}
void GLScopeGUI::on_amp1_valueChanged(int value) void GLScopeGUI::on_amp1_valueChanged(int value)
{ {
m_amplification1 = value; m_amplification1 = value;
@ -341,6 +411,29 @@ void GLScopeGUI::on_amp1OfsFine_valueChanged(int value)
m_glScope->setAmp1Ofs(o/1000.0); // scale to [-1.0,1.0] m_glScope->setAmp1Ofs(o/1000.0); // scale to [-1.0,1.0]
} }
void GLScopeGUI::on_amp2_valueChanged(int value)
{
m_amplification2 = value;
setAmp2ScaleDisplay();
m_glScope->setAmp2(0.2 / amps[m_amplification2]);
}
void GLScopeGUI::on_amp2OfsCoarse_valueChanged(int value)
{
m_amp2OffsetCoarse = value;
setAmp2OfsDisplay();
qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0);
m_glScope->setAmp2Ofs(o/1000.0); // scale to [-1.0,1.0]
}
void GLScopeGUI::on_amp2OfsFine_valueChanged(int value)
{
m_amp2OffsetFine = value;
setAmp2OfsDisplay();
qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0);
m_glScope->setAmp2Ofs(o/1000.0); // scale to [-1.0,1.0]
}
void GLScopeGUI::on_scope_traceSizeChanged(int) void GLScopeGUI::on_scope_traceSizeChanged(int)
{ {
setTimeScaleDisplay(); setTimeScaleDisplay();