How to interrupt while loop for GUI without escaping from the callback function.
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2019-12-27
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!