How to interrupt while loop for GUI without escaping from the callback function.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi
I would like to camera module control with MATLAB GUI callback.
There is one toggle button.
if I push the toggle button first,
toggle_stat = 1
and
camera works.
After then, if I push the toggle button again,
toggle_stat = 0
and
camera works with other Exposure time.
this is what I want.
However, If I push the toggle button secondly.
MATLAB escape from the Module_start_toggle_Callback function immediatly and reacess Module_start_toggle_Callback function.
It means that the camera can't not stop correctly and can't not initialize again.
So this camera must Always excute the code 'Module.CaptureStop();'
So I want to know how to use toggle button using the code 'Module.CaptureStop();'
Please, give me the answer for this problem.
Thanks all.
% --- Executes on button press in Module_start_toggle.
function Module_start_toggle_Callback(hObject, eventdata, handles)
% hObject handle to Module_start_toggle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc
toggle_stat = get(handles.Module_start_toggle,'Value');
if (toggle_stat == 1) %
Module.initailize();
Module.ExpsureTimeSet('Auto');
Module.CaptureStart();
while(toggle_stat == 1)
images = Module.getImages();
imshow(images,'Parent',handles.axes1)
drawnow;
end
Module.CaptureStop();
end
elseif (toggle_stat == 0)
Module.initailize();
Module.ExpsureTimeSet('500');
Module.CaptureStart();
while(toggle_stat == 1)
images = Module.getImages();
imshow(images,'Parent',handles.axes1)
drawnow;
end
Module.CaptureStop();
end
1 comentario
Walter Roberson
el 27 de Dic. de 2019
toggle_stat = get(handles.Module_start_toggle,'Value');
Must also go inside your while loops. You currently get() the value once but do not update it.
Respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!