O-band Amp Characterization Measurement
This commit is contained in:
@@ -1,20 +1,50 @@
|
||||
function waitUntilClick()
|
||||
% Create the UI figure
|
||||
fig = uifigure('Name', 'Pause Execution', 'Position', [100 100 300 150]);
|
||||
function waitUntilClick(options)
|
||||
|
||||
% Create a label to inform the user
|
||||
uilabel(fig, 'Position', [50 80 200 40], 'Text', 'Click "Continue" to proceed', ...
|
||||
'FontSize', 14, 'HorizontalAlignment', 'center');
|
||||
% use like this to stop any computation and wait for user to press ENTER or
|
||||
% Continue button. I used this in the lab to wait until smth settled or I
|
||||
% set a device to a certain operating point...
|
||||
|
||||
% Create the "Continue" button
|
||||
continueButton = uibutton(fig, 'push', 'Text', 'Continue', 'Position', [100 20 100 40], ...
|
||||
'ButtonPushedFcn', @(src, event) closeWindow());
|
||||
% USAGE:
|
||||
% waitUntilClick;
|
||||
|
||||
% OPTIONAL: provide input text that is prompted :-)
|
||||
% usrcmd = sprintf('Laser to %d dBm',p);
|
||||
% waitUntilClick('Text',usrcmd);
|
||||
|
||||
|
||||
arguments
|
||||
options.Text string = "Click ""Continue"" to proceed"
|
||||
end
|
||||
|
||||
% Create the UI figure
|
||||
fig = uifigure('Name', 'Pause Execution', ...
|
||||
'Position', [100 100 300 150], ...
|
||||
'KeyPressFcn', @(src,event) keyHandler(event));
|
||||
|
||||
% Create a label with custom text
|
||||
uilabel(fig, ...
|
||||
'Position', [30 70 240 60], ...
|
||||
'Text', options.Text, ...
|
||||
'FontSize', 14, ...
|
||||
'HorizontalAlignment', 'center', ...
|
||||
'WordWrap','on');
|
||||
|
||||
% Create the "Continue" button
|
||||
uibutton(fig, 'push', ...
|
||||
'Text', 'Continue', ...
|
||||
'Position', [100 20 100 40], ...
|
||||
'ButtonPushedFcn', @(src, event) closeWindow());
|
||||
|
||||
% Function to close the window when "Continue" is clicked
|
||||
function closeWindow()
|
||||
delete(fig); % Close the figure window
|
||||
delete(fig);
|
||||
end
|
||||
|
||||
% Wait until the figure is closed to resume execution
|
||||
waitfor(fig);
|
||||
end
|
||||
function keyHandler(event)
|
||||
if strcmp(event.Key,'return') || strcmp(event.Key,'enter')
|
||||
closeWindow();
|
||||
end
|
||||
end
|
||||
|
||||
% Wait until the figure is closed
|
||||
waitfor(fig);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user