Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7d279abf9f1b
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0e0252d4d85d
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Aug 16, 2020

  1. Removed all special-casing for FFT waveforms. They now work just like…

    … any other analog signal
    azonenberg committed Aug 16, 2020
    Copy the full SHA
    0e0252d View commit details
2 changes: 1 addition & 1 deletion lib
Submodule lib updated from 06cd31 to 6dca06
5 changes: 0 additions & 5 deletions src/glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -714,11 +714,6 @@ bool WaveformArea::IsEyeOrBathtub()
return IsEye() || (bath != NULL);
}

bool WaveformArea::IsFFT()
{
return (m_channel->GetYAxisUnits().GetType() == Unit::UNIT_DBM);
}

bool WaveformArea::IsTime()
{
return (m_channel->GetYAxisUnits().GetType() == Unit::UNIT_PS);
2 changes: 0 additions & 2 deletions src/glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -154,7 +154,6 @@ class WaveformArea : public Gtk::GLArea
bool IsEye();
bool IsEyeOrBathtub();
bool IsWaterfall();
bool IsFFT();
bool IsTime();

size_t GetOverlayCount()
@@ -390,7 +389,6 @@ class WaveformArea : public Gtk::GLArea
float VoltsToPixels(float volt);
float VoltsToYPosition(float volt);
float YPositionToVolts(float y);
float DbToYPosition(float db);
int64_t XPositionToXAxisUnits(float pix);
int64_t PixelsToXAxisUnits(float pix);
float XAxisUnitsToPixels(int64_t t);
85 changes: 36 additions & 49 deletions src/glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -116,64 +116,53 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)

std::map<float, float> gridmap;

//Spectra are printed on a logarithmic scale
if(m_channel->GetYAxisUnits() == Unit::UNIT_DBM)
{
for(float db=0; db >= -60; db -= 10)
gridmap[db] = DbToYPosition(db);
}

//Normal analog waveform
else
{
//Volts from the center line of our graph to the top. May not be the max value in the signal.
float volts_per_half_span = PixelsToVolts(halfheight);
//Volts from the center line of our graph to the top. May not be the max value in the signal.
float volts_per_half_span = PixelsToVolts(halfheight);

//Decide what voltage step to use. Pick from a list (in volts)
float selected_step = PickStepSize(volts_per_half_span);
//Decide what voltage step to use. Pick from a list (in volts)
float selected_step = PickStepSize(volts_per_half_span);

//Special case a few values
if(m_channel->GetYAxisUnits() == Unit::UNIT_LOG_BER)
selected_step = 2;
//Special case a few values
if(m_channel->GetYAxisUnits() == Unit::UNIT_LOG_BER)
selected_step = 2;

float bottom_edge = (ybot + theight/2);
float top_edge = (ytop - theight/2);
float bottom_edge = (ybot + theight/2);
float top_edge = (ytop - theight/2);

//Calculate grid positions
float vbot = YPositionToVolts(ybot);
float vtop = YPositionToVolts(ytop);
float vmid = (vbot + vtop)/2;
for(float dv=0; ; dv += selected_step)
{
float vp = vmid + dv;
float vn = vmid - dv;
//Calculate grid positions
float vbot = YPositionToVolts(ybot);
float vtop = YPositionToVolts(ytop);
float vmid = (vbot + vtop)/2;
for(float dv=0; ; dv += selected_step)
{
float vp = vmid + dv;
float vn = vmid - dv;

float yt = VoltsToYPosition(vp);
float yb = VoltsToYPosition(vn);
float yt = VoltsToYPosition(vp);
float yb = VoltsToYPosition(vn);

if(dv != 0)
{
if( (yb >= bottom_edge) && (yb <= top_edge ) )
gridmap[vn] = yb;
if(dv != 0)
{
if( (yb >= bottom_edge) && (yb <= top_edge ) )
gridmap[vn] = yb;

if( (yt >= bottom_edge ) && (yt <= top_edge) )
gridmap[vp] = yt;
}
else
if( (yt >= bottom_edge ) && (yt <= top_edge) )
gridmap[vp] = yt;

//Stop if we're off the edge
if( (yb > ytop) && (yt < ybot) )
break;
}
else
gridmap[vp] = yt;

//Center line is solid
cr->set_source_rgba(0.7, 0.7, 0.7, 1.0);
cr->move_to(0, VoltsToYPosition(0));
cr->line_to(m_plotRight, VoltsToYPosition(0));
cr->stroke();
//Stop if we're off the edge
if( (yb > ytop) && (yt < ybot) )
break;
}

//Center line is solid
cr->set_source_rgba(0.7, 0.7, 0.7, 1.0);
cr->move_to(0, VoltsToYPosition(0));
cr->line_to(m_plotRight, VoltsToYPosition(0));
cr->stroke();

if(gridmap.size() > 50)
LogFatal("gridmap way too big (%zu)\n", gridmap.size());

@@ -200,9 +189,7 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
{
float v = it.first;
tlayout->set_text(m_channel->GetYAxisUnits().PrettyPrint(v));
float y = it.second;
if(!IsFFT())
y -= theight/2;
float y = it.second - theight/2;
if(y < ybot)
continue;
if(y > ytop)
5 changes: 0 additions & 5 deletions src/glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -253,11 +253,6 @@ void WaveformArea::OnSingleClick(GdkEventButton* event, int64_t timestamp)
{
//Left
case 1:

//For now, can only change offset on voltage channels
if(m_channel->GetYAxisUnits() != Unit::UNIT_VOLTS)
return;

m_dragState = DRAG_OFFSET;
m_dragStartVoltage = YPositionToVolts(event->y);
break;
36 changes: 6 additions & 30 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -111,7 +111,6 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
}

float xscale = pdat->m_timescale * m_group->m_pixelsPerXUnit;
bool fft = IsFFT();

//Zero voltage level
//TODO: properly calculate decoder positions once RenderDecodeOverlays() isn't doing that anymore
@@ -127,10 +126,9 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
ybase = m_height - (m_overlayPositions[dynamic_cast<ProtocolDecoder*>(channel)] + 10);
}

float offset = channel->GetOffset();
float yoff = channel->GetOffset();

//Y axis scaling in shader
float yoff = 0;
float yscale = 1;

//We need to stretch every sample to two samples, one at the very left and one at the very right,
@@ -150,7 +148,7 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
digheight = 20;

//#pragma omp parallel for
yoff = ybase;
//TODO: AVX
yscale = digheight;
for(size_t j=0; j<realcount; j++)
{
@@ -171,26 +169,10 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
else
Int64ToFloat(wdata->m_mappedXBuffer, reinterpret_cast<int64_t*>(&andat->m_offsets[0]), wdata->m_count);

float* psamps = reinterpret_cast<float*>(__builtin_assume_aligned(&andat->m_samples[0], 16));
if(fft)
{
//Scaling for display
//TODO: don't hard code plot limits
float plotheight = m_height - 2*m_padding;
float db_range = 70;
float db_offset = -db_range/2;
yoff = plotheight;
yscale = plotheight / db_range;
offset = db_offset + db_range/2;
}
else
{
yoff = ybase;
yscale = m_pixelsPerVolt;
}
yscale = m_pixelsPerVolt;

//Copy the waveform
memcpy(wdata->m_mappedYBuffer, psamps, wdata->m_count*sizeof(float));
memcpy(wdata->m_mappedYBuffer, &andat->m_samples[0], wdata->m_count*sizeof(float));
}

double dt = GetTime() - start;
@@ -216,9 +198,9 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
wdata->m_mappedConfigBuffer[4] = digdat ? 1 : 0; //digital
wdata->m_mappedFloatConfigBuffer[5] = xoff; //xoff
wdata->m_mappedFloatConfigBuffer[6] = xscale; //xscale
wdata->m_mappedFloatConfigBuffer[7] = yoff; //ybase
wdata->m_mappedFloatConfigBuffer[7] = ybase; //ybase
wdata->m_mappedFloatConfigBuffer[8] = yscale; //yscale
wdata->m_mappedFloatConfigBuffer[9] = offset; //yoff
wdata->m_mappedFloatConfigBuffer[9] = yoff; //yoff

//Done
wdata->m_geometryOK = true;
@@ -776,12 +758,6 @@ float WaveformArea::VoltsToYPosition(float volt)
return m_height/2 - VoltsToPixels(volt + m_channel->GetOffset());
}

float WaveformArea::DbToYPosition(float db)
{
float plotheight = m_height - 2*m_padding;
return m_padding - (db/70 * plotheight);
}

float WaveformArea::YPositionToVolts(float y)
{
return PixelsToVolts(-1 * (y - m_height/2) ) - m_channel->GetOffset();