%
% PURPOSE: Plot Believer telemetry.
% DATE:    11 Jan 2022
%

co = [0 0 1;
      0 0.5 0;
      1 0 0;
      0 0.75 0.75;
      0.75 0 0.75;
      0.75 0.75 0;
      0.25 0.25 0.25];

set(groot,'defaultAxesColorOrder',co)

MonitorPositions = get(0,'MonitorPositions');
nMon = size(MonitorPositions);
nMon = nMon(1);
%Select widest monitor
position = MonitorPositions(1,:);
if( nMon > 1 && MonitorPositions(2,3) > MonitorPositions(1,3) )  
  position =  MonitorPositions(2,:); 
end

%position = get(0,'screensize');
npposition(1:2) = position(1:2) + round([position(3)*.02 position(4)*.04]);
npposition(3:4) = round([position(3)*.95 position(4)*.90]);
position = npposition;


  if( exist( 'fig1Ptr' ) ~= 1 )
    fig1Ptr= figure;
    set( fig1Ptr, 'Name', 'Wave Height', 'DeleteFcn', 'clear fig1Ptr' );
    set(gcf,'position',position)
    if(exist('fontsize')) 
      scanFontsize=fontsize;
    else
      scanFontsize=22;
    end
    scanFontweight='normal';
    set(gca,'fontsize',scanFontsize,'fontweigh',scanFontweight)
    set(gcf,'defaultaxesfontsize',scanFontsize,'defaulttextfontsize', ...
        scanFontsize)
  else
    figure(fig1Ptr);
  end

  subplot(2,1,1)
  plot(log.BARO.TimeS,  log.BARO.Temp,'linewidth',2);
  grid on;
  hold on;
  ylabel('Baro Temp, Celsius')
  title('MB Academy, Flight #1')
  
  subplot(2,1,2)
  plot(log.BARO.TimeS,  log.BARO.Alt,'linewidth',2);
  hold on
  plot(log.BARO.TimeS, log.ARSP.Airspeed,'linewidth',2)
  %set(gca,'linewidth',2);
  grid on
  ylabel('Altitude & Airspeed')
  legend('Altitude, m','Airspeed, m/s')
  xlabel('Seconds Since Mission Start')

  linkaxes(get(gcf,'children'),'x')
  

