From e17ecf03282c49d378c25833aa8f32a4fd9b00c8 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 7 Feb 2017 00:25:40 +0100 Subject: [PATCH] New scope: fixed trace offset --- sdrbase/dsp/scopevisng.cpp | 11 ++++++++++- sdrbase/dsp/scopevisng.h | 2 +- sdrbase/gui/glscopeng.cpp | 10 ++++++++-- sdrbase/gui/glscopenggui.cpp | 23 +++++++++++++++++------ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/sdrbase/dsp/scopevisng.cpp b/sdrbase/dsp/scopevisng.cpp index fa8d5df63..794e2fdc5 100644 --- a/sdrbase/dsp/scopevisng.cpp +++ b/sdrbase/dsp/scopevisng.cpp @@ -306,8 +306,17 @@ int ScopeVisNG::processTraces(int beginPointDelta, int endPointDelta, TraceBackB { float posLimit = 1.0 / itData->m_amp; float negLimit = -1.0 / itData->m_amp; + ProjectionType projectionType = itData->m_projectionType; + float v; - float v = itCtl->m_projector->run(*begin) * itData->m_amp + itData->m_ofs; + if (projectionType == ProjectionMagLin) { + v = itCtl->m_projector->run(*begin)*itData->m_amp - itData->m_ofs - 1.0/itData->m_amp; + } else if (projectionType == ProjectionMagDB) { + v = 1.0f + 2.0f*(((itCtl->m_projector->run(*begin))/100.0f) - itData->m_ofs) + 1.0f - 1.0f/itData->m_amp; + //v = itCtl->m_projector->run(*begin) * itData->m_amp - itData->m_ofs; + } else { + v = itCtl->m_projector->run(*begin) * itData->m_amp - itData->m_ofs; + } if(v > posLimit) { v = posLimit; diff --git a/sdrbase/dsp/scopevisng.h b/sdrbase/dsp/scopevisng.h index 97f8c75e4..466f9d9df 100644 --- a/sdrbase/dsp/scopevisng.h +++ b/sdrbase/dsp/scopevisng.h @@ -321,7 +321,7 @@ private: { uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag; //return mult * log2f(magsq/1073741824.0f); - return (log10f(magsq/1073741824.0f) / 5.0f) + 1.0f; + return log10f(magsq/1073741824.0f) * 10.0f; } private: static const Real mult; diff --git a/sdrbase/gui/glscopeng.cpp b/sdrbase/gui/glscopeng.cpp index f41005144..eb2e4dd10 100644 --- a/sdrbase/gui/glscopeng.cpp +++ b/sdrbase/gui/glscopeng.cpp @@ -983,7 +983,7 @@ void GLScopeNG::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) ScopeVisNG::TraceData& traceData = (*m_tracesData)[highlightedTraceIndex]; float amp_range = 2.0 / traceData.m_amp; float amp_ofs = traceData.m_ofs; - float pow_floor = -100.0 + traceData.m_ofs * 100.0 + 50.0f - 50.0f/traceData.m_amp; + float pow_floor = -100.0 + traceData.m_ofs * 100.0; float pow_range = 100.0 / traceData.m_amp; switch (traceData.m_projectionType) @@ -991,13 +991,19 @@ void GLScopeNG::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) case ScopeVisNG::ProjectionMagDB: // dB scale scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range); break; + case ScopeVisNG::ProjectionMagLin: + if (amp_range < 2.0) { + scale.setRange(Unit::None, amp_ofs * 500.0, amp_range * 1000.0 + amp_ofs * 500.0); + } else { + scale.setRange(Unit::None, amp_ofs/2.0, amp_range + amp_ofs/2.0); + } + break; case ScopeVisNG::ProjectionPhase: // Phase or frequency case ScopeVisNG::ProjectionDPhase: scale.setRange(Unit::None, -1.0/traceData.m_amp + amp_ofs, 1.0/traceData.m_amp + amp_ofs); break; case ScopeVisNG::ProjectionReal: // Linear generic case ScopeVisNG::ProjectionImag: - case ScopeVisNG::ProjectionMagLin: default: if (amp_range < 2.0) { scale.setRange(Unit::None, - amp_range * 500.0 + amp_ofs * 1000.0, amp_range * 500.0 + amp_ofs * 1000.0); diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index a26aa1301..9d1707fe0 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -93,6 +93,7 @@ void GLScopeNGGUI::setBuddies(MessageQueue* messageQueue, ScopeVisNG* scopeVis, setTimeScaleDisplay(); setTimeOfsDisplay(); setAmpScaleDisplay(); + setAmpOfsDisplay(); } void GLScopeNGGUI::setSampleRate(int sampleRate) @@ -246,6 +247,7 @@ void GLScopeNGGUI::on_traceLen_valueChanged(int value) void GLScopeNGGUI::on_traceMode_currentIndexChanged(int index) { setAmpScaleDisplay(); + setAmpOfsDisplay(); changeCurrentTrace(); } @@ -464,17 +466,26 @@ void GLScopeNGGUI::setAmpOfsDisplay() if (projectionType == ScopeVisNG::ProjectionMagDB) { - ui->ofsText->setText(tr("%1").arg(o/1000.0, 0, 'f', 4)); + ui->ofsText->setText(tr("%1\ndB").arg(o/10.0f - 100.0f, 0, 'f', 1)); } else { - float a = o/1000.0f; + float a; - if(fabs(a) < 0.000001) + if (projectionType == ScopeVisNG::ProjectionMagLin) + { + a = o/2000.0f; + } + else + { + a = o/1000.0f; + } + + if(fabs(a) < 0.000001f) ui->ofsText->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(fabs(a) < 0.001) + else if(fabs(a) < 0.001f) ui->ofsText->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(fabs(a) < 1.0) + else if(fabs(a) < 1.0f) ui->ofsText->setText(tr("%1\nm").arg(a * 1000.0)); else ui->ofsText->setText(tr("%1").arg(a * 1.0)); @@ -585,7 +596,7 @@ void GLScopeNGGUI::fillTraceData(ScopeVisNG::TraceData& traceData) traceData.m_projectionType = (ScopeVisNG::ProjectionType) ui->traceMode->currentIndex(); traceData.m_inputIndex = 0; traceData.m_amp = 0.2 / amps[ui->amp->value()]; - traceData.m_ofs = (10.0 * ui->ofsCoarse->value()) + (ui->ofsFine->value() / 20.0); + traceData.m_ofs = ((10.0 * ui->ofsCoarse->value()) + (ui->ofsFine->value() / 20.0)) / 1000.0f; traceData.m_traceDelay = 0; }