Skip to content

Commit 47ce3fb

Browse files
committed
Stream browser updates for global ADC mode
1 parent 47e5ea9 commit 47ce3fb

File tree

3 files changed

+99
-21
lines changed

3 files changed

+99
-21
lines changed

src/ngscopeclient/StreamBrowserDialog.cpp

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ StreamBrowserTimebaseInfo::StreamBrowserTimebaseInfo(shared_ptr<Oscilloscope> sc
107107
}
108108
else
109109
m_integrationTime = 0;
110+
111+
m_adcmode = scope->GetADCMode(0);
112+
m_adcmodeNames = scope->GetADCModeNames(0);
110113
}
111114

112115
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -246,7 +249,9 @@ void StreamBrowserDialog::renderBadge(ImVec4 color, ... /* labels, ending in NUL
246249
@param values the combo box values
247250
@param useColorForText if true, use the provided color for text (and a darker version of it for background color)
248251
@param cropTextTo if >0 crop the combo text up to this number of characters to have it fit the available space
249-
@return true true if the selected value of the combo has been changed
252+
@param hideArrow True to hide the dropdown arrow
253+
254+
@return true if the selected value of the combo has been changed
250255
*/
251256
bool StreamBrowserDialog::renderCombo(
252257
const char* label,
@@ -255,7 +260,8 @@ bool StreamBrowserDialog::renderCombo(
255260
int &selected,
256261
const vector<string> &values,
257262
bool useColorForText,
258-
uint8_t cropTextTo)
263+
uint8_t cropTextTo,
264+
bool hideArrow)
259265
{
260266
if(selected >= (int)values.size() || selected < 0)
261267
{
@@ -307,7 +313,9 @@ bool StreamBrowserDialog::renderCombo(
307313
ImGui::PushStyleColor(ImGuiCol_FrameBg, color);
308314
}
309315
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 0));
310-
int flags = ImGuiComboFlags_NoArrowButton;
316+
int flags = 0;
317+
if(hideArrow)
318+
flags |= ImGuiComboFlags_NoArrowButton;
311319
if(alignRight)
312320
flags |= ImGuiComboFlags_WidthFitPreview;
313321

@@ -975,11 +983,17 @@ shared_ptr<StreamBrowserTimebaseInfo> StreamBrowserDialog::GetTimebaseInfoFor(sh
975983
{
976984
//If no timebase info, create it
977985
if(m_timebaseConfig.find(scope) == m_timebaseConfig.end())
986+
{
987+
LogTrace("Creating initial timebase info\n");
978988
m_timebaseConfig[scope] = make_shared<StreamBrowserTimebaseInfo>(scope);
989+
}
979990

980991
//If we had info, but it's clearly out of date, recreate it
981992
else if(m_timebaseConfig[scope]->GetRate() != scope->GetSampleRate())
993+
{
994+
LogTrace("Recreating timebase info (out of date sample rate)\n");
982995
m_timebaseConfig[scope] = make_shared<StreamBrowserTimebaseInfo>(scope);
996+
}
983997

984998
//Use whatever is left
985999
return m_timebaseConfig[scope];
@@ -1088,28 +1102,31 @@ void StreamBrowserDialog::DoSpectrometerSettings(shared_ptr<SCPISpectrometer> sp
10881102
*/
10891103
void StreamBrowserDialog::DoTimebaseSettings(shared_ptr<Oscilloscope> scope)
10901104
{
1091-
auto width = ImGui::GetFontSize() * 5;
1105+
auto width = ImGui::GetFontSize() * 7;
10921106

10931107
//If we don't have timebase settings for the scope, create them
10941108
auto config = GetTimebaseInfoFor(scope);
10951109

10961110
//Interleaving
10971111
bool refresh = false;
1098-
ImGui::SetNextItemWidth(width);
1099-
bool disabled = !scope->CanInterleave();
1100-
ImGui::BeginDisabled(disabled);
1101-
if(renderOnOffToggleEXT("Interleaving", false, config->m_interleaving))
1112+
if(scope->HasInterleavingControls())
11021113
{
1103-
scope->SetInterleaving(config->m_interleaving);
1104-
refresh = true;
1114+
ImGui::SetNextItemWidth(width);
1115+
bool disabled = !scope->CanInterleave();
1116+
ImGui::BeginDisabled(disabled);
1117+
if(renderOnOffToggleEXT("Interleaving", false, config->m_interleaving))
1118+
{
1119+
scope->SetInterleaving(config->m_interleaving);
1120+
refresh = true;
1121+
}
1122+
ImGui::EndDisabled();
1123+
HelpMarker(
1124+
"Combine ADCs from multiple channels to get higher sampling rate on a subset of channels.\n"
1125+
"\n"
1126+
"Some instruments do not have an explicit interleaving switch, but available sample rates "
1127+
"may vary depending on which channels are active."
1128+
);
11051129
}
1106-
ImGui::EndDisabled();
1107-
HelpMarker(
1108-
"Combine ADCs from multiple channels to get higher sampling rate on a subset of channels.\n"
1109-
"\n"
1110-
"Some instruments do not have an explicit interleaving switch, but available sample rates "
1111-
"may vary depending on which channels are active."
1112-
);
11131130

11141131
//Show sampling mode iff both are available
11151132
if(
@@ -1131,6 +1148,12 @@ void StreamBrowserDialog::DoTimebaseSettings(shared_ptr<Oscilloscope> scope)
11311148

11321149
refresh = true;
11331150
}
1151+
1152+
HelpMarker(
1153+
"Switch the acquisition system between real time (continuous capture of consecutive samples\n"
1154+
"and equivalent time (undersampling with a narrow sample-and-hold to build up a high resolution\n"
1155+
"view of a repetitive signal over many acquisitions)"
1156+
);
11341157
}
11351158

11361159
//Sample rate
@@ -1139,26 +1162,76 @@ void StreamBrowserDialog::DoTimebaseSettings(shared_ptr<Oscilloscope> scope)
11391162
"Sample Rate",
11401163
false,
11411164
ImGui::GetStyleColorVec4(ImGuiCol_FrameBg),
1142-
config->m_rate, config->m_rateNames))
1165+
config->m_rate,
1166+
config->m_rateNames,
1167+
false,
1168+
0,
1169+
false))
11431170
{
11441171
scope->SetSampleRate(config->m_rates[config->m_rate]);
11451172
refresh = true;
11461173
}
1174+
HelpMarker(
1175+
"Adjust the ADC sampling rate.\n\n"
1176+
"Note that with some instruments, the set of available sampling rates varies depending on which channels are active."
1177+
);
11471178

11481179
//Memory depth
11491180
ImGui::SetNextItemWidth(width);
11501181
if(renderCombo(
11511182
"Memory Depth",
11521183
false,
11531184
ImGui::GetStyleColorVec4(ImGuiCol_FrameBg),
1154-
config->m_depth, config->m_depthNames))
1185+
config->m_depth,
1186+
config->m_depthNames,
1187+
false,
1188+
0,
1189+
false))
11551190
{
11561191
scope->SetSampleDepth(config->m_depths[config->m_depth]);
11571192
refresh = true;
11581193
}
1194+
HelpMarker(
1195+
"Adjust the number of samples captured each trigger event.\n\n"
1196+
"Note that with some instruments, the maximum memory depth varies depending on which channels are active."
1197+
);
1198+
1199+
//Global ADC mode switch
1200+
if(scope->IsADCModeConfigurable() && !scope->IsADCModePerChannel())
1201+
{
1202+
bool nomodes = config->m_adcmodeNames.size() <= 1;
1203+
if(nomodes)
1204+
ImGui::BeginDisabled();
1205+
ImGui::SetNextItemWidth(width);
1206+
if(renderCombo(
1207+
"ADC mode",
1208+
false,
1209+
ImGui::GetStyleColorVec4(ImGuiCol_FrameBg),
1210+
config->m_adcmode,
1211+
config->m_adcmodeNames,
1212+
false,
1213+
0,
1214+
false))
1215+
{
1216+
scope->SetADCMode(0, config->m_adcmode);
1217+
refresh = true;
1218+
}
1219+
if(nomodes)
1220+
ImGui::EndDisabled();
1221+
1222+
HelpMarker(
1223+
"Operating mode for the analog-to-digital converter.\n\n"
1224+
"Some instruments allow the ADC to operate in several modes, typically trading bit depth "
1225+
"against sample rate. Available modes may vary depending on the current sample rate and "
1226+
"which channels are in use."
1227+
);
1228+
}
11591229

11601230
if(refresh)
1231+
{
11611232
m_timebaseConfig[scope] = make_shared<StreamBrowserTimebaseInfo>(scope);
1233+
LogTrace("Refreshing timebase config for %s\n", scope->m_nickname.c_str());
1234+
}
11621235
}
11631236

11641237
/**

src/ngscopeclient/StreamBrowserDialog.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class StreamBrowserTimebaseInfo
9090
//Spectrometer controls
9191
std::string m_integrationText;
9292
double m_integrationTime;
93+
94+
//ADC mode controls
95+
std::vector<std::string> m_adcmodeNames;
96+
int m_adcmode;
9397
};
9498

9599
class StreamBrowserDialog : public Dialog
@@ -129,7 +133,8 @@ class StreamBrowserDialog : public Dialog
129133
int &selected,
130134
const std::vector<std::string>& values,
131135
bool useColorForText = false,
132-
uint8_t cropTextTo = 0);
136+
uint8_t cropTextTo = 0,
137+
bool hideArrow = true);
133138
bool renderCombo(
134139
const char* label,
135140
bool alignRight,

0 commit comments

Comments
 (0)