classdef DMX512_RS232 < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                     matlab.ui.Figure
        GridLayout                   matlab.ui.container.GridLayout
        DMX512LEnsELabel             matlab.ui.control.Label
        ConnectButton                matlab.ui.control.Button
        HelpButton                   matlab.ui.control.Button
        PortdeCommunicationDropDownLabel  matlab.ui.control.Label
        PortdeCommunicationDropDown  matlab.ui.control.DropDown
        InformationsLabel            matlab.ui.control.Label
        TestingApplicationPanel      matlab.ui.container.Panel
        GridLayout2                  matlab.ui.container.GridLayout
        LED1OnOffButton              matlab.ui.control.Button
        RefreshCOMButton             matlab.ui.control.Button
        TabGroup                     matlab.ui.container.TabGroup
        H2O_LEDTab                   matlab.ui.container.Tab
        GridLayout3                  matlab.ui.container.GridLayout
        RougeSliderLabel             matlab.ui.control.Label
        RougeSlider                  matlab.ui.control.Slider
        VertSliderLabel              matlab.ui.control.Label
        VertSlider                   matlab.ui.control.Slider
        BleuSliderLabel              matlab.ui.control.Label
        BleuSlider                   matlab.ui.control.Slider
        H2OAdresseEditFieldLabel     matlab.ui.control.Label
        H2OAdresseEditField          matlab.ui.control.NumericEditField
        MASTERSliderLabel            matlab.ui.control.Label
        MASTERSlider                 matlab.ui.control.Slider
        LED_OFFButton                matlab.ui.control.Button
        LED_ONButton                 matlab.ui.control.Button
        SetH2OALLButton              matlab.ui.control.Button
        RougeValueLabel              matlab.ui.control.Label
        VertValueLabel               matlab.ui.control.Label
        BleuValueLabel               matlab.ui.control.Label
        MasterValueLabel             matlab.ui.control.Label
        CouleurFinaleLampLabel       matlab.ui.control.Label
        CouleurFinaleLamp            matlab.ui.control.Lamp
        WASH_LyreTab                 matlab.ui.container.Tab
        GridLayout5                  matlab.ui.container.GridLayout
        Lyre_OffButton               matlab.ui.control.Button
        Lyre_OnButton                matlab.ui.control.Button
        LyreAdresseEditFieldLabel    matlab.ui.control.Label
        LyreAdresseEditField         matlab.ui.control.NumericEditField
        LyrePanSliderLabel           matlab.ui.control.Label
        LyrePanSlider                matlab.ui.control.Slider
        LyreTiltSliderLabel          matlab.ui.control.Label
        LyreTiltSlider               matlab.ui.control.Slider
        LyreDimSliderLabel           matlab.ui.control.Label
        LyreDimSlider                matlab.ui.control.Slider
        LyreStrobSliderLabel         matlab.ui.control.Label
        LyreStrobSlider              matlab.ui.control.Slider
        SetLyreALLButton             matlab.ui.control.Button
        LyreRougeSliderLabel         matlab.ui.control.Label
        LyreRougeSlider              matlab.ui.control.Slider
        LyreVertSliderLabel          matlab.ui.control.Label
        LyreVertSlider               matlab.ui.control.Slider
        LyreBleuSliderLabel          matlab.ui.control.Label
        LyreBleuSlider               matlab.ui.control.Slider
        LyreBlancSliderLabel         matlab.ui.control.Label
        LyreBlancSlider              matlab.ui.control.Slider
        VitesseSliderLabel           matlab.ui.control.Label
        VitesseSlider                matlab.ui.control.Slider
        CouleurLyreLampLabel         matlab.ui.control.Label
        CouleurLyreLamp              matlab.ui.control.Lamp
        channelsTab                  matlab.ui.container.Tab
        GridLayout4                  matlab.ui.container.GridLayout
        Ch0EditFieldLabel            matlab.ui.control.Label
        Ch0EditField                 matlab.ui.control.NumericEditField
        Add_ChEditFieldLabel         matlab.ui.control.Label
        Add_ChEditField              matlab.ui.control.NumericEditField
        Ch1EditFieldLabel            matlab.ui.control.Label
        Ch1EditField                 matlab.ui.control.NumericEditField
        Ch3EditFieldLabel            matlab.ui.control.Label
        Ch3EditField                 matlab.ui.control.NumericEditField
        Ch4EditFieldLabel            matlab.ui.control.Label
        Ch4EditField                 matlab.ui.control.NumericEditField
        Ch5EditFieldLabel            matlab.ui.control.Label
        Ch5EditField                 matlab.ui.control.NumericEditField
        Ch2EditFieldLabel            matlab.ui.control.Label
        Ch2EditField                 matlab.ui.control.NumericEditField
        Ch6EditFieldLabel            matlab.ui.control.Label
        Ch6EditField                 matlab.ui.control.NumericEditField
        Ch7EditFieldLabel            matlab.ui.control.Label
        Ch7EditField                 matlab.ui.control.NumericEditField
        Ch8EditFieldLabel            matlab.ui.control.Label
        Ch8EditField                 matlab.ui.control.NumericEditField
        Ch9EditFieldLabel            matlab.ui.control.Label
        Ch9EditField                 matlab.ui.control.NumericEditField
        Ch10EditFieldLabel           matlab.ui.control.Label
        Ch10EditField                matlab.ui.control.NumericEditField
        Ch11EditFieldLabel           matlab.ui.control.Label
        Ch11EditField                matlab.ui.control.NumericEditField
        Ch12EditFieldLabel           matlab.ui.control.Label
        Ch12EditField                matlab.ui.control.NumericEditField
        SENDButton                   matlab.ui.control.Button
        NOTYETLabel                  matlab.ui.control.Label
    end

    
    properties (Access = private)
        s % serial port
        portList % list of the different available comm ports
        connected = 0;
        sended_data;
    end
    
    methods (Access = private)
        
        % Mise à jour couleur Lamp appli H2O
        function updateH2OLamp(app, ~)
            rouge = round(app.RougeSlider.Value);
            vert = round(app.VertSlider.Value);
            bleu = round(app.BleuSlider.Value);
            app.CouleurFinaleLamp.Color = [rouge/255.0 vert/255.0 bleu/255.0];
        end
        % Extinction Lamp H2O
        function offH2OLamp(app, ~)
            app.CouleurFinaleLamp.Color = [0 0 0];
        end
        
        % Mise à jour couleur Lamp appli Lyre WASH42
        function updateLyreLamp(app, ~)
            rouge = round(app.LyreRougeSlider.Value);
            vert = round(app.LyreVertSlider.Value);
            bleu = round(app.LyreBleuSlider.Value);
            app.CouleurLyreLamp.Color = [rouge/255.0 vert/255.0 bleu/255.0];
        end
        % Extinction Lamp Lyre WASH42
        function offLyreLamp(app, ~) 
            app.CouleurLyreLamp.Color = [0 0 0];
        end       
        % Interruption sur reception de donnees
        function rs232Interrupt(app, src, ~)
            rLine = readline(src);
            rLineChar = char(rLine);
            if rLineChar(1:1) == 'k'
                app.InformationsLabel.Text = 'Connected';
                app.connected = 1;
            elseif rLineChar(1:1) == 'a'
                app.InformationsLabel.Text = 'LED ON';
                app.LED1OnOffButton.BackgroundColor = '#7CFC00';
                app.LED1OnOffButton.FontColor = 'black';
            elseif rLineChar(1:1) == 'e'
                app.InformationsLabel.Text = 'LED OFF';
                app.LED1OnOffButton.BackgroundColor = '#DC143C';
                app.LED1OnOffButton.FontColor = 'white';
            %elseif rLineChar(1:1) == 'd'
            %    app.InformationsLabel.Text = 'Data sended = '+app.sended_data;
            end
            drawnow;
            flush(app.s);
        end
    end
    

    % Callbacks that handle component events
    methods (Access = private)

        % Code that executes after component creation
        function startupFcn(app)
            app.portList = serialportlist();
            app.PortdeCommunicationDropDown.Items = app.portList;
            if(~isempty(app.portList))
                app.ConnectButton.Enable = true;
            else
                app.ConnectButton.Enable = false;
            end
            app.LED1OnOffButton.BackgroundColor = '#DC143C';
            app.LED1OnOffButton.FontColor = 'white';
            % H2O
            app.RougeSlider.Enable = false;
            app.VertSlider.Enable = false;
            app.BleuSlider.Enable = false;
            app.MASTERSlider.Enable = false;
            app.LED_OFFButton.Enable = false;
            app.LED_ONButton.Enable = false;
            app.SetH2OALLButton.Enable = false;
            app.RougeValueLabel.Text = num2str(0);
            app.VertValueLabel.Text = num2str(0);
            app.BleuValueLabel.Text = num2str(0);
            app.MasterValueLabel.Text = num2str(0);
            app.offH2OLamp();
            % Lyre
            app.LyrePanSlider.Enable = false;
            app.LyreTiltSlider.Enable = false;
            app.LyreDimSlider.Enable = false;
            app.LyreStrobSlider.Enable = false;
            app.LyreRougeSlider.Enable = false;
            app.LyreVertSlider.Enable = false;
            app.LyreBleuSlider.Enable = false;
            app.LyreBlancSlider.Enable = false;
            app.VitesseSlider.Enable = false;
            app.SetLyreALLButton.Enable = false;
            app.Lyre_OnButton.Enable = false;
            app.Lyre_OffButton.Enable = false;
            app.offLyreLamp();
            % Channels
            app.SENDButton.Enable = false;
            drawnow;
        end

        % Button pushed function: ConnectButton
        function ConnectButtonPushed(app, event)
            try
                app.s = serialport(app.PortdeCommunicationDropDown.Value, 115200);            
                configureTerminator(app.s, "CR/LF");
                configureCallback(app.s, "terminator", @app.rs232Interrupt);
                app.ConnectButton.Enable = false;
            catch
                warning('Problem using serial.');
            end
            app.InformationsLabel.Text = "OK "+app.PortdeCommunicationDropDown.Value;
            % H2O
            app.RougeSlider.Enable = true;
            app.VertSlider.Enable = true;
            app.BleuSlider.Enable = true;
            app.MASTERSlider.Enable = true;
            app.LED_ONButton.Enable = true;
            app.LED_OFFButton.Enable = true;
            app.SetH2OALLButton.Enable = true;
            % Lyre
            app.LyrePanSlider.Enable = true;
            app.LyreTiltSlider.Enable = true;
            app.LyreDimSlider.Enable = true;
            app.LyreStrobSlider.Enable = true;
            app.LyreRougeSlider.Enable = true;
            app.LyreVertSlider.Enable = true;
            app.LyreBleuSlider.Enable = true;
            app.LyreBlancSlider.Enable = true;
            app.VitesseSlider.Enable = true;
            app.SetLyreALLButton.Enable = true;
            app.Lyre_OnButton.Enable = true;
            app.Lyre_OffButton.Enable = true;
            % Channels
            app.SENDButton.Enable = true;
            drawnow;
        end

        % Button pushed function: HelpButton
        function HelpButtonPushed(app, event)
            open DMX512_RS232.mlx;
        end

        % Button pushed function: RefreshCOMButton
        function RefreshCOMButtonPushed(app, event)
            app.portList = serialportlist();
            app.PortdeCommunicationDropDown.Items = app.portList;
        end

        % Button pushed function: LED1OnOffButton
        function LED1OnOffButtonPushed(app, event)
            if(~isempty(app.s))
                writeline(app.s, 'a');
            end
        end

        % Value changed function: RougeSlider
        function SetRButtonPushed(app, event)
            % Couleur rouge sur H2O
            address = round(app.H2OAdresseEditField.Value);
            rouge = round(app.RougeSlider.Value);
            app.updateH2OLamp();
            app.RougeValueLabel.Text = num2str(rouge);
            app.InformationsLabel.Text = "AD = "+address+" / Rouge = "+rouge;
            str_to_send = strcat('d:',num2str(address),':1:',num2str(rouge),';');
            app.InformationsLabel.Text = str_to_send;
            drawnow;
            if(~isempty(app.s))
                writeline(app.s, str_to_send);
            end
        end

        % Value changed function: VertSlider
        function SetGButtonPushed(app, event)
            % Couleur vert sur H2O
            address = round(app.H2OAdresseEditField.Value);
            vert = round(app.VertSlider.Value);
            app.updateH2OLamp();
            app.VertValueLabel.Text = num2str(vert);
            app.InformationsLabel.Text = "AD = "+address+" / Vert = "+vert;
            str_to_send = strcat('d:',num2str(address+1),':1:',num2str(vert),';');
            drawnow;
            writeline(app.s, str_to_send);            
        end

        % Value changed function: BleuSlider
        function SetBButtonPushed(app, event)
            % Couleur bleu sur H2O
            address = round(app.H2OAdresseEditField.Value);
            bleu = round(app.BleuSlider.Value);
            app.updateH2OLamp();
            app.BleuValueLabel.Text = num2str(bleu);
            app.InformationsLabel.Text = "AD = "+address+" / Bleu = "+bleu;
            str_to_send = strcat('d:',num2str(address+2),':1:',num2str(bleu),';');
            drawnow;
            writeline(app.s, str_to_send);                  
        end

        % Value changed function: MASTERSlider
        function SetMButtonPushed(app, event)
            % Dimmer sur H2O
            address = round(app.H2OAdresseEditField.Value);
            master = round(app.MASTERSlider.Value);
            app.updateH2OLamp();
            app.MasterValueLabel.Text = num2str(master);            
            app.InformationsLabel.Text = "AD = "+address+" / MASTER = "+master;
            str_to_send = strcat('d:',num2str(address+3),':1:',num2str(master),';');
            drawnow;
            writeline(app.s, str_to_send);                  
        end

        % Button pushed function: LED_OFFButton
        function LED_OFFButtonPushed(app, event)
            address = round(app.H2OAdresseEditField.Value);
            app.InformationsLabel.Text = "AD = "+address+" / OFF";
            app.offH2OLamp();
            str_to_send = strcat('d:',num2str(address+4),':1:',num2str(1),';');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Button pushed function: LED_ONButton
        function LED_ONButtonPushed(app, event)
            address = round(app.H2OAdresseEditField.Value);
            master = round(app.MASTERSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / ON";
            app.updateH2OLamp();
            str_to_send = strcat('d:',num2str(address+3),':2:',num2str(master),':',num2str(0),';');
            drawnow;
            writeline(app.s, str_to_send);             
        end

        % Button pushed function: SetH2OALLButton
        function SetH2OALLButtonPushed(app, event)
            address = round(app.H2OAdresseEditField.Value);
            rouge = round(app.RougeSlider.Value);
            vert = round(app.VertSlider.Value);
            bleu = round(app.BleuSlider.Value);
            master = round(app.MASTERSlider.Value);
            str_to_send = strcat('d:',num2str(address),':5:',num2str(rouge),':',num2str(vert),':',num2str(bleu),':',num2str(master),':0;');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Value changed function: LyrePanSlider
        function SetPanButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            pan = round(app.LyrePanSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / PAN = "+pan;
            str_to_send = strcat('d:',num2str(address),':1:',num2str(pan),';');
            drawnow;
            writeline(app.s, str_to_send);              
        end

        % Value changed function: LyreTiltSlider
        function SetTiltButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            tilt = round(app.LyreTiltSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / TILT = "+tilt;
            str_to_send = strcat('d:',num2str(address+1),':1:',num2str(tilt),';');
            drawnow;
            writeline(app.s, str_to_send);                
        end

        % Value changed function: LyreDimSlider
        function SetDimButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            dimmer = round(app.LyreDimSlider.Value);
            app.updateLyreLamp();
            app.InformationsLabel.Text = "AD = "+address+" / DIM = "+dimmer;
            str_to_send = strcat('d:',num2str(address+2),':1:',num2str(dimmer),';');
            drawnow;
            writeline(app.s, str_to_send);               
        end

        % Value changed function: LyreStrobSlider
        function SetStrobButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            strob = round(app.LyreStrobSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / STROB = "+strob;
            str_to_send = strcat('d:',num2str(address+2),':1:',num2str(strob),';');
            drawnow;
            writeline(app.s, str_to_send);              
        end

        % Value changed function: LyreRougeSlider
        function SetLyreRButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            rouge = round(app.LyreRougeSlider.Value);
            app.updateLyreLamp();
            app.InformationsLabel.Text = "AD = "+address+" / ROUGE = "+rouge;
            str_to_send = strcat('d:',num2str(address+3),':1:',num2str(rouge),';');
            drawnow;
            writeline(app.s, str_to_send);             
        end

        % Value changed function: LyreVertSlider
        function SetLyreVButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            vert = round(app.LyreVertSlider.Value);
            app.updateLyreLamp();
            app.InformationsLabel.Text = "AD = "+address+" / VERT = "+vert;
            str_to_send = strcat('d:',num2str(address+4),':1:',num2str(vert),';');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Value changed function: LyreBleuSlider
        function SetLyreBButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            bleu = round(app.LyreBleuSlider.Value);
            app.updateLyreLamp();
            app.InformationsLabel.Text = "AD = "+address+" / BLEU = "+bleu;
            str_to_send = strcat('d:',num2str(address+5),':1:',num2str(bleu),';');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Value changed function: LyreBlancSlider
        function SetLyreWButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            blanc = round(app.LyreBlancSlider.Value);
            app.updateLyreLamp();
            app.InformationsLabel.Text = "AD = "+address+" / BLANC = "+blanc;
            str_to_send = strcat('d:',num2str(address+6),':1:',num2str(blanc),';');
            drawnow;
            writeline(app.s, str_to_send);             
        end

        % Value changed function: VitesseSlider
        function SetVitesseButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            vitesse = round(app.VitesseSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / VITESSE = "+vitesse;
            str_to_send = strcat('d:',num2str(address+7),':1:',num2str(vitesse),';');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Button pushed function: Lyre_OffButton
        function Lyre_OffButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            app.InformationsLabel.Text = "AD = "+address+" / OFF";
            app.offLyreLamp();
            str_to_send = strcat('d:',num2str(address+2),':1:',num2str(0),';');
            drawnow;
            writeline(app.s, str_to_send);             
        end

        % Button pushed function: Lyre_OnButton
        function Lyre_OnButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            app.InformationsLabel.Text = "AD = "+address+" / ON";
            app.updateLyreLamp();
            str_to_send = strcat('d:',num2str(address+2),':1:',num2str(255),';');
            drawnow;
            writeline(app.s, str_to_send); 
        end

        % Button pushed function: SetLyreALLButton
        function SetLyreALLButtonPushed(app, event)
            address = round(app.LyreAdresseEditField.Value);
            pan = round(app.LyrePanSlider.Value);
            tilt = round(app.LyreTiltSlider.Value);
            dimmer = round(app.LyreDimSlider.Value);
            rouge = round(app.LyreRougeSlider.Value);
            vert = round(app.LyreVertSlider.Value);
            bleu = round(app.LyreBleuSlider.Value);
            blanc = round(app.LyreBlancSlider.Value);
            vitesse = round(app.VitesseSlider.Value);
            app.InformationsLabel.Text = "AD = "+address+" / ALL";
            app.sended_data = strcat('d:',num2str(address),':8:',num2str(pan),':',num2str(tilt),':');
            app.sended_data = strcat(app.sended_data, num2str(dimmer),':',num2str(rouge),':');
            app.sended_data = strcat(app.sended_data, num2str(vert),':',num2str(bleu),':');
            app.sended_data = strcat(app.sended_data, num2str(blanc),':',num2str(vitesse),';');
            app.InformationsLabel.Text = strcat("OK ",app.sended_data);
            drawnow;
            writeline(app.s, app.sended_data); 
        end

        % Button pushed function: SENDButton
        function SENDButtonPushed(app, event)
            address = round(app.Add_ChEditField.Value);
            str_to_send = strcat("d:",num2str(address),':');
            if app.Ch0EditField.Value ~= -1
                str_to_send = strcat(str_to_send,num2str(app.Ch0EditField.Value));
            end
            if app.Ch1EditField.Value ~= -1
                str_to_send = strcat(str_to_send,':',num2str(app.Ch1EditField.Value));
            else
                str_to_send = strcat(str_to_send,';');
                writeline(app.s, str_to_send); 
            end   
            if app.Ch2EditField.Value ~= -1
                str_to_send = strcat(str_to_send,':',num2str(app.Ch2EditField.Value));
            else
                str_to_send = strcat(str_to_send,';');
                writeline(app.s, str_to_send); 
            end 
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [50 50 879 753];
            app.UIFigure.Name = 'MATLAB App';

            % Create GridLayout
            app.GridLayout = uigridlayout(app.UIFigure);
            app.GridLayout.ColumnWidth = {'2x', '1x'};
            app.GridLayout.RowHeight = {'1x', '10x', '1x', '1x'};

            % Create DMX512LEnsELabel
            app.DMX512LEnsELabel = uilabel(app.GridLayout);
            app.DMX512LEnsELabel.HorizontalAlignment = 'center';
            app.DMX512LEnsELabel.FontSize = 20;
            app.DMX512LEnsELabel.FontColor = [1 0.4118 0.1608];
            app.DMX512LEnsELabel.Layout.Row = 1;
            app.DMX512LEnsELabel.Layout.Column = 1;
            app.DMX512LEnsELabel.Text = 'DMX512 / LEnsE';

            % Create ConnectButton
            app.ConnectButton = uibutton(app.GridLayout, 'push');
            app.ConnectButton.ButtonPushedFcn = createCallbackFcn(app, @ConnectButtonPushed, true);
            app.ConnectButton.FontSize = 20;
            app.ConnectButton.FontWeight = 'bold';
            app.ConnectButton.Layout.Row = 4;
            app.ConnectButton.Layout.Column = 2;
            app.ConnectButton.Text = 'Connect';

            % Create HelpButton
            app.HelpButton = uibutton(app.GridLayout, 'push');
            app.HelpButton.ButtonPushedFcn = createCallbackFcn(app, @HelpButtonPushed, true);
            app.HelpButton.FontSize = 14;
            app.HelpButton.Layout.Row = 1;
            app.HelpButton.Layout.Column = 2;
            app.HelpButton.Text = 'Help';

            % Create PortdeCommunicationDropDownLabel
            app.PortdeCommunicationDropDownLabel = uilabel(app.GridLayout);
            app.PortdeCommunicationDropDownLabel.HorizontalAlignment = 'right';
            app.PortdeCommunicationDropDownLabel.Layout.Row = 3;
            app.PortdeCommunicationDropDownLabel.Layout.Column = 1;
            app.PortdeCommunicationDropDownLabel.Text = 'Port de Communication';

            % Create PortdeCommunicationDropDown
            app.PortdeCommunicationDropDown = uidropdown(app.GridLayout);
            app.PortdeCommunicationDropDown.Items = {'Choisir'};
            app.PortdeCommunicationDropDown.Layout.Row = 3;
            app.PortdeCommunicationDropDown.Layout.Column = 2;
            app.PortdeCommunicationDropDown.Value = 'Choisir';

            % Create InformationsLabel
            app.InformationsLabel = uilabel(app.GridLayout);
            app.InformationsLabel.HorizontalAlignment = 'center';
            app.InformationsLabel.Layout.Row = 4;
            app.InformationsLabel.Layout.Column = 1;
            app.InformationsLabel.Text = 'Informations';

            % Create TestingApplicationPanel
            app.TestingApplicationPanel = uipanel(app.GridLayout);
            app.TestingApplicationPanel.ForegroundColor = [0.502 0.502 0.502];
            app.TestingApplicationPanel.TitlePosition = 'centertop';
            app.TestingApplicationPanel.Title = 'Testing Application';
            app.TestingApplicationPanel.Layout.Row = 2;
            app.TestingApplicationPanel.Layout.Column = 2;
            app.TestingApplicationPanel.FontSize = 16;

            % Create GridLayout2
            app.GridLayout2 = uigridlayout(app.TestingApplicationPanel);
            app.GridLayout2.ColumnWidth = {'1x'};
            app.GridLayout2.RowHeight = {'1x', '1x', '1x', '1x', '1x', '1x'};

            % Create LED1OnOffButton
            app.LED1OnOffButton = uibutton(app.GridLayout2, 'push');
            app.LED1OnOffButton.ButtonPushedFcn = createCallbackFcn(app, @LED1OnOffButtonPushed, true);
            app.LED1OnOffButton.FontSize = 14;
            app.LED1OnOffButton.FontWeight = 'bold';
            app.LED1OnOffButton.FontColor = [1 0.0745 0.651];
            app.LED1OnOffButton.Layout.Row = 1;
            app.LED1OnOffButton.Layout.Column = 1;
            app.LED1OnOffButton.Text = 'LED1 On/Off';

            % Create RefreshCOMButton
            app.RefreshCOMButton = uibutton(app.GridLayout2, 'push');
            app.RefreshCOMButton.ButtonPushedFcn = createCallbackFcn(app, @RefreshCOMButtonPushed, true);
            app.RefreshCOMButton.FontSize = 14;
            app.RefreshCOMButton.FontWeight = 'bold';
            app.RefreshCOMButton.Layout.Row = 6;
            app.RefreshCOMButton.Layout.Column = 1;
            app.RefreshCOMButton.Text = 'Refresh COM';

            % Create TabGroup
            app.TabGroup = uitabgroup(app.GridLayout);
            app.TabGroup.Layout.Row = 2;
            app.TabGroup.Layout.Column = 1;

            % Create H2O_LEDTab
            app.H2O_LEDTab = uitab(app.TabGroup);
            app.H2O_LEDTab.Title = 'H2O_LED';

            % Create GridLayout3
            app.GridLayout3 = uigridlayout(app.H2O_LEDTab);
            app.GridLayout3.ColumnWidth = {'1x', '4x', '1x'};
            app.GridLayout3.RowHeight = {'1x', '1x', '1x', '1x', '1x', '1x', '1x'};

            % Create RougeSliderLabel
            app.RougeSliderLabel = uilabel(app.GridLayout3);
            app.RougeSliderLabel.BackgroundColor = [1 0 0];
            app.RougeSliderLabel.HorizontalAlignment = 'center';
            app.RougeSliderLabel.FontSize = 15;
            app.RougeSliderLabel.FontColor = [1 1 1];
            app.RougeSliderLabel.Layout.Row = 2;
            app.RougeSliderLabel.Layout.Column = 1;
            app.RougeSliderLabel.Text = 'Rouge';

            % Create RougeSlider
            app.RougeSlider = uislider(app.GridLayout3);
            app.RougeSlider.Limits = [0 255];
            app.RougeSlider.MajorTicks = [0 50 100 150 200 250];
            app.RougeSlider.ValueChangedFcn = createCallbackFcn(app, @SetRButtonPushed, true);
            app.RougeSlider.FontSize = 15;
            app.RougeSlider.Layout.Row = 2;
            app.RougeSlider.Layout.Column = 2;

            % Create VertSliderLabel
            app.VertSliderLabel = uilabel(app.GridLayout3);
            app.VertSliderLabel.BackgroundColor = [0 1 0];
            app.VertSliderLabel.HorizontalAlignment = 'center';
            app.VertSliderLabel.FontSize = 15;
            app.VertSliderLabel.Layout.Row = 3;
            app.VertSliderLabel.Layout.Column = 1;
            app.VertSliderLabel.Text = 'Vert';

            % Create VertSlider
            app.VertSlider = uislider(app.GridLayout3);
            app.VertSlider.Limits = [0 255];
            app.VertSlider.MajorTicks = [0 50 100 150 200 250];
            app.VertSlider.ValueChangedFcn = createCallbackFcn(app, @SetGButtonPushed, true);
            app.VertSlider.FontSize = 15;
            app.VertSlider.Layout.Row = 3;
            app.VertSlider.Layout.Column = 2;

            % Create BleuSliderLabel
            app.BleuSliderLabel = uilabel(app.GridLayout3);
            app.BleuSliderLabel.BackgroundColor = [0.302 0.7451 0.9333];
            app.BleuSliderLabel.HorizontalAlignment = 'center';
            app.BleuSliderLabel.FontSize = 15;
            app.BleuSliderLabel.Layout.Row = 4;
            app.BleuSliderLabel.Layout.Column = 1;
            app.BleuSliderLabel.Text = 'Bleu';

            % Create BleuSlider
            app.BleuSlider = uislider(app.GridLayout3);
            app.BleuSlider.Limits = [0 255];
            app.BleuSlider.MajorTicks = [0 50 100 150 200 250];
            app.BleuSlider.ValueChangedFcn = createCallbackFcn(app, @SetBButtonPushed, true);
            app.BleuSlider.FontSize = 15;
            app.BleuSlider.Layout.Row = 4;
            app.BleuSlider.Layout.Column = 2;

            % Create H2OAdresseEditFieldLabel
            app.H2OAdresseEditFieldLabel = uilabel(app.GridLayout3);
            app.H2OAdresseEditFieldLabel.BackgroundColor = [0.9412 0.9412 0.9412];
            app.H2OAdresseEditFieldLabel.HorizontalAlignment = 'right';
            app.H2OAdresseEditFieldLabel.Layout.Row = 1;
            app.H2OAdresseEditFieldLabel.Layout.Column = 1;
            app.H2OAdresseEditFieldLabel.Text = 'H2OAdresse';

            % Create H2OAdresseEditField
            app.H2OAdresseEditField = uieditfield(app.GridLayout3, 'numeric');
            app.H2OAdresseEditField.BackgroundColor = [0.9412 0.9412 0.9412];
            app.H2OAdresseEditField.Layout.Row = 1;
            app.H2OAdresseEditField.Layout.Column = 2;

            % Create MASTERSliderLabel
            app.MASTERSliderLabel = uilabel(app.GridLayout3);
            app.MASTERSliderLabel.HorizontalAlignment = 'center';
            app.MASTERSliderLabel.FontSize = 15;
            app.MASTERSliderLabel.FontWeight = 'bold';
            app.MASTERSliderLabel.Layout.Row = 5;
            app.MASTERSliderLabel.Layout.Column = 1;
            app.MASTERSliderLabel.Text = 'MASTER';

            % Create MASTERSlider
            app.MASTERSlider = uislider(app.GridLayout3);
            app.MASTERSlider.Limits = [0 255];
            app.MASTERSlider.MajorTicks = [0 50 100 150 200 250];
            app.MASTERSlider.ValueChangedFcn = createCallbackFcn(app, @SetMButtonPushed, true);
            app.MASTERSlider.FontSize = 15;
            app.MASTERSlider.Layout.Row = 5;
            app.MASTERSlider.Layout.Column = 2;

            % Create LED_OFFButton
            app.LED_OFFButton = uibutton(app.GridLayout3, 'push');
            app.LED_OFFButton.ButtonPushedFcn = createCallbackFcn(app, @LED_OFFButtonPushed, true);
            app.LED_OFFButton.FontSize = 14;
            app.LED_OFFButton.FontWeight = 'bold';
            app.LED_OFFButton.FontAngle = 'italic';
            app.LED_OFFButton.Layout.Row = 6;
            app.LED_OFFButton.Layout.Column = 1;
            app.LED_OFFButton.Text = 'LED_OFF';

            % Create LED_ONButton
            app.LED_ONButton = uibutton(app.GridLayout3, 'push');
            app.LED_ONButton.ButtonPushedFcn = createCallbackFcn(app, @LED_ONButtonPushed, true);
            app.LED_ONButton.FontSize = 14;
            app.LED_ONButton.FontWeight = 'bold';
            app.LED_ONButton.FontAngle = 'italic';
            app.LED_ONButton.Layout.Row = 6;
            app.LED_ONButton.Layout.Column = 3;
            app.LED_ONButton.Text = 'LED_ON';

            % Create SetH2OALLButton
            app.SetH2OALLButton = uibutton(app.GridLayout3, 'push');
            app.SetH2OALLButton.ButtonPushedFcn = createCallbackFcn(app, @SetH2OALLButtonPushed, true);
            app.SetH2OALLButton.FontSize = 15;
            app.SetH2OALLButton.FontWeight = 'bold';
            app.SetH2OALLButton.Layout.Row = 6;
            app.SetH2OALLButton.Layout.Column = 2;
            app.SetH2OALLButton.Text = 'SetH2OALL';

            % Create RougeValueLabel
            app.RougeValueLabel = uilabel(app.GridLayout3);
            app.RougeValueLabel.BackgroundColor = [1 0 0];
            app.RougeValueLabel.HorizontalAlignment = 'center';
            app.RougeValueLabel.FontSize = 15;
            app.RougeValueLabel.FontWeight = 'bold';
            app.RougeValueLabel.FontColor = [1 1 1];
            app.RougeValueLabel.Layout.Row = 2;
            app.RougeValueLabel.Layout.Column = 3;
            app.RougeValueLabel.Text = 'RougeValue';

            % Create VertValueLabel
            app.VertValueLabel = uilabel(app.GridLayout3);
            app.VertValueLabel.BackgroundColor = [0 1 0];
            app.VertValueLabel.HorizontalAlignment = 'center';
            app.VertValueLabel.FontSize = 15;
            app.VertValueLabel.FontWeight = 'bold';
            app.VertValueLabel.Layout.Row = 3;
            app.VertValueLabel.Layout.Column = 3;
            app.VertValueLabel.Text = 'VertValue';

            % Create BleuValueLabel
            app.BleuValueLabel = uilabel(app.GridLayout3);
            app.BleuValueLabel.BackgroundColor = [0.0745 0.6235 1];
            app.BleuValueLabel.HorizontalAlignment = 'center';
            app.BleuValueLabel.FontSize = 15;
            app.BleuValueLabel.FontWeight = 'bold';
            app.BleuValueLabel.Layout.Row = 4;
            app.BleuValueLabel.Layout.Column = 3;
            app.BleuValueLabel.Text = 'BleuValue';

            % Create MasterValueLabel
            app.MasterValueLabel = uilabel(app.GridLayout3);
            app.MasterValueLabel.BackgroundColor = [1 1 1];
            app.MasterValueLabel.HorizontalAlignment = 'center';
            app.MasterValueLabel.FontSize = 15;
            app.MasterValueLabel.FontWeight = 'bold';
            app.MasterValueLabel.Layout.Row = 5;
            app.MasterValueLabel.Layout.Column = 3;
            app.MasterValueLabel.Text = 'MasterValue';

            % Create CouleurFinaleLampLabel
            app.CouleurFinaleLampLabel = uilabel(app.GridLayout3);
            app.CouleurFinaleLampLabel.HorizontalAlignment = 'right';
            app.CouleurFinaleLampLabel.Layout.Row = 7;
            app.CouleurFinaleLampLabel.Layout.Column = 2;
            app.CouleurFinaleLampLabel.Text = 'Couleur Finale';

            % Create CouleurFinaleLamp
            app.CouleurFinaleLamp = uilamp(app.GridLayout3);
            app.CouleurFinaleLamp.Layout.Row = 7;
            app.CouleurFinaleLamp.Layout.Column = 3;

            % Create WASH_LyreTab
            app.WASH_LyreTab = uitab(app.TabGroup);
            app.WASH_LyreTab.Title = 'WASH_Lyre';

            % Create GridLayout5
            app.GridLayout5 = uigridlayout(app.WASH_LyreTab);
            app.GridLayout5.ColumnWidth = {'1x', '4x', '1x'};
            app.GridLayout5.RowHeight = {'1x', '1x', '1x', '1x', '1x', '1x', '1x', '1x', '1x', '1x', '1x', '2x'};

            % Create Lyre_OffButton
            app.Lyre_OffButton = uibutton(app.GridLayout5, 'push');
            app.Lyre_OffButton.ButtonPushedFcn = createCallbackFcn(app, @Lyre_OffButtonPushed, true);
            app.Lyre_OffButton.FontWeight = 'bold';
            app.Lyre_OffButton.FontAngle = 'italic';
            app.Lyre_OffButton.Layout.Row = 11;
            app.Lyre_OffButton.Layout.Column = 1;
            app.Lyre_OffButton.Text = 'Lyre_Off';

            % Create Lyre_OnButton
            app.Lyre_OnButton = uibutton(app.GridLayout5, 'push');
            app.Lyre_OnButton.ButtonPushedFcn = createCallbackFcn(app, @Lyre_OnButtonPushed, true);
            app.Lyre_OnButton.FontWeight = 'bold';
            app.Lyre_OnButton.FontAngle = 'italic';
            app.Lyre_OnButton.Layout.Row = 11;
            app.Lyre_OnButton.Layout.Column = 3;
            app.Lyre_OnButton.Text = 'Lyre_On';

            % Create LyreAdresseEditFieldLabel
            app.LyreAdresseEditFieldLabel = uilabel(app.GridLayout5);
            app.LyreAdresseEditFieldLabel.BackgroundColor = [0.9412 0.9412 0.9412];
            app.LyreAdresseEditFieldLabel.HorizontalAlignment = 'right';
            app.LyreAdresseEditFieldLabel.Layout.Row = 1;
            app.LyreAdresseEditFieldLabel.Layout.Column = 1;
            app.LyreAdresseEditFieldLabel.Text = 'LyreAdresse';

            % Create LyreAdresseEditField
            app.LyreAdresseEditField = uieditfield(app.GridLayout5, 'numeric');
            app.LyreAdresseEditField.BackgroundColor = [0.9412 0.9412 0.9412];
            app.LyreAdresseEditField.Layout.Row = 1;
            app.LyreAdresseEditField.Layout.Column = 2;

            % Create LyrePanSliderLabel
            app.LyrePanSliderLabel = uilabel(app.GridLayout5);
            app.LyrePanSliderLabel.BackgroundColor = [0.9294 0.6941 0.1255];
            app.LyrePanSliderLabel.HorizontalAlignment = 'right';
            app.LyrePanSliderLabel.FontWeight = 'bold';
            app.LyrePanSliderLabel.Layout.Row = 2;
            app.LyrePanSliderLabel.Layout.Column = 1;
            app.LyrePanSliderLabel.Text = 'LyrePan';

            % Create LyrePanSlider
            app.LyrePanSlider = uislider(app.GridLayout5);
            app.LyrePanSlider.Limits = [0 255];
            app.LyrePanSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyrePanSlider.ValueChangedFcn = createCallbackFcn(app, @SetPanButtonPushed, true);
            app.LyrePanSlider.FontWeight = 'bold';
            app.LyrePanSlider.Layout.Row = 2;
            app.LyrePanSlider.Layout.Column = 2;

            % Create LyreTiltSliderLabel
            app.LyreTiltSliderLabel = uilabel(app.GridLayout5);
            app.LyreTiltSliderLabel.BackgroundColor = [0.8 0.8 0.8];
            app.LyreTiltSliderLabel.HorizontalAlignment = 'right';
            app.LyreTiltSliderLabel.FontWeight = 'bold';
            app.LyreTiltSliderLabel.Layout.Row = 3;
            app.LyreTiltSliderLabel.Layout.Column = 1;
            app.LyreTiltSliderLabel.Text = 'LyreTilt';

            % Create LyreTiltSlider
            app.LyreTiltSlider = uislider(app.GridLayout5);
            app.LyreTiltSlider.Limits = [0 255];
            app.LyreTiltSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyreTiltSlider.ValueChangedFcn = createCallbackFcn(app, @SetTiltButtonPushed, true);
            app.LyreTiltSlider.FontWeight = 'bold';
            app.LyreTiltSlider.Layout.Row = 3;
            app.LyreTiltSlider.Layout.Column = 2;

            % Create LyreDimSliderLabel
            app.LyreDimSliderLabel = uilabel(app.GridLayout5);
            app.LyreDimSliderLabel.HorizontalAlignment = 'right';
            app.LyreDimSliderLabel.FontWeight = 'bold';
            app.LyreDimSliderLabel.Layout.Row = 4;
            app.LyreDimSliderLabel.Layout.Column = 1;
            app.LyreDimSliderLabel.Text = 'LyreDim';

            % Create LyreDimSlider
            app.LyreDimSlider = uislider(app.GridLayout5);
            app.LyreDimSlider.Limits = [8 134];
            app.LyreDimSlider.ValueChangedFcn = createCallbackFcn(app, @SetDimButtonPushed, true);
            app.LyreDimSlider.FontWeight = 'bold';
            app.LyreDimSlider.Layout.Row = 4;
            app.LyreDimSlider.Layout.Column = 2;
            app.LyreDimSlider.Value = 8;

            % Create LyreStrobSliderLabel
            app.LyreStrobSliderLabel = uilabel(app.GridLayout5);
            app.LyreStrobSliderLabel.HorizontalAlignment = 'right';
            app.LyreStrobSliderLabel.FontWeight = 'bold';
            app.LyreStrobSliderLabel.Layout.Row = 5;
            app.LyreStrobSliderLabel.Layout.Column = 1;
            app.LyreStrobSliderLabel.Text = 'LyreStrob';

            % Create LyreStrobSlider
            app.LyreStrobSlider = uislider(app.GridLayout5);
            app.LyreStrobSlider.Limits = [135 239];
            app.LyreStrobSlider.ValueChangedFcn = createCallbackFcn(app, @SetStrobButtonPushed, true);
            app.LyreStrobSlider.FontWeight = 'bold';
            app.LyreStrobSlider.Layout.Row = 5;
            app.LyreStrobSlider.Layout.Column = 2;
            app.LyreStrobSlider.Value = 135;

            % Create SetLyreALLButton
            app.SetLyreALLButton = uibutton(app.GridLayout5, 'push');
            app.SetLyreALLButton.ButtonPushedFcn = createCallbackFcn(app, @SetLyreALLButtonPushed, true);
            app.SetLyreALLButton.FontSize = 14;
            app.SetLyreALLButton.FontWeight = 'bold';
            app.SetLyreALLButton.Layout.Row = 11;
            app.SetLyreALLButton.Layout.Column = 2;
            app.SetLyreALLButton.Text = 'SetLyreALL';

            % Create LyreRougeSliderLabel
            app.LyreRougeSliderLabel = uilabel(app.GridLayout5);
            app.LyreRougeSliderLabel.BackgroundColor = [1 0 0];
            app.LyreRougeSliderLabel.HorizontalAlignment = 'right';
            app.LyreRougeSliderLabel.FontWeight = 'bold';
            app.LyreRougeSliderLabel.FontColor = [1 1 1];
            app.LyreRougeSliderLabel.Layout.Row = 6;
            app.LyreRougeSliderLabel.Layout.Column = 1;
            app.LyreRougeSliderLabel.Text = 'LyreRouge';

            % Create LyreRougeSlider
            app.LyreRougeSlider = uislider(app.GridLayout5);
            app.LyreRougeSlider.Limits = [0 255];
            app.LyreRougeSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyreRougeSlider.ValueChangedFcn = createCallbackFcn(app, @SetLyreRButtonPushed, true);
            app.LyreRougeSlider.FontWeight = 'bold';
            app.LyreRougeSlider.Layout.Row = 6;
            app.LyreRougeSlider.Layout.Column = 2;

            % Create LyreVertSliderLabel
            app.LyreVertSliderLabel = uilabel(app.GridLayout5);
            app.LyreVertSliderLabel.BackgroundColor = [0 1 0];
            app.LyreVertSliderLabel.HorizontalAlignment = 'right';
            app.LyreVertSliderLabel.FontWeight = 'bold';
            app.LyreVertSliderLabel.Layout.Row = 7;
            app.LyreVertSliderLabel.Layout.Column = 1;
            app.LyreVertSliderLabel.Text = 'LyreVert';

            % Create LyreVertSlider
            app.LyreVertSlider = uislider(app.GridLayout5);
            app.LyreVertSlider.Limits = [0 255];
            app.LyreVertSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyreVertSlider.ValueChangedFcn = createCallbackFcn(app, @SetLyreVButtonPushed, true);
            app.LyreVertSlider.FontWeight = 'bold';
            app.LyreVertSlider.Layout.Row = 7;
            app.LyreVertSlider.Layout.Column = 2;

            % Create LyreBleuSliderLabel
            app.LyreBleuSliderLabel = uilabel(app.GridLayout5);
            app.LyreBleuSliderLabel.BackgroundColor = [0.302 0.7451 0.9333];
            app.LyreBleuSliderLabel.HorizontalAlignment = 'right';
            app.LyreBleuSliderLabel.FontWeight = 'bold';
            app.LyreBleuSliderLabel.Layout.Row = 8;
            app.LyreBleuSliderLabel.Layout.Column = 1;
            app.LyreBleuSliderLabel.Text = 'LyreBleu';

            % Create LyreBleuSlider
            app.LyreBleuSlider = uislider(app.GridLayout5);
            app.LyreBleuSlider.Limits = [0 255];
            app.LyreBleuSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyreBleuSlider.ValueChangedFcn = createCallbackFcn(app, @SetLyreBButtonPushed, true);
            app.LyreBleuSlider.FontWeight = 'bold';
            app.LyreBleuSlider.Layout.Row = 8;
            app.LyreBleuSlider.Layout.Column = 2;

            % Create LyreBlancSliderLabel
            app.LyreBlancSliderLabel = uilabel(app.GridLayout5);
            app.LyreBlancSliderLabel.BackgroundColor = [1 1 1];
            app.LyreBlancSliderLabel.HorizontalAlignment = 'right';
            app.LyreBlancSliderLabel.FontWeight = 'bold';
            app.LyreBlancSliderLabel.Layout.Row = 9;
            app.LyreBlancSliderLabel.Layout.Column = 1;
            app.LyreBlancSliderLabel.Text = 'LyreBlanc';

            % Create LyreBlancSlider
            app.LyreBlancSlider = uislider(app.GridLayout5);
            app.LyreBlancSlider.Limits = [0 255];
            app.LyreBlancSlider.MajorTicks = [0 50 100 150 200 250];
            app.LyreBlancSlider.ValueChangedFcn = createCallbackFcn(app, @SetLyreWButtonPushed, true);
            app.LyreBlancSlider.FontWeight = 'bold';
            app.LyreBlancSlider.Layout.Row = 9;
            app.LyreBlancSlider.Layout.Column = 2;

            % Create VitesseSliderLabel
            app.VitesseSliderLabel = uilabel(app.GridLayout5);
            app.VitesseSliderLabel.HorizontalAlignment = 'right';
            app.VitesseSliderLabel.FontWeight = 'bold';
            app.VitesseSliderLabel.Layout.Row = 10;
            app.VitesseSliderLabel.Layout.Column = 1;
            app.VitesseSliderLabel.Text = 'Vitesse';

            % Create VitesseSlider
            app.VitesseSlider = uislider(app.GridLayout5);
            app.VitesseSlider.Limits = [0 255];
            app.VitesseSlider.MajorTicks = [0 50 100 150 200 250];
            app.VitesseSlider.ValueChangedFcn = createCallbackFcn(app, @SetVitesseButtonPushed, true);
            app.VitesseSlider.FontWeight = 'bold';
            app.VitesseSlider.Layout.Row = 10;
            app.VitesseSlider.Layout.Column = 2;

            % Create CouleurLyreLampLabel
            app.CouleurLyreLampLabel = uilabel(app.GridLayout5);
            app.CouleurLyreLampLabel.HorizontalAlignment = 'right';
            app.CouleurLyreLampLabel.Layout.Row = 12;
            app.CouleurLyreLampLabel.Layout.Column = 2;
            app.CouleurLyreLampLabel.Text = 'Couleur Lyre';

            % Create CouleurLyreLamp
            app.CouleurLyreLamp = uilamp(app.GridLayout5);
            app.CouleurLyreLamp.Layout.Row = 12;
            app.CouleurLyreLamp.Layout.Column = 3;

            % Create channelsTab
            app.channelsTab = uitab(app.TabGroup);
            app.channelsTab.Title = 'channels';

            % Create GridLayout4
            app.GridLayout4 = uigridlayout(app.channelsTab);
            app.GridLayout4.ColumnWidth = {'1x', '2x', '1x', '2x'};
            app.GridLayout4.RowHeight = {'1x', '1x', '1x', '1x', '1x', '1x', '1x', '1x'};

            % Create Ch0EditFieldLabel
            app.Ch0EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch0EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch0EditFieldLabel.Layout.Row = 2;
            app.Ch0EditFieldLabel.Layout.Column = 1;
            app.Ch0EditFieldLabel.Text = 'Ch0';

            % Create Ch0EditField
            app.Ch0EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch0EditField.Layout.Row = 2;
            app.Ch0EditField.Layout.Column = 2;
            app.Ch0EditField.Value = -1;

            % Create Add_ChEditFieldLabel
            app.Add_ChEditFieldLabel = uilabel(app.GridLayout4);
            app.Add_ChEditFieldLabel.HorizontalAlignment = 'right';
            app.Add_ChEditFieldLabel.Layout.Row = 1;
            app.Add_ChEditFieldLabel.Layout.Column = 1;
            app.Add_ChEditFieldLabel.Text = 'Add_Ch';

            % Create Add_ChEditField
            app.Add_ChEditField = uieditfield(app.GridLayout4, 'numeric');
            app.Add_ChEditField.BackgroundColor = [0.9412 0.9412 0.9412];
            app.Add_ChEditField.Layout.Row = 1;
            app.Add_ChEditField.Layout.Column = 2;

            % Create Ch1EditFieldLabel
            app.Ch1EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch1EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch1EditFieldLabel.Layout.Row = 3;
            app.Ch1EditFieldLabel.Layout.Column = 1;
            app.Ch1EditFieldLabel.Text = 'Ch1';

            % Create Ch1EditField
            app.Ch1EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch1EditField.Layout.Row = 3;
            app.Ch1EditField.Layout.Column = 2;
            app.Ch1EditField.Value = -1;

            % Create Ch3EditFieldLabel
            app.Ch3EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch3EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch3EditFieldLabel.Layout.Row = 5;
            app.Ch3EditFieldLabel.Layout.Column = 1;
            app.Ch3EditFieldLabel.Text = 'Ch3';

            % Create Ch3EditField
            app.Ch3EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch3EditField.Layout.Row = 5;
            app.Ch3EditField.Layout.Column = 2;
            app.Ch3EditField.Value = -1;

            % Create Ch4EditFieldLabel
            app.Ch4EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch4EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch4EditFieldLabel.Layout.Row = 6;
            app.Ch4EditFieldLabel.Layout.Column = 1;
            app.Ch4EditFieldLabel.Text = 'Ch4';

            % Create Ch4EditField
            app.Ch4EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch4EditField.Layout.Row = 6;
            app.Ch4EditField.Layout.Column = 2;
            app.Ch4EditField.Value = -1;

            % Create Ch5EditFieldLabel
            app.Ch5EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch5EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch5EditFieldLabel.Layout.Row = 7;
            app.Ch5EditFieldLabel.Layout.Column = 1;
            app.Ch5EditFieldLabel.Text = 'Ch5';

            % Create Ch5EditField
            app.Ch5EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch5EditField.Layout.Row = 7;
            app.Ch5EditField.Layout.Column = 2;
            app.Ch5EditField.Value = -1;

            % Create Ch2EditFieldLabel
            app.Ch2EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch2EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch2EditFieldLabel.Layout.Row = 4;
            app.Ch2EditFieldLabel.Layout.Column = 1;
            app.Ch2EditFieldLabel.Text = 'Ch2';

            % Create Ch2EditField
            app.Ch2EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch2EditField.Layout.Row = 4;
            app.Ch2EditField.Layout.Column = 2;
            app.Ch2EditField.Value = -1;

            % Create Ch6EditFieldLabel
            app.Ch6EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch6EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch6EditFieldLabel.Layout.Row = 8;
            app.Ch6EditFieldLabel.Layout.Column = 1;
            app.Ch6EditFieldLabel.Text = 'Ch6';

            % Create Ch6EditField
            app.Ch6EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch6EditField.Layout.Row = 8;
            app.Ch6EditField.Layout.Column = 2;
            app.Ch6EditField.Value = -1;

            % Create Ch7EditFieldLabel
            app.Ch7EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch7EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch7EditFieldLabel.Layout.Row = 2;
            app.Ch7EditFieldLabel.Layout.Column = 3;
            app.Ch7EditFieldLabel.Text = 'Ch7';

            % Create Ch7EditField
            app.Ch7EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch7EditField.Layout.Row = 2;
            app.Ch7EditField.Layout.Column = 4;
            app.Ch7EditField.Value = -1;

            % Create Ch8EditFieldLabel
            app.Ch8EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch8EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch8EditFieldLabel.Layout.Row = 3;
            app.Ch8EditFieldLabel.Layout.Column = 3;
            app.Ch8EditFieldLabel.Text = 'Ch8';

            % Create Ch8EditField
            app.Ch8EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch8EditField.Layout.Row = 3;
            app.Ch8EditField.Layout.Column = 4;
            app.Ch8EditField.Value = -1;

            % Create Ch9EditFieldLabel
            app.Ch9EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch9EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch9EditFieldLabel.Layout.Row = 4;
            app.Ch9EditFieldLabel.Layout.Column = 3;
            app.Ch9EditFieldLabel.Text = 'Ch9';

            % Create Ch9EditField
            app.Ch9EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch9EditField.Layout.Row = 4;
            app.Ch9EditField.Layout.Column = 4;
            app.Ch9EditField.Value = -1;

            % Create Ch10EditFieldLabel
            app.Ch10EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch10EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch10EditFieldLabel.Layout.Row = 5;
            app.Ch10EditFieldLabel.Layout.Column = 3;
            app.Ch10EditFieldLabel.Text = 'Ch10';

            % Create Ch10EditField
            app.Ch10EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch10EditField.Layout.Row = 5;
            app.Ch10EditField.Layout.Column = 4;
            app.Ch10EditField.Value = -1;

            % Create Ch11EditFieldLabel
            app.Ch11EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch11EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch11EditFieldLabel.Layout.Row = 6;
            app.Ch11EditFieldLabel.Layout.Column = 3;
            app.Ch11EditFieldLabel.Text = 'Ch11';

            % Create Ch11EditField
            app.Ch11EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch11EditField.Layout.Row = 6;
            app.Ch11EditField.Layout.Column = 4;
            app.Ch11EditField.Value = -1;

            % Create Ch12EditFieldLabel
            app.Ch12EditFieldLabel = uilabel(app.GridLayout4);
            app.Ch12EditFieldLabel.HorizontalAlignment = 'right';
            app.Ch12EditFieldLabel.Layout.Row = 7;
            app.Ch12EditFieldLabel.Layout.Column = 3;
            app.Ch12EditFieldLabel.Text = 'Ch12';

            % Create Ch12EditField
            app.Ch12EditField = uieditfield(app.GridLayout4, 'numeric');
            app.Ch12EditField.Layout.Row = 7;
            app.Ch12EditField.Layout.Column = 4;
            app.Ch12EditField.Value = -1;

            % Create SENDButton
            app.SENDButton = uibutton(app.GridLayout4, 'push');
            app.SENDButton.ButtonPushedFcn = createCallbackFcn(app, @SENDButtonPushed, true);
            app.SENDButton.BackgroundColor = [0.8 0.8 0.8];
            app.SENDButton.FontSize = 15;
            app.SENDButton.FontWeight = 'bold';
            app.SENDButton.Layout.Row = 1;
            app.SENDButton.Layout.Column = 4;
            app.SENDButton.Text = 'SEND';

            % Create NOTYETLabel
            app.NOTYETLabel = uilabel(app.GridLayout4);
            app.NOTYETLabel.HorizontalAlignment = 'center';
            app.NOTYETLabel.Layout.Row = 8;
            app.NOTYETLabel.Layout.Column = 4;
            app.NOTYETLabel.Text = 'NOT YET !!';

            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = DMX512_RS232

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end