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

Commits on Nov 2, 2020

  1. Copy the full SHA
    a6932eb View commit details
Showing with 35 additions and 2 deletions.
  1. +34 −2 scopeprotocols/SubtractFilter.cpp
  2. +1 −0 scopeprotocols/SubtractFilter.h
36 changes: 34 additions & 2 deletions scopeprotocols/SubtractFilter.cpp
Original file line number Diff line number Diff line change
@@ -88,12 +88,44 @@ bool SubtractFilter::NeedsConfig()
return true;
}

double SubtractFilter::GetOffset()
{
double v1 = m_inputs[0].m_channel->GetVoltageRange();
double v2 = m_inputs[1].m_channel->GetVoltageRange();
double o1 = m_inputs[0].m_channel->GetOffset();
double o2 = m_inputs[1].m_channel->GetOffset();

double vmax_p = v1/2 - o1;
double vmin_p = -v1/2 - o1;

double vmax_n = v2/2 - o2;
double vmin_n = -v2/2 - o2;

//Possible output range
double vout_max = vmax_p - vmin_n;
double vout_min = vmin_p - vmax_p;

return -(vout_min + ((vout_max - vout_min) / 2));
}

double SubtractFilter::GetVoltageRange()
{
//TODO: default, but allow overriding
double v1 = m_inputs[0].m_channel->GetVoltageRange();
double v2 = m_inputs[1].m_channel->GetVoltageRange();
return max(v1, v2) * 2;
double o1 = m_inputs[0].m_channel->GetOffset();
double o2 = m_inputs[1].m_channel->GetOffset();

double vmax_p = v1/2 - o1;
double vmin_p = -v1/2 - o1;

double vmax_n = v2/2 - o2;
double vmin_n = -v2/2 - o2;

//Possible output range
double vout_max = vmax_p - vmin_n;
double vout_min = vmin_p - vmax_p;

return (vout_max - vout_min);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 change: 1 addition & 0 deletions scopeprotocols/SubtractFilter.h
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ class SubtractFilter : public Filter
static std::string GetProtocolName();
virtual void SetDefaultName();

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

virtual bool ValidateChannel(size_t i, StreamDescriptor stream);