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
| function gui_control_KRISTO_v03r04_mini
clear all
close all
clc
x=1;
y=1;
x2=1;
y2=1;
% periode de rafraichissement
% graphique
per_graph1 = 1;
per_graph2 = 4; % le graph du dessous s'affichera 4 fois plus lentement
% save acc
per_acc = 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.start=uicontrol('style','pushbutton',... %%%%%%%%%%%%%
'BackgroundColor','g',...
'units','normalized',...
'position',[0.1 0.825 0.1 0.05],...
'FontSize',14,...
'FontWeight','bold',...
'string','START',...
'callback',@start);
%%%%%%%%%%%%
% Création de l'objet Uicontrol Pushbutton %%% STOP %%%
gui.stop=uicontrol('style','pushbutton',... %%%%%%%%%%%%
'BackgroundColor','g',...
'units','normalized',...
'position',[0.5 0.825 0.1 0.05],...
'FontSize',14,...
'FontWeight','bold',...
'string','STOP',...
'callback',@stop);
%% 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]);
% Création de l'objet Axes pour le tracer de l'accélération
gui.h2=axes('units','normalized',...
'position',[0.1 0.075 0.8 0.25]);
%% declaration du timer pour mettre à jour le graph tension
gui.timer_graph1 = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', per_graph1, ... % Initial period is 1 sec.
'TimerFcn', @update_display1); % Specify callback function
%% declaration du timer pour mettre à jour le graph accéléro
gui.timer_graph2 = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', per_graph2, ... % Initial period is 1 sec.
'TimerFcn', @update_display2); % Specify callback function
%% declaration du timer pour enregistrer les donnees de l'accelero
gui.timer_acc = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', per_acc, ... % Initial period is 1 sec.
'TimerFcn', @save_acc); % Specify callback function
setappdata(hgui,'logindlg',gui)
% DEBUT DE LA SOUS-FONCTION START %
function start(obj,event)
set(gui.start,'BackgroundColor','g');
start(gui.timer_graph1);
start(gui.timer_graph2);
start(gui.timer_acc);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION START%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION STOP %
function stop(obj,event)
set(gui.stop,'BackgroundColor','g');
stop(gui.timer_graph1);
stop(gui.timer_graph2)
stop(gui.timer_acc);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION STOP%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Affichage tension %
function update_display1(obj,event)
x=[x rand];
y=[y rand];
plot(gui.h1,x,y);
drawnow;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Affichage tension%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Affichage accelero %
function update_display2(obj,event)
plot(gui.h2,x2,y2);
drawnow;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Affichage tension%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DEBUT DE LA SOUS-FONCTION Sauvegarde donnees accelero %
function save_acc(obj,event)
x2=[x2 rand];
y2=[y2 rand];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%FIN DE LA SOUS-FONCTION Sauvegarde donnees accelero%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end |
Partager