Open figure in standalone application
古いコメントを表示
I have a script controlling a motorized Pan-Tilt Unit (PTU) using a joystick. The way everything is set-up is that control is basically a continuous loop of 1) Check joystick position 2) Send command to PTU according to joystick position. 3) Repeat.
I want to be able to break this loop by pressing a button, so I can properly close all connections. GUIs, callbacks and more were completely new to me yesterday, but I found a simple solution that works in Matlab but not in the stand-alone application. Can anyone point out my mistake? Help is greatly appreciated!
< Note that the joystick control itself works fine (except for a delay, but that's just a minor problem righ tnow). It really is just the figure with stop-button that doesn't show up >
Code that is turned into a stand-alone .exe:
% COMPORT='COM1';
prompt = {'What COMPORT Should be used? Type {COMX} without brackets, replace X by a number'};
dlg_title = 'Comport';
num_lines = 1;
defaultans = {'COM2'};
COMPORT = inputdlg(prompt,dlg_title,num_lines,defaultans);
obj1=StartComms(COMPORT);
% Set PTU message variables
SSS='IP2'; %PTU slave device identifier
MMM='000'; %PTU master controller identifier
JoyID=0; %joystick ID on current machine
RunJoystick(JoyID,SSS,MMM,obj1)
(Note that the Comport dialogue box shows up perfectly!)
Then, the RunJoystick function is of the shape:
function RunJoystick(JoyID,SSS,MMM,obj1)
% Create figure with close button to stop joystick operation
DlgH = figure;
H = uicontrol('Style', 'PushButton', ...
'String', 'Break', ...
'Callback', 'delete(gcbf)');
while ishandle(H)
% Read Joystick position
%[CODE HERE]
% Steer unit if joystick is used
if [Joystick not centered]
[Send move command to PTU]
else %stop unit if joystick is centered
[Send stop command to PTU]
end
end
end
For some reason, the DlgH figure never shows up in the standalone version, while it does when running in Matlab.
If it is of any help, I create the standalone using
mcc -C -W CTF:archive_name_joytest -m SimpleJoystickTest.m
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!