how to enter function into app designer ?
2 ビュー (過去 30 日間)
古いコメントを表示
So I want to use UART prtocol into my project . I build the UART protocol ,but I want to use this protocol via appdesigner . So for exmaple I want to write the number In a Numeric Field box and to send this number to the UART protocol . how do I do it ?
this is my UART protocol :
%% Instrument Connection
% Find a serial port object.
obj1 = instrfind('Type', 'serial', 'Port', 'COM3', 'Tag', '');
% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = serial('COM3');
else
fclose(obj1);
obj1 = obj1(1);
end
% Connect to instrument object, obj1.
fopen(obj1);
%%% Instrument Configuration and Control\
% Communicating with instrument object, obj1.
fwrite(obj1,23 , 'uint8');
in this last line of code :
fwrite(obj1,23 , 'uint8');
I send the number that I want to send in the UART protocol . But I want to enter this number (for example 23 in this case ) via NumericEditField in the app designer . How to do it ?
0 件のコメント
回答 (1 件)
Adam Danz
2019 年 8 月 21 日
編集済み: Adam Danz
2020 年 1 月 18 日
"I want to write the number in a Numeric Field box and to send this number to the UART protocol"
From within your app code, these two lines will get the numeric text value and send it to fwrite(). The two lines can be placed in any callback function that responds to interaction with a GUI component. Assuming the numeric text field is named "EditField1",
value = app.EditField1.Value; % or whatever your handle is
fwrite(obj1, value, 'uint8');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!