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: 8fbf3d107883
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: a4512050053b
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Mar 1, 2020

  1. Various rendering and UI work to support digital and digital-bus wave…

    …forms in main channels vs overlays
    azonenberg committed Mar 1, 2020
    Copy the full SHA
    a451205 View commit details
7 changes: 5 additions & 2 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -292,8 +292,10 @@ void OscilloscopeWindow::CreateWidgets()
chan->m_displayname = tmp;
}

auto type = chan->GetType();

//Add a menu item - but not for the external trigger(s)
if(chan->GetType() != OscilloscopeChannel::CHANNEL_TYPE_TRIGGER)
if(type != OscilloscopeChannel::CHANNEL_TYPE_TRIGGER)
{
item = Gtk::manage(new Gtk::MenuItem(chan->m_displayname, false));
item->signal_activate().connect(
@@ -304,7 +306,8 @@ void OscilloscopeWindow::CreateWidgets()
//See which channels are currently on
//DEBUG: enable all analog channels to save time when setting up the client
//if(chan->IsEnabled())
if(chan->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG)
if( (type == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) ||
(type == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL) )
{
auto w = new WaveformArea(
scope,
6 changes: 6 additions & 0 deletions glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -670,6 +670,12 @@ bool WaveformArea::IsWaterfall()
return (fall != NULL);
}

bool WaveformArea::IsDigital()
{
auto pdat = m_channel->GetData();
return (dynamic_cast<DigitalCapture*>(pdat) != NULL);
}

bool WaveformArea::IsAnalog()
{
auto pdat = m_channel->GetData();
1 change: 1 addition & 0 deletions glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -131,6 +131,7 @@ class WaveformArea : public Gtk::GLArea

//Helpers for figuring out what kind of signal our primary trace is
bool IsAnalog();
bool IsDigital();
bool IsEye();
bool IsWaterfall();
bool IsFFT();
66 changes: 65 additions & 1 deletion glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -84,6 +84,10 @@ void WaveformArea::RenderBackgroundGradient(Cairo::RefPtr< Cairo::Context > cr)

void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
{
//If we're a digital channel, no grid or anything else makes sense
if(m_channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
return;

//Calculate width of right side axis label
int twidth;
int theight;
@@ -245,8 +249,68 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
int spacing = 30;
int midline = spacing / 2;

//Render digital bus waveforms here (TODO: GL stuff)
auto bus = dynamic_cast<DigitalBusCapture*>(m_channel->GetData());
if(bus != NULL)
{
int ymid = m_height - 15;
int ytop = ymid - 8;
int ybot = ymid + 8;

Gdk::Color color(m_channel->m_displaycolor);

for(size_t i=0; i<bus->GetDepth(); i++)
{
double start = (bus->GetSampleStart(i) * bus->m_timescale) + bus->m_triggerPhase;
double end = start + (bus->GetSampleLen(i) * bus->m_timescale);

double xs = XAxisUnitsToXPosition(start);
double xe = XAxisUnitsToXPosition(end);

if( (xe < m_infoBoxRect.get_right()) || (xs > m_plotRight) )
continue;

auto sample = bus->m_samples[i].m_sample;

uint64_t value = 0;
for(size_t j=0; j<sample.size(); j++)
{
if(sample[j])
value |= (1 << j);
}

char tmp[128];
if(sample.size() <= 4)
snprintf(tmp, sizeof(tmp), "%01lx", value);
else if(sample.size() <= 8)
snprintf(tmp, sizeof(tmp), "%02lx", value);
else if(sample.size() <= 12)
snprintf(tmp, sizeof(tmp), "%03lx", value);
else if(sample.size() <= 16)
snprintf(tmp, sizeof(tmp), "%04lx", value);
else if(sample.size() <= 20)
snprintf(tmp, sizeof(tmp), "%05lx", value);
else if(sample.size() <= 24)
snprintf(tmp, sizeof(tmp), "%06lx", value);
else if(sample.size() <= 28)
snprintf(tmp, sizeof(tmp), "%07lx", value);
else if(sample.size() <= 32)
snprintf(tmp, sizeof(tmp), "%08lx", value);
else
snprintf(tmp, sizeof(tmp), "%lx", value);

ChannelRenderer::RenderComplexSignal(
cr,
m_infoBoxRect.get_right(), m_plotRight,
xs, xe, 5,
ybot, ymid, ytop,
tmp,
color);
}
}

//Find which overlay slots are in use
int max_overlays = 10;
const int max_overlays = 10;
bool overlayPositionsUsed[max_overlays] = {0};
for(auto o : m_overlays)
{
13 changes: 10 additions & 3 deletions glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -75,11 +75,18 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
bool fft = IsFFT();

//Zero voltage level
//TODO: don't assume all digital data is a protocol decode, logic analyzers are a thing!
//TODO: properly calculate decoder positions once RenderDecodeOverlays() isn't doing that anymore
float ybase = m_height/2;
if(digdat)
ybase = m_height - (m_overlayPositions[dynamic_cast<ProtocolDecoder*>(channel)] + 15);
{
//Main channel
if(channel == m_channel)
ybase = 15;

//Overlay
else
ybase = m_height - (m_overlayPositions[dynamic_cast<ProtocolDecoder*>(channel)] + 15);
}

//Calculate X/Y coordinate of each sample point
//TODO: some of this can probably move to GPU too?
@@ -233,7 +240,7 @@ bool WaveformArea::on_render(const Glib::RefPtr<Gdk::GLContext>& /*context*/)
*/

//Download the main waveform to the GPU and kick off the compute shader for rendering it
if(IsAnalog())
if(IsAnalog() || IsDigital())
{
PrepareGeometry(m_waveformRenderData);
RenderTrace(m_waveformRenderData);