function varargout = RBDSExampleApp
%RBDSEXAMPLEAPP Further exploration of RDS/RBDS Example

% Copyright 2016-2018 The MathWorks, Inc.

% Top-level figure:
figureHandle = figure('Position', [100 100 1500 500], ...
  'Visible', 'off', ...
  'Resize', 'off', ...
  'HandleVisibility', 'on', ...
  'Color', [0.8 0.8 0.8], ...
  'MenuBar', 'none', ...
  'Name', 'RDS/RBDS and RadioText Plus (RT+) App', ...
  'IntegerHandle', 'off', ...
  'NumberTitle', 'off', ...
  'Tag', 'RBDSApp');
movegui(figureHandle, 'center')

% Viewer:
viewerContainer = uicontainer(figureHandle);
viewerContainer.Position = [0.355 0 0.645 1];
viewer = helperRBDSViewer('ParentHandle', viewerContainer);

% Controller:
controllerContainer = uicontainer(figureHandle);
controllerContainer.Position = [0 0 0.355 1];
hGridController = siglayout.gridbaglayout(controllerContainer);
hGridController.VerticalGap = 15;
hGridController.HorizontalGap = 5;
hGridController.VerticalWeights = [0 0 0 0 1];

controllerPanel = uipanel(controllerContainer, 'Title', 'RDS/RBDS controller');
add(hGridController, controllerPanel, 1, 1, ...
        'Fill', 'Both', ...
        'MinimumHeight', 450, ...
        'MinimumWidth', 230);
controllerPanel2 = uicontainer(controllerContainer);
add(hGridController, controllerPanel2, 2, 1, ...
        'Fill', 'Both', ...
        'MinimumHeight', 100, ...
        'MinimumWidth', 230);

controller = helperRBDSController('ParentHandle',controllerPanel,...
  'Viewer',viewer);

% adjust dimensions:
figureHandle.Position(3) = 850;
figureHandle.Position(4) = 600;

render(controller)

% Frequency specified only in MHz:
freqUnit = findobj(figureHandle, 'Tag', 'CenterFrequencyUnit');
freqUnit.Enable = 'on';

if nargout > 0
  varargout{1} = controller;
end
if nargout > 1
  varargout{2} = viewer;
end
end