1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| function gui_USE_TIMER_4
clear all
close all
clc
x2=1;
y2=1;
scrsz = get(0,'ScreenSize');
% Création de l'objet Figure
hgui=figure('units','pixels',...
'Position',[scrsz(1) scrsz(2) scrsz(3) scrsz(4)],...
'color',[0.925 0.913 0.687],...
'numbertitle','off',...
'name','[GUI] Interface avec le microcontroleur',...
'menubar','none',...
'tag','interface');
% %%%%%%%%%%%%%
% Création de l'objet Uicontrol Pushbutton %%% START %%%
gui.start1=uicontrol('style','pushbutton',... %%%%%%%%%%%%%
'BackgroundColor','g',...
'units','normalized',...
'position',[0.1 0.825 0.1 0.05],...
'FontSize',14,...
'FontWeight','bold',...
'string','START1',...
'callback',@bouton_start1);
% %%%%%%%%%%%%
% Création de l'objet Uicontrol Pushbutton %%% STOP %%%
gui.stop=uicontrol('style','pushbutton',... %%%%%%%%%%%%
'BackgroundColor','g',...
'units','normalized',...
'position',[0.3 0.825 0.1 0.05],...
'FontSize',14,...
'FontWeight','bold',...
'string','STOP',...
'callback',@bouton_stop);
gui.sens_timer=uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.5 0.775 0.7 0.15],...
'FontSize',14,...
'FontWeight','bold',...
'string','Inv_sens_start(timer)');
gui.inv_perio=uicontrol('style','checkbox',...
'units','normalized',...
'position',[0.7 0.775 0.7 0.15],...
'FontSize',14,...
'FontWeight','bold',...
'string','Inv_periode_timer');
%% affichage graphique de la tension et de l'accélération
% Création de l'objet Axes pour le tracer des tensions
gui.h1=axes('units','normalized',...
'position',[0.1 0.4 0.8 0.25]);
period_timer_graph1=0.01;
period_timer_xy=0.09;
%% declaration du timer pour mettre à jour le graph tension
gui.timer_graph1 = timer(...
'BusyMode','queue',...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', period_timer_graph1, ... % Initial period is per_graph1.
'TimerFcn', @update_display1); % Specify callback function
%% declaration du timer pour mettre à jour le graph tension
gui.timer_xy = timer(...
'BusyMode','queue',...
'ExecutionMode', 'fixedRate', ...
'Period', period_timer_xy, ...
'TimerFcn', @calc_xy);
%% FIN DE LA FONCTION PRINCIPALE
% DEBUT DE LA SOUS-FONCTION Bouton_Start %
function bouton_start1(obj,event)
set(gui.start1,'BackgroundColor','r');
set(gui.stop,'BackgroundColor','g');
if get(gui.inv_perio,'Value')
set(gui.timer_graph1,'Period',period_timer_xy);
set(gui.timer_xy,'Period',period_timer_graph1);
else
set(gui.timer_xy,'Period',period_timer_xy);
set(gui.timer_graph1,'Period',period_timer_graph1);
end
if get(gui.sens_timer,'Value')
start(gui.timer_xy);
start(gui.timer_graph1);
else
start(gui.timer_graph1);
start(gui.timer_xy);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Bouton_Start %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Bouton_Stop %
function bouton_stop(obj,event)
set(gui.stop,'BackgroundColor','r');
set(gui.start1,'BackgroundColor','g');
stop(gui.timer_graph1);
stop(gui.timer_xy);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Bouton_Stop %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Affichage_XY %
function update_display1(obj,event)
disp('0000000000000000')
plot(gui.h1,x2,y2,'*');
drawnow;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Affichage XY%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Affichage_XY %
function calc_xy(obj,event)
disp('-----------------')
x2=[x2 rand];
y2=[y2 rand];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Affichage XY%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end |
Partager