%UpdateTempGraph

%Plots and Updates Temperature Graph

Ctemp=newTempData(1)*100+newTempData(2)*10+newTempData(3);

TempData=[TempData,Ctemp];

temp = datestr(now,14);

temp = temp(1:size(temp,2)-3);

TempDateS=[TempDateS;temp];

TempDate=[TempDate,now];

printgraph = printgraph +1;

resetgraph = resetgraph +1;

%updates the graph after 5 data points are input

if (printgraph == 5)

   hold on  

   plot(TempDate,TempData);

   plot(TempDate,TempData,'r*');

   %prints text vertically in the plot

   temp = 1:1:(size(TempDate,1));

   set(gca,'XTick',TempDate,'XTickLabel','');

   hx = get(gca,'XLabel');  % Handle to xlabel

   set(hx,'Units','data');

   pos = get(hx,'Position');

   y = pos(2);

   t = [];

   % Place the new labels

   for i = 1:size(TempDateS,1)

      %using the text command to make the labels

      t(i) = text(TempDate(i),y,TempDateS(i,:));

   end

   set(t,'Rotation',90,'HorizontalAlignment','right');

   hold off

   xlabel('Time');

   ylabel('Temperature in °C');

   title('Time Plot of Temperature');

   print('-djpeg75','-r70','c:\brian\school\ee476\final\web\tempGraph');

   printgraph = 0;

end

close(gcf);

close all hidden;

%shifts the history data 1 bit so that are always 20 points

if (resetgraph > 20)

   TempData = [TempData(2:size(TempData,2))];

   TempDate = [TempDate(2:size(TempDate,2))];

   TempDateS = [TempDateS(2:size(TempDateS,1),:)];

end

go =1; %tell tempinput that it is ready to GO!