Ejemplo n.º 1
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            //fill out relevant variables
            cbGUISpeechEnabled.Checked = gui_settings.speech_enabled;
            sOptionsConfigFilename = sOptionsConfigFilename + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems
            iCheckBoxItems = 24;                    //Theoretical maximum

            splash.sStatus = "Building internal data structures...";
            splash.Refresh();

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mission_step = new mission_step_structure();

            //Quick hack to get pid names to mw_params untill redo the structures
            for (int i = 0; i < iPidItems; i++)
            {
                mw_params.pidnames[i] = Pid[i].name;
            }

            splash.sFcVersionLabel = "MultiWii version " + sRelName;
            splash.sStatus = "Connecting to MAP server...";
            splash.Refresh();

            MainMap.Manager.Mode = AccessMode.ServerAndCache;
            if (!Stuff.PingNetwork("pingtest.com"))
            {
                MainMap.Manager.Mode = AccessMode.CacheOnly;
                MessageBox.Show("No internet connection available, going to CacheOnly mode.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



            cbMapProviders.SelectedIndex = gui_settings.iMapProviderSelectedIndex;
            MainMap.MapProvider = mapProviders[gui_settings.iMapProviderSelectedIndex];
            MainMap.Zoom = 18;

            splash.sStatus = "Building up GUI elements...";
            splash.Refresh();

            bSerialBuffer = new byte[65];
            inBuf = new byte[300];   //init input buffer

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //rcOptions1 = new byte[iCheckBoxItems];
            //rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;

            cbCellcount.SelectedIndex = gui_settings.cellcount - 1;
            cbGUISpeechEnabled.Checked = gui_settings.speech_enabled;
            cbSpeakAlt.Checked = gui_settings.announce_alt_enabled;
            cbSpeakBattery.Checked = gui_settings.announce_vbat_enabled;
            cbSpeakDist.Checked = gui_settings.announce_dist_enabled;
            comboSpeakInterval.SelectedIndex = gui_settings.announce_interval;

            b_save_gui_settings.BackColor = Color.Transparent;

            splash.sStatus = "Build PID structures...";
            splash.Refresh();


            //Build servo control arrays
            // It is a mess and not an elegant solution BUT WORKS
            servo_text = new System.Windows.Forms.Label[8];
            servo_text[0] = lSrvName1;
            servo_text[1] = lSrvName2;
            servo_text[2] = lSrvName3;
            servo_text[3] = lSrvName4;
            servo_text[4] = lSrvName5;
            servo_text[5] = lSrvName6;
            servo_text[6] = lSrvName7;
            servo_text[7] = lSrvName8;

            servo_reverse = new CheckBoxEx[8];
            servo_reverse[0] = cbSrvRev1;
            servo_reverse[1] = cbSrvRev2;
            servo_reverse[2] = cbSrvRev3;
            servo_reverse[3] = cbSrvRev4;
            servo_reverse[4] = cbSrvRev5;
            servo_reverse[5] = cbSrvRev6;
            servo_reverse[6] = cbSrvRev7;
            servo_reverse[7] = cbSrvRev8;

            servo_rate = new System.Windows.Forms.NumericUpDown[8];
            servo_rate[0] = nSrvRate1;
            servo_rate[1] = nSrvRate2;
            servo_rate[2] = nSrvRate3;
            servo_rate[3] = nSrvRate4;
            servo_rate[4] = nSrvRate5;
            servo_rate[5] = nSrvRate6;
            servo_rate[6] = nSrvRate7;
            servo_rate[7] = nSrvRate8;

            servo_min = new System.Windows.Forms.NumericUpDown[8];
            servo_min[0] = nSrvMin1;
            servo_min[1] = nSrvMin2;
            servo_min[2] = nSrvMin3;
            servo_min[3] = nSrvMin4;
            servo_min[4] = nSrvMin5;
            servo_min[5] = nSrvMin6;
            servo_min[6] = nSrvMin7;
            servo_min[7] = nSrvMin8;

            servo_mid = new System.Windows.Forms.NumericUpDown[8];
            servo_mid[0] = nSrvMid1;
            servo_mid[1] = nSrvMid2;
            servo_mid[2] = nSrvMid3;
            servo_mid[3] = nSrvMid4;
            servo_mid[4] = nSrvMid5;
            servo_mid[5] = nSrvMid6;
            servo_mid[6] = nSrvMid7;
            servo_mid[7] = nSrvMid8;

            servo_max = new System.Windows.Forms.NumericUpDown[8];
            servo_max[0] = nSrvMax1;
            servo_max[1] = nSrvMax2;
            servo_max[2] = nSrvMax3;
            servo_max[3] = nSrvMax4;
            servo_max[4] = nSrvMax5;
            servo_max[5] = nSrvMax6;
            servo_max[6] = nSrvMax7;
            servo_max[7] = nSrvMax8;


            //Build PID control structure based on the Pid structure.

            const int iLineSpace = 36;
            const int iRow1 = 30;
            const int iRow2 = 130;
            const int iRow3 = 230;
            const int iTopY = 25;
            Font fontField = new Font("Tahoma", 9, FontStyle.Bold);
            Size fieldSize = new Size(70, 25);

            for (int i = 0; i < iPidItems; i++)
            {
                Pid[i].pidLabel = new System.Windows.Forms.Label();
                Pid[i].pidLabel.Text = Pid[i].name;
                Pid[i].pidLabel.Location = new Point(iRow1, 10 + i * iLineSpace);
                Pid[i].pidLabel.Visible = true;
                Pid[i].pidLabel.AutoSize = true;
                Pid[i].pidLabel.ForeColor = Color.White;
                Pid[i].pidLabel.TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(Pid[i].pidLabel, Pid[i].description);
                this.tabPagePID.Controls.Add(Pid[i].pidLabel);

                if (Pid[i].Pshown)
                {
                    Pid[i].Pfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Pfield.ValueChanged += new EventHandler(pfield_valuechange);
                    Pid[i].Pfield.Location = new Point(iRow1, iTopY + i * iLineSpace);
                    Pid[i].Pfield.Size = fieldSize;
                    Pid[i].Pfield.Font = fontField;
                    Pid[i].Pfield.BorderStyle = BorderStyle.None;
                    Pid[i].Pfield.Maximum = Pid[i].Pmax;
                    Pid[i].Pfield.Minimum = Pid[i].Pmin;
                    Pid[i].Pfield.DecimalPlaces = decimals(Pid[i].Pprec);
                    Pid[i].Pfield.Increment = 1 / (decimal)Pid[i].Pprec;
                    this.tabPagePID.Controls.Add(Pid[i].Pfield);

                    Pid[i].Plabel = new System.Windows.Forms.Label();
                    Pid[i].Plabel.Text = "P";
                    Pid[i].Plabel.Font = fontField;
                    Pid[i].Plabel.ForeColor = Color.White;
                    Pid[i].Plabel.Location = new Point(iRow1 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Plabel);

                }
                if (Pid[i].Ishown)
                {
                    Pid[i].Ifield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Ifield.ValueChanged += new EventHandler(ifield_valuechange);
                    Pid[i].Ifield.Location = new Point(iRow2, iTopY + i * iLineSpace);
                    Pid[i].Ifield.Size = fieldSize;
                    Pid[i].Ifield.Font = fontField;
                    Pid[i].Ifield.BorderStyle = BorderStyle.None;
                    Pid[i].Ifield.Maximum = Pid[i].Imax;
                    Pid[i].Ifield.Minimum = Pid[i].Imin;
                    Pid[i].Ifield.DecimalPlaces = decimals(Pid[i].Iprec);
                    Pid[i].Ifield.Increment = 1 / (decimal)Pid[i].Iprec;
                    this.tabPagePID.Controls.Add(Pid[i].Ifield);

                    Pid[i].Ilabel = new System.Windows.Forms.Label();
                    Pid[i].Ilabel.Text = "I";
                    Pid[i].Ilabel.Font = fontField;
                    Pid[i].Ilabel.ForeColor = Color.White;
                    Pid[i].Ilabel.Location = new Point(iRow2 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Ilabel);



                }
                if (Pid[i].Dshown)
                {
                    Pid[i].Dfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Dfield.ValueChanged += new EventHandler(dfield_valuechange);
                    Pid[i].Dfield.Location = new Point(iRow3, iTopY + i * iLineSpace);
                    Pid[i].Dfield.Size = fieldSize;
                    Pid[i].Dfield.Font = fontField;
                    Pid[i].Dfield.BorderStyle = BorderStyle.None;
                    Pid[i].Dfield.Maximum = Pid[i].Dmax;
                    Pid[i].Dfield.Minimum = Pid[i].Dmin;
                    Pid[i].Dfield.DecimalPlaces = decimals(Pid[i].Dprec);
                    Pid[i].Dfield.Increment = 1 / (decimal)Pid[i].Dprec;
                    this.tabPagePID.Controls.Add(Pid[i].Dfield);

                    Pid[i].Dlabel = new System.Windows.Forms.Label();
                    Pid[i].Dlabel.Text = "D";
                    Pid[i].Dlabel.Font = fontField;
                    Pid[i].Dlabel.ForeColor = Color.White;
                    Pid[i].Dlabel.Location = new Point(iRow3 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Dlabel);

                }


                //Set up stuff at the mission palane
                txtDefAlt.Text = iDefAlt.ToString();        //Set up default altitude
                txtGTCAlt.Text = iGTCAlt.ToString();        //Set up default Go to Click altitude


            }


            //Tooltips (needs improvement)

            toolTip1.SetToolTip(b_check_all_ACC, "Select all ACC values");
            toolTip1.SetToolTip(b_uncheck_all_ACC, "Deselect all ACC values");
            toolTip1.SetToolTip(lDefAlt, "Default waypoint altitude (in Above Ground Level where Home position Ground level is zero)");
            toolTip1.SetToolTip(txtDefAlt, "Default waypoint altitude (in Above Ground Level where Home position Ground level is zero)");






            this.Refresh();

            splash.sStatus = "Check serial ports...";
            splash.Refresh();



            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;




            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 1;              //10Hz is the default

            splash.sStatus = "Setup Timers...";
            splash.Refresh();



            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();


            splash.sStatus = "Setup zgMonitor control...";
            splash.Refresh();


            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.XAxis.MajorGrid.Color = Color.DarkGray;
            myPane.YAxis.MajorGrid.Color = Color.DarkGray;


            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.DarkGray;
            myPane.YAxis.Title.FontSpec.FontColor = Color.DarkGray;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Color = Color.DarkGray;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -300;
            myPane.YAxis.Scale.Max = 300;
            myPane.XAxis.Color = Color.DarkGray;

            myPane.Border.Color = Color.FromArgb(64, 64, 64);

            myPane.Chart.Fill = new Fill(Color.Black, Color.Black, 45.0f);
            myPane.Fill = new Fill(Color.FromArgb(64, 64, 64), Color.FromArgb(64, 64, 64), 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }


            myPane.YAxis.Title.FontSpec.FontColor = Color.DarkGray;
            myPane.XAxis.Title.FontSpec.FontColor = Color.DarkGray;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;



            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();


            splash.sStatus = "Init video capture structures...";
            splash.Refresh();



            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);


            //Disable buttons that are not working till connected
            b_reset.Enabled = false;
            b_cal_acc.Enabled = false;
            b_cal_mag.Enabled = false;
            b_read_settings.Enabled = false;
            b_write_settings.Enabled = false;
            b_write_to_file.Enabled = false;
            b_load_from_file.Enabled = false;
            btnDownLoadMission.Enabled = false;
            btnUploadMission.Enabled = false;



            //init instrument panels
            altitude_meter1.SetAlimeterParameters(0);
            vertical_speed_indicator1.SetVerticalSpeedIndicatorParameters(0);


            System.Threading.Thread.Sleep(2000);
            splash.Close();
            MainMap.Invalidate(false);

            int w = MainMap.Size.Width;
            MainMap.Width = w +1 ;
            MainMap.Width = w;
            MainMap.ShowCenter = false;


            mw_gui.max_wp_number = gui_settings.max_wp_number;
            mw_gui.wp_radius = gui_settings.wp_radius;

            //Welcome message from Anna
            if (gui_settings.speech_enabled)
            {
                speech = new SpeechSynthesizer();
                speech.Rate = -2;
                speech.SpeakAsync("Initialisation completed. Have a good flight!");
            }

        }
Ejemplo n.º 2
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            sOptionsConfigFilename = sOptionsConfigFilename + gui_settings.iSoftwareVersion + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion,gui_settings.bSupressI2CErrorData);

            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);

            //Define FC version dependant thingys :D
            if (gui_settings.iSoftwareVersion == 20)
            {
                PID_ROLL = 0; PID_PITCH = 1; PID_YAW = 2; PID_ALT = 3; PID_VEL = 4; PID_GPS = 5; PID_LEVEL = 6; PID_MAG = 7;
                iPacketSizeM = iPacketSizeM20;
                sRelName = sRelName20;
                splash.sFcVersionLabel = "MultiWii version " + sRelName20;
                if (gui_settings.bSupressI2CErrorData)
                {
                    l_i2cdatasupress.Text = "dev20120203 combatibity mode enabled";
                    iPacketSizeM = 153;     //This is hardcoded and eventually will be removed once MultiWii 2.0 is released
                    splash.sFcVersionLabel += Environment.NewLine + "20120203 compatibility mode";
                }
                splash.Refresh();


            }
            if (gui_settings.iSoftwareVersion == 19)
            {
                PID_ROLL = 0; PID_PITCH = 1; PID_YAW = 2; PID_ALT = 3; PID_VEL = 4; PID_LEVEL = 5; PID_MAG = 6;
                iPacketSizeM = iPacketSizeM19;
                sRelName = sRelName19;
                nPID_level_d.Visible = false;
                groupBoxGPS.Visible = false;
                splash.sFcVersionLabel = "MultiWii version " + sRelName19;
                splash.Refresh();

            }

            bSerialBuffer = new byte[iPacketSizeM];

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            rcOptions1 = new byte[iCheckBoxItems];
            rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;
            switch (gui_settings.iSoftwareVersion)
            {
                case 19:
                    rb_sw19.Checked = true;
                    break;
                case 20:
                    rb_sw20.Checked = true;
                    break;
                default:
                    rb_sw20.Checked = true;
                    break;
            }

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;


            //Build the RC control checkboxes structure

            aux = new CheckBoxEx[4, 4, iCheckBoxItems];

            int startx = 200;
            int starty = 60;

            int a, b, c;
            for (c = 0; c < 4; c++)
            {
                for (a = 0; a < 3; a++)
                {
                    for (b = 0; b < iCheckBoxItems; b++)
                    {
                        aux[c, a, b] = new CheckBoxEx();
                        aux[c, a, b].Location = new Point(startx + a * 18 + c * 70, starty + b * 25);
                        aux[c, a, b].Visible = true;
                        aux[c, a, b].Text = "";
                        aux[c, a, b].AutoSize = true;
                        aux[c, a, b].Size = new Size(16, 16);
                        aux[c, a, b].UseVisualStyleBackColor = true;
                        aux[c, a, b].CheckedChanged += new System.EventHandler(this.aux_checked_changed_event);
                        //Set info on the given checkbox position
                        aux[c, a, b].aux = c;           //Which aux channel
                        aux[c, a, b].rclevel = a;       //which rc level
                        aux[c, a, b].item = b;          //Which item
                        this.tabPageRC.Controls.Add(aux[c, a, b]);

                    }
                }
            }

            aux_labels = new System.Windows.Forms.Label[4];
            lmh_labels = new System.Windows.Forms.Label[4, 3];          // aux1-4, L,M,H
            string strlmh = "LMH";
            for (a = 0; a < 4; a++)
            {
                aux_labels[a] = new System.Windows.Forms.Label();
                aux_labels[a].Text = "AUX" + String.Format("{0:0}", a + 1);
                aux_labels[a].Location = new Point(startx + a * 70 + 8, starty - 35);
                aux_labels[a].AutoSize = true;
                aux_labels[a].ForeColor = Color.White;
                this.tabPageRC.Controls.Add(aux_labels[a]);
                for (b = 0; b < 3; b++)
                {
                    lmh_labels[a, b] = new System.Windows.Forms.Label();
                    lmh_labels[a, b].Text = strlmh.Substring(b, 1); ;
                    lmh_labels[a, b].Location = new Point(startx + a * 70 + b * 18, starty - 20);
                    lmh_labels[a, b].AutoSize = true;
                    lmh_labels[a, b].ForeColor = Color.White;
                    this.tabPageRC.Controls.Add(lmh_labels[a, b]);
                }

            }

            cb_labels = new System.Windows.Forms.Label[20];

            for (z = 0; z < iCheckBoxItems; z++)
            {
                cb_labels[z] = new System.Windows.Forms.Label();
                cb_labels[z].Text = option_names[z];
                cb_labels[z].Location = new Point(10, starty + z * 25);
                cb_labels[z].Visible = true;
                cb_labels[z].AutoSize = true;
                cb_labels[z].ForeColor = Color.White;
                cb_labels[z].TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(cb_labels[z], option_desc[z]);
                this.tabPageRC.Controls.Add(cb_labels[z]);
            }


            if (gui_settings.iSoftwareVersion == 19)
            {
                //Hide AUX3-AUX4 settings
                aux_labels[2].Visible = false;
                aux_labels[3].Visible = false;
                lmh_labels[2, 0].Visible = false;
                lmh_labels[2, 1].Visible = false;
                lmh_labels[2, 2].Visible = false;
                lmh_labels[3, 0].Visible = false;
                lmh_labels[3, 1].Visible = false;
                lmh_labels[3, 2].Visible = false;

                for (int i = 0; i < iCheckBoxItems; i++)
                {
                    aux[2, 0, i].Visible = false;
                    aux[2, 1, i].Visible = false;
                    aux[2, 2, i].Visible = false;
                    aux[3, 0, i].Visible = false;
                    aux[3, 1, i].Visible = false;
                    aux[3, 2, i].Visible = false;
                }
            }

            this.Refresh();

            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;

            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 0;              //20Hz is the default

            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();

            timer_rc.Tick += new EventHandler(timer_rc_Tick);
            timer_rc.Interval = 100; //(10Hz)
            timer_rc.Enabled = true;
            timer_rc.Stop();


            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -150;
            myPane.YAxis.Scale.Max = 150;

            myPane.Chart.Fill = new Fill(Color.DimGray, Color.DarkGray, 45.0f);
            myPane.Fill = new Fill(Color.DimGray, Color.DimGray, 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }


            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;
            
            
            
            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();

            pictureBox2.BorderStyle = BorderStyle.None;

            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            System.Threading.Thread.Sleep(2000);
            splash.Close();



        } //End of mainGUI_load
Ejemplo n.º 3
0
        private void mainGUI_Load(object sender, EventArgs e)
        {
            //First step, check it gui_settings file is exists or not, if not then start settings wizard
            if (!File.Exists(sGuiSettingsFilename))
            {
                setup_wizard panelSetupWizard = new setup_wizard();
                panelSetupWizard.ShowDialog();

            }

            //Now there must be a valid settings file, so we can continue with normal execution

            splash_screen splash = new splash_screen();
            splash.sVersionLabel = sVersion;
            splash.Show();
            splash.Refresh();
            //Start with Settings file read, and parse exit if unsuccessfull
            gui_settings = new GUI_settings();
            if (!gui_settings.read_from_xml(sGuiSettingsFilename))
            {
                Environment.Exit(-1);
            }

            sOptionsConfigFilename = sOptionsConfigFilename + gui_settings.iSoftwareVersion + ".xml";
            read_options_config();                  //read and parse optionsconfig.xml file. sets iCheckBoxItems

            mw_gui = new mw_data_gui(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);
            mw_params = new mw_settings(iPidItems, iCheckBoxItems, gui_settings.iSoftwareVersion);

            splash.sFcVersionLabel = "MultiWii version " + sRelName;
            splash.sStatus = "Connecting to MAP server...";
            splash.Refresh();

            //Quick hack to get pid names to mw_params untill redo the structures
            for (int i = 0; i < iPidItems; i++)
            {
                mw_params.pidnames[i] = Pid[i].name;
            }

            cbMapProviders.SelectedIndex = gui_settings.iMapProviderSelectedIndex;
            MainMap.MapProvider = mapProviders[gui_settings.iMapProviderSelectedIndex];
            tb_mapzoom.Value = MainMap.MaxZoom;
            MainMap.Zoom = MainMap.MaxZoom;

            splash.sStatus = "Building up GUI elements...";
            splash.Refresh();

            bSerialBuffer = new byte[65];
            inBuf = new byte[300];   //init input buffer

            ToolTip toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //rcOptions1 = new byte[iCheckBoxItems];
            //rcOptions2 = new byte[iCheckBoxItems];

            //Fill out settings tab
            l_Capture_folder.Text = gui_settings.sCaptureFolder;
            l_LogFolder.Text = gui_settings.sLogFolder;
            l_Settings_folder.Text = gui_settings.sSettingsFolder;

            cb_Logging_enabled.Checked = gui_settings.bEnableLogging;

            //Set log enties checkboxes
            cb_Log1.Checked = gui_settings.logGraw;
            cb_Log2.Checked = gui_settings.logGatt;
            cb_Log3.Checked = gui_settings.logGmag;
            cb_Log4.Checked = gui_settings.logGrcc;
            cb_Log5.Checked = gui_settings.logGrcx;
            cb_Log6.Checked = gui_settings.logGmot;
            cb_Log7.Checked = gui_settings.logGsrv;
            cb_Log8.Checked = gui_settings.logGnav;
            cb_Log9.Checked = gui_settings.logGpar;
            cb_Log10.Checked = gui_settings.logGdbg;

            //Build PID control structure based on the Pid structure.

            const int iLineSpace = 36;
            const int iRow1 = 30;
            const int iRow2 = 125;
            const int iRow3 = 220;
            const int iTopY = 25;
            Font fontField = new Font("Tahoma", 9, FontStyle.Bold);
            Size fieldSize = new Size(70, 25);

            for (int i = 0; i < iPidItems; i++)
            {
                Pid[i].pidLabel = new System.Windows.Forms.Label();
                Pid[i].pidLabel.Text = Pid[i].name;
                Pid[i].pidLabel.Location = new Point(iRow1, 10 + i * iLineSpace);
                Pid[i].pidLabel.Visible = true;
                Pid[i].pidLabel.AutoSize = true;
                Pid[i].pidLabel.ForeColor = Color.White;
                Pid[i].pidLabel.TextAlign = ContentAlignment.MiddleRight;
                toolTip1.SetToolTip(Pid[i].pidLabel, Pid[i].description);
                this.tabPagePID.Controls.Add(Pid[i].pidLabel);

                if (Pid[i].Pshown)
                {
                    Pid[i].Pfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Pfield.ValueChanged += new EventHandler(pfield_valuechange);
                    Pid[i].Pfield.Location = new Point(iRow1, iTopY + i * iLineSpace);
                    Pid[i].Pfield.Size = fieldSize;
                    Pid[i].Pfield.Font = fontField;
                    Pid[i].Pfield.BorderStyle = BorderStyle.None;
                    Pid[i].Pfield.Maximum = Pid[i].Pmax;
                    Pid[i].Pfield.Minimum = Pid[i].Pmin;
                    Pid[i].Pfield.DecimalPlaces = decimals(Pid[i].Pprec);
                    Pid[i].Pfield.Increment = 1 / (decimal)Pid[i].Pprec;
                    this.tabPagePID.Controls.Add(Pid[i].Pfield);

                    Pid[i].Plabel = new System.Windows.Forms.Label();
                    Pid[i].Plabel.Text = "P";
                    Pid[i].Plabel.Font = fontField;
                    Pid[i].Plabel.ForeColor = Color.White;
                    Pid[i].Plabel.Location = new Point(iRow1 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Plabel);

                }
                if (Pid[i].Ishown)
                {
                    Pid[i].Ifield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Ifield.ValueChanged += new EventHandler(ifield_valuechange);
                    Pid[i].Ifield.Location = new Point(iRow2, iTopY + i * iLineSpace);
                    Pid[i].Ifield.Size = fieldSize;
                    Pid[i].Ifield.Font = fontField;
                    Pid[i].Ifield.BorderStyle = BorderStyle.None;
                    Pid[i].Ifield.Maximum = Pid[i].Imax;
                    Pid[i].Ifield.Minimum = Pid[i].Imin;
                    Pid[i].Ifield.DecimalPlaces = decimals(Pid[i].Iprec);
                    Pid[i].Ifield.Increment = 1 / (decimal)Pid[i].Iprec;
                    this.tabPagePID.Controls.Add(Pid[i].Ifield);

                    Pid[i].Ilabel = new System.Windows.Forms.Label();
                    Pid[i].Ilabel.Text = "I";
                    Pid[i].Ilabel.Font = fontField;
                    Pid[i].Ilabel.ForeColor = Color.White;
                    Pid[i].Ilabel.Location = new Point(iRow2 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Ilabel);

                }
                if (Pid[i].Dshown)
                {
                    Pid[i].Dfield = new System.Windows.Forms.NumericUpDown();
                    Pid[i].Dfield.ValueChanged += new EventHandler(dfield_valuechange);
                    Pid[i].Dfield.Location = new Point(iRow3, iTopY + i * iLineSpace);
                    Pid[i].Dfield.Size = fieldSize;
                    Pid[i].Dfield.Font = fontField;
                    Pid[i].Dfield.BorderStyle = BorderStyle.None;
                    Pid[i].Dfield.Maximum = Pid[i].Dmax;
                    Pid[i].Dfield.Minimum = Pid[i].Dmin;
                    Pid[i].Dfield.DecimalPlaces = decimals(Pid[i].Dprec);
                    Pid[i].Dfield.Increment = 1 / (decimal)Pid[i].Dprec;
                    this.tabPagePID.Controls.Add(Pid[i].Dfield);

                    Pid[i].Dlabel = new System.Windows.Forms.Label();
                    Pid[i].Dlabel.Text = "D";
                    Pid[i].Dlabel.Font = fontField;
                    Pid[i].Dlabel.ForeColor = Color.White;
                    Pid[i].Dlabel.Location = new Point(iRow3 - 20, iTopY + i * iLineSpace);
                    this.tabPagePID.Controls.Add(Pid[i].Dlabel);

                }

            }

            toolTip1.SetToolTip(b_check_all_ACC, "Select all ACC values");
            toolTip1.SetToolTip(b_uncheck_all_ACC, "Deselect all ACC values");

            this.Refresh();

            serial_ports_enumerate();
            foreach (string speed in sSerialSpeeds)
            {
                cb_serial_speed.Items.Add(speed);
            }
            cb_serial_speed.SelectedItem = gui_settings.sPreferedSerialSpeed;

            if (cb_serial_port.Items.Count == 0)
            {
                b_connect.Enabled = false;          //Nos serial port, disable connect
            }

            //Init serial port object
            serialPort = new SerialPort();
            //Set up serial port parameters (at least the ones what we know upfront
            serialPort.DataBits = 8;
            serialPort.Parity = Parity.None;
            serialPort.StopBits = StopBits.One;
            serialPort.Handshake = Handshake.None;
            serialPort.DtrEnable = false;               //??

            serialPort.ReadBufferSize = 4096;            //4K byte of read buffer
            serialPort.ReadTimeout = 500;               // 500msec timeout;

            //Init Realtime Monitor panel controls
            foreach (string rate in sRefreshSpeeds)
            {
                cb_monitor_rate.Items.Add(rate);
            }
            cb_monitor_rate.SelectedIndex = 0;              //20Hz is the default

            //Setup timers
            timer_realtime.Tick += new EventHandler(timer_realtime_Tick);
            timer_realtime.Interval = iRefreshIntervals[cb_monitor_rate.SelectedIndex];
            timer_realtime.Enabled = true;
            timer_realtime.Stop();

            //Set up zgMonitor control for real time monitoring
            GraphPane myPane = zgMonitor.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";

            //Set up pointlists and curves
            list_acc_roll = new RollingPointPairList(300);
            curve_acc_roll = myPane.AddCurve("acc_roll", list_acc_roll, Color.Red, SymbolType.None);

            list_acc_pitch = new RollingPointPairList(300);
            curve_acc_pitch = myPane.AddCurve("acc_pitch", list_acc_pitch, Color.Green, SymbolType.None);

            list_acc_z = new RollingPointPairList(300);
            curve_acc_z = myPane.AddCurve("acc_z", list_acc_z, Color.Blue, SymbolType.None);

            list_gyro_roll = new RollingPointPairList(300);
            curve_gyro_roll = myPane.AddCurve("gyro_roll", list_gyro_roll, Color.Khaki, SymbolType.None);

            list_gyro_pitch = new RollingPointPairList(300);
            curve_gyro_pitch = myPane.AddCurve("gyro_pitch", list_gyro_pitch, Color.Cyan, SymbolType.None);

            list_gyro_yaw = new RollingPointPairList(300);
            curve_gyro_yaw = myPane.AddCurve("gyro_yaw", list_gyro_yaw, Color.Magenta, SymbolType.None);

            list_mag_roll = new RollingPointPairList(300);
            curve_mag_roll = myPane.AddCurve("mag_roll", list_mag_roll, Color.CadetBlue, SymbolType.None);

            list_mag_pitch = new RollingPointPairList(300);
            curve_mag_pitch = myPane.AddCurve("mag_pitch", list_mag_pitch, Color.MediumPurple, SymbolType.None);

            list_mag_yaw = new RollingPointPairList(300);
            curve_mag_yaw = myPane.AddCurve("mag_yaw", list_mag_yaw, Color.DarkGoldenrod, SymbolType.None);

            list_alt = new RollingPointPairList(300);
            curve_alt = myPane.AddCurve("alt", list_alt, Color.White, SymbolType.None);

            list_head = new RollingPointPairList(300);
            curve_head = myPane.AddCurve("head", list_head, Color.Orange, SymbolType.None);

            list_dbg1 = new RollingPointPairList(300);
            curve_dbg1 = myPane.AddCurve("dbg1", list_dbg1, Color.PaleTurquoise, SymbolType.None);

            list_dbg2 = new RollingPointPairList(300);
            curve_dbg2 = myPane.AddCurve("dbg2", list_dbg2, Color.PaleTurquoise, SymbolType.None);

            list_dbg3 = new RollingPointPairList(300);
            curve_dbg3 = myPane.AddCurve("dbg3", list_dbg3, Color.PaleTurquoise, SymbolType.None);

            list_dbg4 = new RollingPointPairList(300);
            curve_dbg4 = myPane.AddCurve("dbg4", list_dbg4, Color.PaleTurquoise, SymbolType.None);

            // Show the x axis grid
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            myPane.XAxis.Scale.IsVisible = false;

            // Make the Y axis scale red
            myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane.YAxis.MajorGrid.IsZeroLine = true;
            // Align the Y axis labels so they are flush to the axis
            myPane.YAxis.Scale.Align = AlignP.Inside;
            myPane.YAxis.Scale.IsVisible = false;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -150;
            myPane.YAxis.Scale.Max = 150;

            myPane.Chart.Fill = new Fill(Color.DimGray, Color.DarkGray, 45.0f);
            myPane.Fill = new Fill(Color.DimGray, Color.DimGray, 45.0f);
            myPane.Legend.IsVisible = false;
            myPane.XAxis.Scale.IsVisible = false;
            myPane.YAxis.Scale.IsVisible = true;

            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = false;

            zgMonitor.IsEnableHPan = true;
            zgMonitor.IsEnableHZoom = true;

            foreach (ZedGraph.LineItem li in myPane.CurveList)
            {
                li.Line.Width = 1;
            }

            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;

            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 300;
            myPane.XAxis.Type = AxisType.Linear;

            zgMonitor.ScrollGrace = 0;
            xScale = zgMonitor.GraphPane.XAxis.Scale;
            zgMonitor.AxisChange();

            //Init video capture dev
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    dropdown_devices.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                dropdown_devices.Items.Add("No local capture devices");
                dropdown_devices.Enabled = false;
                b_video_connect.Enabled = false;
            }

            dropdown_devices.SelectedIndex = 0;
            cb_codec.SelectedIndex = 0;

            //Drawing stuff for OSD
            drawPen = new Pen(Color.White, 1);
            drawFont = new System.Drawing.Font(FontFamily.GenericMonospace, 16.0F);
            drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);

            //Disable buttons that are not working till connected
            b_reset.Enabled = false;
            b_cal_acc.Enabled = false;
            b_cal_mag.Enabled = false;
            b_read_settings.Enabled = false;
            b_write_settings.Enabled = false;

            //System.Threading.Thread.Sleep(2000);
            splash.Close();
        }