Skip to content

Commit 4253c91

Browse files
committed
Stream browser: properly handle per-channel ADC modes
1 parent a92b6c8 commit 4253c91

5 files changed

Lines changed: 62 additions & 9 deletions

File tree

lib

src/ngscopeclient/Dialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ bool Dialog::renderEditableProperty(
563563
float fontSize = ImGui::GetFontSize();
564564
if(width >= 0)
565565
{
566-
if(width == 0) width = 6*fontSize;
566+
if(width == 0)
567+
width = 8*fontSize;
567568
ImGui::SetNextItemWidth(width);
568569
}
569570
if constexpr (std::is_same_v<T, int64_t>)

src/ngscopeclient/InstrumentThread.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ void InstrumentThread(InstrumentThreadArgs args)
174174
scopestate->m_strOffset[i][j] = unit.PrettyPrint(offset);
175175
scopestate->m_strRange[i][j] = unit.PrettyPrint(range);
176176
}
177+
177178
// Get probe name
178179
scopestate->m_probeName[i] = scope->GetProbeName(i);
180+
179181
// Populate bandwidth limit values
180182
auto limit = scope->GetChannelBandwidthLimit(i);
181183
scopestate->m_bandwidthLimits[i].clear();
@@ -194,6 +196,8 @@ void InstrumentThread(InstrumentThreadArgs args)
194196
scopestate->m_channelBandwidthLimit[i] = j;
195197
}
196198

199+
scopestate->m_adcMode[i] = scope->GetADCMode(i);
200+
197201
// Populate coupling values
198202
auto coupling = scope->GetChannelCoupling(i);
199203
scopestate->m_couplings[i].clear();

src/ngscopeclient/OscilloscopeState.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class OscilloscopeState
7777
m_committedAttenuation = std::make_unique<float[]>(n);
7878
m_strAttenuation = std::make_unique<std::string[]>(n);
7979

80+
m_adcMode = std::make_unique<int[]>(n);
81+
8082
Unit volts(Unit::UNIT_VOLTS);
8183

8284
for(size_t i=0; i<n; i++)
@@ -88,6 +90,7 @@ class OscilloscopeState
8890
m_channelBandwidthLimit[i] = 0;
8991
m_channelCoupling[i] = 0;
9092
m_channelBandwidthLimit[i] = 0;
93+
m_adcMode[i] = 0;
9194

9295
// Offset and range ar per stream
9396
OscilloscopeChannel* chan = dynamic_cast<OscilloscopeChannel*>(scope->GetChannel(i));
@@ -150,6 +153,8 @@ class OscilloscopeState
150153

151154
std::unique_ptr<float[]> m_committedAttenuation;
152155
std::unique_ptr<std::string[]> m_strAttenuation;
156+
157+
std::unique_ptr<int[]> m_adcMode;
153158
};
154159

155160
#endif

src/ngscopeclient/StreamBrowserDialog.cpp

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ void StreamBrowserDialog::renderChannelNode(
17511751
m_parent->ShowChannelProperties(scopechan);
17521752
}
17531753
renderChannelProperties(scope,scopechan,channelIndex,scopeState);
1754-
EndBlock();
1754+
EndBlock();
17551755
}
17561756
}
17571757
size_t streamCount = channel->GetStreamCount();
@@ -1778,15 +1778,25 @@ void StreamBrowserDialog::renderChannelNode(
17781778
@param channelIndex the index of the channel
17791779
@param scopeState the OscilloscopeState
17801780
*/
1781-
void StreamBrowserDialog::renderChannelProperties(std::shared_ptr<Oscilloscope> scope, OscilloscopeChannel* scopechan, size_t channelIndex, shared_ptr<OscilloscopeState> scopeState)
1781+
void StreamBrowserDialog::renderChannelProperties(
1782+
shared_ptr<Oscilloscope> scope,
1783+
OscilloscopeChannel* scopechan,
1784+
size_t channelIndex,
1785+
shared_ptr<OscilloscopeState> scopeState)
17821786
{
17831787
float fontSize = ImGui::GetFontSize();
1784-
float width = 6*fontSize;
1788+
float width = 8*fontSize;
17851789

17861790
Unit counts(Unit::UNIT_COUNTS);
1787-
if(renderEditableProperty(width,"Attenuation",scopeState->m_strAttenuation[channelIndex],scopeState->m_committedAttenuation[channelIndex],counts,
1788-
"Attenuation setting for the probe (for example, 10 for a 10:1 probe)"))
1789-
{ // Update offset
1791+
if(renderEditableProperty(
1792+
width,
1793+
"Attenuation",
1794+
scopeState->m_strAttenuation[channelIndex],
1795+
scopeState->m_committedAttenuation[channelIndex],
1796+
counts,
1797+
"Attenuation setting for the probe (for example, 10 for a 10:1 probe)"))
1798+
{
1799+
// Update offset
17901800
scopechan->SetAttenuation(scopeState->m_committedAttenuation[channelIndex]);
17911801
scopeState->m_needsUpdate[channelIndex] = true;
17921802
}
@@ -1823,7 +1833,8 @@ void StreamBrowserDialog::renderChannelProperties(std::shared_ptr<Oscilloscope>
18231833
0,
18241834
false))
18251835
{
1826-
scopechan->SetBandwidthLimit(scopeState->m_bandwidthLimits[channelIndex][scopeState->m_channelBandwidthLimit[channelIndex]]);
1836+
scopechan->SetBandwidthLimit(
1837+
scopeState->m_bandwidthLimits[channelIndex][scopeState->m_channelBandwidthLimit[channelIndex]]);
18271838
scopeState->m_needsUpdate[channelIndex] = true;
18281839
}
18291840
HelpMarker("Hardware bandwidth limiter setting");
@@ -1843,6 +1854,38 @@ void StreamBrowserDialog::renderChannelProperties(std::shared_ptr<Oscilloscope>
18431854
);
18441855
}
18451856

1857+
//Per channel ADC mode switch
1858+
if(scope->IsADCModeConfigurable() && scope->IsADCModePerChannel())
1859+
{
1860+
auto config = GetTimebaseInfoFor(scope);
1861+
bool nomodes = config->m_adcmodeNames.size() <= 1;
1862+
if(nomodes)
1863+
ImGui::BeginDisabled();
1864+
ImGui::SetNextItemWidth(width);
1865+
1866+
if(renderCombo(
1867+
"ADC mode",
1868+
false,
1869+
ImGui::GetStyleColorVec4(ImGuiCol_FrameBg),
1870+
scopeState->m_adcMode[channelIndex],
1871+
config->m_adcmodeNames,
1872+
false,
1873+
0,
1874+
false))
1875+
{
1876+
scope->SetADCMode(channelIndex, scopeState->m_adcMode[channelIndex]);
1877+
}
1878+
if(nomodes)
1879+
ImGui::EndDisabled();
1880+
1881+
HelpMarker(
1882+
"Operating mode for the analog-to-digital converter.\n\n"
1883+
"Some instruments allow the ADC to operate in several modes, typically trading bit depth "
1884+
"against sample rate. Available modes may vary depending on the current sample rate and "
1885+
"which channels are in use."
1886+
);
1887+
}
1888+
18461889
}
18471890

18481891
/**

0 commit comments

Comments
 (0)