How to interrupt while loop for GUI without escaping from the callback function.

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

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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2019년 12월 27일

댓글:

2019년 12월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by