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
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 47761de2eaa9
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c03b4941f8d8
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jun 12, 2020

  1. Eye pattern: allow center voltage to be specified, so we can plot eye…

    …s of signals with a DC offset. Fixes #1.
    azonenberg committed Jun 12, 2020
    Copy the full SHA
    c03b494 View commit details
Showing with 25 additions and 6 deletions.
  1. +1 −1 scopehal/OscilloscopeChannel.cpp
  2. +22 −5 scopeprotocols/EyeDecoder2.cpp
  3. +2 −0 scopeprotocols/EyeDecoder2.h
2 changes: 1 addition & 1 deletion scopehal/OscilloscopeChannel.cpp
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ double OscilloscopeChannel::GetOffset()
if(m_scope != NULL)
return m_scope->GetChannelOffset(m_index);
else
return 0; //todo: if protocol decoder use root channel offset or similar?
return 0;
}

void OscilloscopeChannel::SetOffset(double offset)
27 changes: 22 additions & 5 deletions scopeprotocols/EyeDecoder2.cpp
Original file line number Diff line number Diff line change
@@ -105,6 +105,10 @@ EyeDecoder2::EyeDecoder2(string color)
m_saturationName = "Saturation Level";
m_parameters[m_saturationName] = ProtocolDecoderParameter(ProtocolDecoderParameter::TYPE_FLOAT);
m_parameters[m_saturationName].SetFloatVal(1);

m_centerName = "Center Voltage";
m_parameters[m_centerName] = ProtocolDecoderParameter(ProtocolDecoderParameter::TYPE_FLOAT);
m_parameters[m_centerName].SetFloatVal(0);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -312,6 +316,11 @@ void EyeDecoder2::ClearSweeps()
}
}

double EyeDecoder2::GetOffset()
{
return -m_parameters[m_centerName].GetFloatVal();
}

void EyeDecoder2::Refresh()
{
static double total_time = 0;
@@ -344,18 +353,26 @@ void EyeDecoder2::Refresh()

double start = GetTime();

//If center of the eye was changed, reset existing eye data
EyeWaveform* cap = dynamic_cast<EyeWaveform*>(m_data);
double center = m_parameters[m_centerName].GetFloatVal();
if(cap)
{
if(abs(cap->GetCenterVoltage() - center) > 0.001)
{
delete cap;
cap = NULL;
}
}

//Initialize the capture
//TODO: timestamps? do we need those?
EyeWaveform* cap = dynamic_cast<EyeWaveform*>(m_data);
if(cap == NULL)
cap = new EyeWaveform(m_width, m_height, 0); //TODO: make center configurable (scopehal:#1)
cap = new EyeWaveform(m_width, m_height, center);
cap->m_saturationLevel = m_parameters[m_saturationName].GetFloatVal();
cap->m_timescale = 1;
int64_t* data = cap->GetAccumData();

//Midpoint of the eye voltage
double center = cap->GetCenterVoltage();

//Calculate average period of the clock
//TODO: All of this code assumes a fully RLE'd clock with one sample per toggle.
//We probably need a preprocessing filter to handle analog etc clock sources.
2 changes: 2 additions & 0 deletions scopeprotocols/EyeDecoder2.h
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ class EyeDecoder2 : public ProtocolDecoder
virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual double GetVoltageRange();
virtual double GetOffset();

virtual void ClearSweeps();

@@ -133,6 +134,7 @@ class EyeDecoder2 : public ProtocolDecoder
size_t m_uiWidth;

std::string m_saturationName;
std::string m_centerName;
};

#endif