mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
New scope: fixed trace offset
This commit is contained in:
parent
27116d5b3f
commit
e17ecf0328
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user