Skip to content

Commit

Permalink
Updated MATLAB GUI code
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Birman committed May 4, 2012
1 parent 4b939a6 commit ff5a032
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
26 changes: 14 additions & 12 deletions MATLAB GUI code/draw.m
@@ -1,9 +1,9 @@


%draw(0,120*rand(96,1)); %draw(0,120*rand(96,1));


function [NS,EW,NS_busy, EW_busy, local_busy_in] = draw(count,x,NS,EW,NS_busy, EW_busy, local_busy_in) function [NS,EW,NS_busy, EW_busy, local_busy_in, blinking] = draw(count,x,NS,EW,NS_busy, EW_busy, local_busy_in,blinking)


t = cputime; %t = cputime;


name{1,1} = {'0000','proc'}; name{1,1} = {'0000','proc'};
name{2,1} = {'0001','mem'}; name{2,1} = {'0001','mem'};
Expand Down Expand Up @@ -55,19 +55,19 @@


x(49:128) = min(floor((x(49:128)+2)/4)+2,9); %busys x(49:128) = min(floor((x(49:128)+2)/4)+2,9); %busys


disp('constants and colours'); e = cputime-t %disp('constants and colours'); e = cputime-t


if(nargin > 2) if(nargin > 2)
%have already drawn the figure %have already drawn the figure


t = cputime; %t = cputime;


draw2(x,NS,EW,facecolor,scale,NS_busy,EW_busy,local_busy_in,name) draw2(x,NS,EW,facecolor,scale,NS_busy,EW_busy,local_busy_in,name,blinking,count)


disp('draw not first'); e = cputime-t %disp('draw not first'); e = cputime-t
else else
%have not drawn figure yet %have not drawn figure yet
t = cputime; %t = cputime;
%char_text = text(scale*40,-scale*5,num2str(x)); %char_text = text(scale*40,-scale*5,num2str(x));


for i = 1:4 %x for i = 1:4 %x
Expand Down Expand Up @@ -119,27 +119,29 @@




%toggle blinking rectangle %toggle blinking rectangle
rectangle('Position',[25*scale,-15*scale,1*scale,1*scale],'FaceColor',mod(count,2)*[0.8,0.8,0.8]+[0.1,0.1,0.1]); blinking = rectangle('Position',[25*scale,-15*scale,1*scale,1*scale],'FaceColor',mod(count,2)*[0.8,0.8,0.8]+[0.1,0.1,0.1]);






hold off hold off
disp('draw first'); e = cputime-t %disp('draw first'); e = cputime-t
end end
else else
length(x) length(x)
end end
t = cputime; %t = cputime;
drawnow; drawnow;
disp('drawnow'); e = cputime-t %disp('drawnow'); e = cputime-t


end end


function draw2(x,NS,EW,facecolor,scale, NS_busy,EW_busy,local_busy_in,name) function draw2(x,NS,EW,facecolor,scale, NS_busy,EW_busy,local_busy_in,name, blinking,count)


hold on hold on
%set(char_text,'Text',num2str(x)); %set(char_text,'Text',num2str(x));


set(blinking,'FaceColor',mod(count,2)*[0.8,0.8,0.8]+[0.1,0.1,0.1]);

for i = 1:4 %x for i = 1:4 %x
for j = 1:4 %y for j = 1:4 %y
set(local_busy_in(i,j),'FaceColor',facecolor(x(1+2*((j-1)+4*(i-1))+96),:)); set(local_busy_in(i,j),'FaceColor',facecolor(x(1+2*((j-1)+4*(i-1))+96),:));
Expand Down
13 changes: 3 additions & 10 deletions MATLAB GUI code/uart.m
Expand Up @@ -23,22 +23,15 @@


%next character %next character
character = fgets(s); character = fgets(s);


%disp(i);
%disp(character);
% disp(length(character));


if(length(character) == 128) if(length(character) == 128)
disp(character); % disp(character);
%fprintf('max = %i',max(cast(out,'int8')));
%disp('new data');
if(first_time == 1) if(first_time == 1)
first_time = 0; first_time = 0;
[NS,EW,NS_busy,EW_busy,local_busy_in] = draw(count,character); [NS,EW,NS_busy,EW_busy,local_busy_in,blinking] = draw(count,character);
count = count + 1; count = count + 1;
else else
draw(count,character,NS,EW,NS_busy,EW_busy,local_busy_in); draw(count,character,NS,EW,NS_busy,EW_busy,local_busy_in,blinking);
count = count + 1; count = count + 1;
end end
else else
Expand Down

0 comments on commit ff5a032

Please sign in to comment.