diff --git a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs index d768645b78..5db7724fd1 100644 --- a/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs +++ b/Tools/ArdupilotMegaPlanner/Antenna/Tracker.cs @@ -8,6 +8,7 @@ using System.Text; using System.Windows.Forms; using ArdupilotMega.Controls.BackstageView; using ArdupilotMega.Comms; +using ArdupilotMega.Utilities; namespace ArdupilotMega.Antenna { diff --git a/Tools/ArdupilotMegaPlanner/ArduCopterConfig.xml b/Tools/ArdupilotMegaPlanner/ArduCopterConfig.xml index e90fae40cf..2558e46e2c 100644 --- a/Tools/ArdupilotMegaPlanner/ArduCopterConfig.xml +++ b/Tools/ArdupilotMegaPlanner/ArduCopterConfig.xml @@ -56,14 +56,14 @@ When the sticks are fully deflected: Dampen STAB_D - 0.001 + 0 5 0.001 Dynamic STAB_D_S - 0.001 + 0 1 0.001 @@ -201,5 +201,87 @@ A distance error of 100cm * P of .25 = 25 cm/s 0.1 + WP Speed: + + How fast the copter should move towards the target. A larger value means a faster return to center, but can cause the copter to oscillate around the target. + + in m/s + + + + Speed + WP_SPEED_MAX + 1 + 30 + 1 + + + + + + Altitude Hold: + Altitude Error: + + How fast the copter should go to reach the correct altitude. + + + + P + THR_ALT_P + 0.001 + 5 + 0.001 + + + I + THR_ALT_I + 0 + 5 + 0.001 + + + IMAX + THR_ALT_IMAX + 0 + 50 + 0.1 + + + Thrust Rate: + + How much thrust to give us the desired rate. + + This will change depending on the weight and thrust of your copter. + + + + P + THR_RATE_P + 0.001 + 5 + 0.001 + + + I + THR_RATE_I + 0 + 5 + 0.001 + + + D + THR_RATE_D + 0 + 5 + 0.001 + + + IMAX + THR_RATE_IMAX + 0 + 50 + 0.1 + + diff --git a/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs b/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs index 19c8bdea71..b5a62da0d9 100644 --- a/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs +++ b/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs @@ -6,6 +6,7 @@ using System.Threading; using log4net; using System.Globalization; using ArdupilotMega.Comms; +using ArdupilotMega.Utilities; namespace ArdupilotMega.Arduino { diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index 1e1da84698..def4fc453c 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -226,7 +226,7 @@ - + UserControl @@ -249,7 +249,7 @@ ConnectionControl.cs - Form + UserControl ConfigPanel.cs @@ -321,12 +321,6 @@ ConfigTradHeli.cs - - Form - - - Configuration.cs - UserControl @@ -340,7 +334,7 @@ ConfigAccelerometerCalibrationPlane.cs - Form + UserControl Setup.cs @@ -358,14 +352,14 @@ UserControl - + Form Camera.cs - + Component @@ -408,7 +402,7 @@ - + Form @@ -535,7 +529,7 @@ SerialOutput.cs - + Form @@ -543,7 +537,7 @@ Splash.cs - + Form @@ -551,8 +545,8 @@ temp.cs - - + + @@ -684,7 +678,6 @@ ConfigRadioInput.cs - Designer ConfigRadioInput.cs @@ -709,7 +702,6 @@ ConfigTradHeli.cs - Designer ConfigTradHeli.cs @@ -717,9 +709,6 @@ ConfigTradHeli.cs - - Configuration.cs - ConfigAccelerometerCalibrationPlane.cs @@ -1084,9 +1073,7 @@ Always - - Designer - + Always diff --git a/Tools/ArdupilotMegaPlanner/Common.cs b/Tools/ArdupilotMegaPlanner/Common.cs index 30b5395688..a6e13ee17d 100644 --- a/Tools/ArdupilotMegaPlanner/Common.cs +++ b/Tools/ArdupilotMegaPlanner/Common.cs @@ -125,6 +125,8 @@ namespace ArdupilotMega Matrix temp = g.Transform; g.TranslateTransform(LocalPosition.X, LocalPosition.Y); + g.RotateTransform(-MainMap.Bearing); + int length = 500; // anti NaN try @@ -445,7 +447,7 @@ namespace ArdupilotMega // altitude controller CH6_THR_HOLD_KP = 14, CH6_Z_GAIN = 15, - //CH6_DAMP = 16, + CH6_DAMP = 16, // optical flow controller CH6_OPTFLOW_KP = 17, @@ -511,7 +513,7 @@ namespace ArdupilotMega { if (Common.getModes() == typeof(Common.apmmodes)) { - switch ((int)Enum.Parse(Common.getModes(), modein)) + switch (EnumTranslator.GetValue(modein)) { case (int)Common.apmmodes.MANUAL: case (int)Common.apmmodes.CIRCLE: @@ -525,13 +527,13 @@ namespace ArdupilotMega mode.custom_mode = (uint)(int)Enum.Parse(Common.getModes(), modein); break; default: - MessageBox.Show("No Mode Changed " + (int)Enum.Parse(Common.getModes(), modein)); + MessageBox.Show("No Mode Changed " + modein); return false; } } else if (Common.getModes() == typeof(Common.ac2modes)) { - switch ((int)Enum.Parse(Common.getModes(), modein)) + switch (EnumTranslator.GetValue(modein)) { case (int)Common.ac2modes.STABILIZE: case (int)Common.ac2modes.AUTO: @@ -545,7 +547,7 @@ namespace ArdupilotMega mode.custom_mode = (uint)(int)Enum.Parse(Common.getModes(), modein); break; default: - MessageBox.Show("No Mode Changed " + (int)Enum.Parse(Common.getModes(), modein)); + MessageBox.Show("No Mode Changed " + modein); return false; } } @@ -555,7 +557,7 @@ namespace ArdupilotMega return true; } - #else +#else public static bool translateMode(string modein, ref MAVLink.mavlink_set_nav_mode_t navmode, ref MAVLink.mavlink_set_mode_t mode) { @@ -570,7 +572,7 @@ namespace ArdupilotMega { if (Common.getModes() == typeof(Common.apmmodes)) { - switch ((int)Enum.Parse(Common.getModes(), modein)) + switch (EnumTranslator.GetValue(modein)) { case (int)Common.apmmodes.MANUAL: mode.mode = (byte)MAVLink.MAV_MODE.MAV_MODE_MANUAL; @@ -604,13 +606,13 @@ namespace ArdupilotMega mode.mode = (byte)MAVLink.MAV_MODE.MAV_MODE_TEST2; break; default: - CustomMessageBox.Show("No Mode Changed " + (int)Enum.Parse(Common.getModes(), modein)); + CustomMessageBox.Show("No Mode Changed " + modein); return false; } } else if (Common.getModes() == typeof(Common.ac2modes)) { - switch ((int)Enum.Parse(Common.getModes(), modein)) + switch (EnumTranslator.GetValue(modein)) { case (int)Common.ac2modes.GUIDED: mode.mode = (byte)MAVLink.MAV_MODE.MAV_MODE_GUIDED; @@ -632,7 +634,7 @@ namespace ArdupilotMega mode.mode = (byte)MAVLink.MAV_MODE.MAV_MODE_AUTO; break; default: - CustomMessageBox.Show("No Mode Changed " + (int)Enum.Parse(Common.getModes(), modein)); + CustomMessageBox.Show("No Mode Changed " + modein); return false; } } @@ -697,7 +699,7 @@ namespace ArdupilotMega } catch (Exception ex) { log.Info("getFilefromNet(): " + ex.ToString()); return false; } } - + public static Type getModes() { if (MainV2.cs.firmware == MainV2.Firmwares.ArduPlane) diff --git a/Tools/ArdupilotMegaPlanner/Comms/CommsUdpSerial.cs b/Tools/ArdupilotMegaPlanner/Comms/CommsUdpSerial.cs index d569cad89f..8aa8bd72c1 100644 --- a/Tools/ArdupilotMegaPlanner/Comms/CommsUdpSerial.cs +++ b/Tools/ArdupilotMegaPlanner/Comms/CommsUdpSerial.cs @@ -91,7 +91,7 @@ namespace ArdupilotMega.Comms frmProgressReporter.UpdateProgressAndStatus(-1, "Connecting Mavlink UDP"); - ArdupilotMega.ThemeManager.ApplyThemeTo(frmProgressReporter); + ArdupilotMega.Utilities.ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); diff --git a/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs b/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs index 26ab3db6c2..539183f9bb 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/ConfigPanel.cs @@ -8,10 +8,12 @@ using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml; +using ArdupilotMega.Controls.BackstageView; +using ArdupilotMega.Utilities; namespace ArdupilotMega.Controls { - public partial class ConfigPanel : Form + public partial class ConfigPanel : BackStageViewContentPanel { /// /// store tempory pending changes diff --git a/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs b/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs index 2326987b33..de5e9592a5 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/CustomMessageBox.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; //using ArdupilotMega.Controls; using System.Text; using ArdupilotMega; +using ArdupilotMega.Utilities; namespace System.Windows.Forms { diff --git a/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs index 58260f138b..5903f7d2d8 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/MyUserControl.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Forms; namespace System.Windows.Forms { @@ -10,6 +11,19 @@ namespace System.Windows.Forms /// public class MyUserControl : System.Windows.Forms.UserControl { + public event FormClosingEventHandler FormClosing; + + public void Close(object sender, FormClosingEventArgs e) + { + if (FormClosing != null) + FormClosing(sender,e); + } + + public void Close() + { + Close(this, new FormClosingEventArgs(CloseReason.UserClosing, false)); + } + protected override void WndProc(ref Message m) { try diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs index 6d3ff562e1..261c001f3b 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Configuration.cs @@ -14,6 +14,8 @@ using System.Threading; using DirectShowLib; using System.Runtime.InteropServices; using ArdupilotMega.Controls; +using ArdupilotMega.Utilities; +using System.Linq; namespace ArdupilotMega.GCSViews { @@ -97,8 +99,13 @@ namespace ArdupilotMega.GCSViews readToolTips(); // ensure the fields are populated before setting them - CH7_OPT.DataSource = Enum.GetNames(typeof(Common.ac2ch7modes)); - TUNE.DataSource = Enum.GetNames(typeof(Common.ac2ch6modes)); + CH7_OPT.DataSource = EnumTranslator.Translate().ToList(); + CH7_OPT.DisplayMember = "Value"; + CH7_OPT.ValueMember = "Key"; + + TUNE.DataSource = EnumTranslator.Translate().ToList(); + TUNE.DisplayMember = "Value"; + TUNE.ValueMember = "Key"; // prefill all fields param = MainV2.comPort.param; @@ -726,11 +733,17 @@ namespace ArdupilotMega.GCSViews if (ConfigTabs.SelectedTab == TabSetup) { - GCSViews.ConfigurationView.Setup temp = new GCSViews.ConfigurationView.Setup(); - - ThemeManager.ApplyThemeTo(temp); - - temp.ShowDialog(); + Form temp = new Form(); + MyUserControl configview = new GCSViews.ConfigurationView.Setup(); + temp.Controls.Add(configview); + ThemeManager.ApplyThemeTo(temp); + // fix title + temp.Text = configview.Name; + // fix size + temp.Size = configview.Size; + configview.Dock = DockStyle.Fill; + temp.FormClosing += configview.Close; + temp.ShowDialog(); startup = true; processToScreen(); @@ -999,7 +1012,6 @@ namespace ArdupilotMega.GCSViews } - private void CMB_rateattitude_SelectedIndexChanged(object sender, EventArgs e) { MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; @@ -1010,18 +1022,21 @@ namespace ArdupilotMega.GCSViews { MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.rateposition = byte.Parse(((ComboBox)sender).Text); + } private void CMB_ratestatus_SelectedIndexChanged(object sender, EventArgs e) { MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.ratestatus = byte.Parse(((ComboBox)sender).Text); + } private void CMB_raterc_SelectedIndexChanged(object sender, EventArgs e) { MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.raterc = byte.Parse(((ComboBox)sender).Text); + } private void CHK_mavdebug_CheckedChanged(object sender, EventArgs e) diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs index ec5d7ca2cf..2b823b0fe0 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.Designer.cs @@ -126,6 +126,7 @@ this.RATE_RLL_P = new System.Windows.Forms.NumericUpDown(); this.label91 = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.BUT_writePIDS = new ArdupilotMega.Controls.MyButton(); ((System.ComponentModel.ISupportInitialize)(this.TUNE_LOW)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.TUNE_HIGH)).BeginInit(); this.groupBox5.SuspendLayout(); @@ -785,10 +786,18 @@ resources.ApplyResources(this.label91, "label91"); this.label91.Name = "label91"; // + // BUT_writePIDS + // + resources.ApplyResources(this.BUT_writePIDS, "BUT_writePIDS"); + this.BUT_writePIDS.Name = "BUT_writePIDS"; + this.BUT_writePIDS.UseVisualStyleBackColor = true; + this.BUT_writePIDS.Click += new System.EventHandler(this.BUT_writePIDS_Click); + // // ConfigArducopter // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.BUT_writePIDS); this.Controls.Add(this.myLabel3); this.Controls.Add(this.TUNE_LOW); this.Controls.Add(this.TUNE_HIGH); @@ -964,5 +973,6 @@ private System.Windows.Forms.NumericUpDown RATE_RLL_P; private System.Windows.Forms.Label label91; private System.Windows.Forms.ToolTip toolTip1; + private Controls.MyButton BUT_writePIDS; } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs index ce263e44cc..caf0c3b6a9 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.cs @@ -63,8 +63,13 @@ namespace ArdupilotMega.GCSViews.ConfigurationView readToolTips(); // ensure the fields are populated before setting them - CH7_OPT.DataSource = Enum.GetNames(typeof(Common.ac2ch7modes)); - TUNE.DataSource = Enum.GetNames(typeof(Common.ac2ch6modes)); + CH7_OPT.DataSource = Utilities.EnumTranslator.Translate().ToList(); + CH7_OPT.DisplayMember = "Value"; + CH7_OPT.ValueMember = "Key"; + + TUNE.DataSource = Utilities.EnumTranslator.Translate().ToList(); + TUNE.DisplayMember = "Value"; + TUNE.ValueMember = "Key"; // prefill all fields processToScreen(); @@ -225,7 +230,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView ComboBox thisctl = ((ComboBox)ctl); - thisctl.SelectedIndex = (int)(float)MainV2.comPort.param[value]; + thisctl.SelectedValue = (int)(float)MainV2.comPort.param[value]; thisctl.Validated += new EventHandler(ComboBox_Validated); @@ -271,7 +276,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } else if (sender.GetType() == typeof(ComboBox)) { - value = ((ComboBox)sender).SelectedIndex; + value = (int)((ComboBox)sender).SelectedValue; changes[name] = value; } ((Control)sender).BackColor = Color.Green; @@ -344,6 +349,38 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } catch { } } + + private void BUT_writePIDS_Click(object sender, EventArgs e) + { + var temp = (Hashtable)changes.Clone(); + + foreach (string value in temp.Keys) + { + try + { + MainV2.comPort.setParam(value, (float)changes[value]); + + try + { + // set control as well + var textControls = this.Controls.Find(value, true); + if (textControls.Length > 0) + { + textControls[0].BackColor = Color.FromArgb(0x43, 0x44, 0x45); + } + } + catch + { + + } + + } + catch + { + CustomMessageBox.Show("Set " + value + " Failed"); + } + } + } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx index c404907f7d..79660de141 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArducopter.resx @@ -135,13 +135,13 @@ myLabel3 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null $this - 0 + 1 575, 305 @@ -162,7 +162,7 @@ $this - 1 + 2 665, 305 @@ -183,7 +183,7 @@ $this - 2 + 3 540, 277 @@ -201,13 +201,13 @@ myLabel2 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null $this - 3 + 4 CH6_NONE @@ -294,7 +294,7 @@ $this - 4 + 5 540, 329 @@ -312,13 +312,13 @@ myLabel1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null $this - 5 + 6 Do Nothing @@ -363,7 +363,7 @@ $this - 6 + 7 80, 60 @@ -580,7 +580,7 @@ $this - 7 + 8 True @@ -610,7 +610,7 @@ $this - 8 + 9 80, 60 @@ -874,7 +874,7 @@ $this - 9 + 10 80, 13 @@ -946,7 +946,7 @@ $this - 10 + 11 80, 63 @@ -1114,7 +1114,7 @@ $this - 11 + 12 80, 61 @@ -1282,7 +1282,7 @@ $this - 12 + 13 80, 63 @@ -1450,7 +1450,7 @@ $this - 13 + 14 80, 88 @@ -1666,7 +1666,7 @@ $this - 14 + 15 80, 63 @@ -1834,7 +1834,7 @@ $this - 15 + 16 80, 60 @@ -2050,7 +2050,7 @@ $this - 16 + 17 80, 60 @@ -2266,7 +2266,7 @@ $this - 17 + 18 80, 60 @@ -2482,11 +2482,41 @@ $this - 18 + 19 17, 17 + + Top, Right + + + NoControl + + + 305, 383 + + + 103, 19 + + + 70 + + + Write Params + + + BUT_writePIDS + + + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + True @@ -2509,6 +2539,6 @@ ConfigArducopter - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs index 90e96df593..9712d788f3 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.Designer.cs @@ -131,6 +131,7 @@ this.RLL2SRV_P = new System.Windows.Forms.NumericUpDown(); this.label52 = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.BUT_writePIDS = new ArdupilotMega.Controls.MyButton(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.THR_FS_VALUE)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.THR_MAX)).BeginInit(); @@ -789,10 +790,18 @@ resources.ApplyResources(this.label52, "label52"); this.label52.Name = "label52"; // + // BUT_writePIDS + // + resources.ApplyResources(this.BUT_writePIDS, "BUT_writePIDS"); + this.BUT_writePIDS.Name = "BUT_writePIDS"; + this.BUT_writePIDS.UseVisualStyleBackColor = true; + this.BUT_writePIDS.Click += new System.EventHandler(this.BUT_writePIDS_Click); + // // ConfigArduplane // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.BUT_writePIDS); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox2); @@ -970,5 +979,6 @@ private System.Windows.Forms.NumericUpDown RLL2SRV_P; private System.Windows.Forms.Label label52; private System.Windows.Forms.ToolTip toolTip1; + private Controls.MyButton BUT_writePIDS; } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs index 11bbb4fb8e..8b50355a3c 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.cs @@ -268,5 +268,37 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } } + private void BUT_writePIDS_Click(object sender, EventArgs e) + { + var temp = (Hashtable)changes.Clone(); + + foreach (string value in temp.Keys) + { + try + { + MainV2.comPort.setParam(value, (float)changes[value]); + + try + { + // set control as well + var textControls = this.Controls.Find(value, true); + if (textControls.Length > 0) + { + textControls[0].BackColor = Color.FromArgb(0x43, 0x44, 0x45); + } + } + catch + { + + } + + } + catch + { + CustomMessageBox.Show("Set " + value + " Failed"); + } + } + } + } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.resx index e78598b5a3..771898ca2c 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigArduplane.resx @@ -117,14 +117,134 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + THR_FS_VALUE + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 0 + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 1 + + + THR_MAX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 2 + + + label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 3 + + + THR_MIN + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 4 + + + label7 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 5 + + + TRIM_THROTTLE + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 6 + + + label8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox3 + + + 7 + + + 413, 231 + + + 195, 108 + + + + 12 + + + Throttle 0-100% + + + groupBox3 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + 111, 82 78, 20 - 11 @@ -312,29 +432,125 @@ 7 - - 413, 231 + + ARSPD_RATIO - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 0 + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 1 + + + ARSPD_FBW_MAX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 2 + + + label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 3 + + + ARSPD_FBW_MIN + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 4 + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 5 + + + TRIM_ARSPD_CM + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 6 + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 7 + + + 414, 339 + + 195, 108 - - 12 + + 13 - - Throttle 0-100% + + Airspeed m/s - - groupBox3 + + groupBox1 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 0 + + 2 111, 82 @@ -528,29 +744,101 @@ 7 - - 414, 339 + + LIM_PITCH_MIN - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + + + label39 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 1 + + + LIM_PITCH_MAX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 2 + + + label38 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 3 + + + LIM_ROLL_CD + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 4 + + + label37 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 5 + + + 213, 339 + + 195, 108 - - 13 + + 14 - - Airspeed m/s + + Navigation Angles - - groupBox1 + + groupBox2 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 1 + + 3 111, 59 @@ -696,29 +984,77 @@ 5 - - 213, 339 + + XTRK_ANGLE_CD - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox15 + + + 0 + + + label79 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox15 + + + 1 + + + XTRK_GAIN_SC + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox15 + + + 2 + + + label80 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox15 + + + 3 + + + 12, 339 + + 195, 108 - - 14 + + 15 - - Navigation Angles + + Xtrack Pids - - groupBox2 + + groupBox15 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 2 + + 4 111, 36 @@ -816,29 +1152,101 @@ 3 - - 12, 339 + + KFF_PTCH2THR - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 0 + + + label83 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 1 + + + KFF_RDDRMIX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 2 + + + label78 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 3 + + + KFF_PTCHCOMP + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 4 + + + label81 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox16 + + + 5 + + + 213, 231 + + 195, 108 - - 15 + + 16 - - Xtrack Pids + + Other Mix's - - groupBox15 + + groupBox16 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 3 + + 5 111, 13 @@ -984,29 +1392,125 @@ 5 - - 213, 231 + + ENRGY2THR_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 0 + + + label73 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 1 + + + ENRGY2THR_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 2 + + + label74 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 3 + + + ENRGY2THR_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 4 + + + label75 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 5 + + + ENRGY2THR_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 6 + + + label76 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox14 + + + 7 + + + 12, 231 + + 195, 108 - - 16 + + 17 - - Other Mix's + + Energy/Alt Pid - - groupBox16 + + groupBox14 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 4 + + 6 111, 82 @@ -1200,29 +1704,125 @@ 7 - - 12, 231 + + ALT2PTCH_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 0 + + + label69 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 1 + + + ALT2PTCH_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 2 + + + label70 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 3 + + + ALT2PTCH_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 4 + + + label71 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 5 + + + ALT2PTCH_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 6 + + + label72 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox13 + + + 7 + + + 414, 123 + + 195, 108 - - 17 + + 18 - - Energy/Alt Pid + + Nav Pitch Alt Pid - - groupBox14 + + groupBox13 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 5 + + 7 111, 82 @@ -1416,29 +2016,125 @@ 7 - - 414, 123 + + ARSP2PTCH_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 0 + + + label65 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 1 + + + ARSP2PTCH_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 2 + + + label66 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 3 + + + ARSP2PTCH_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 4 + + + label67 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 5 + + + ARSP2PTCH_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 6 + + + label68 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox12 + + + 7 + + + 213, 123 + + 195, 108 - - 18 + + 19 - - Nav Pitch Alt Pid + + Nav Pitch AS Pid - - groupBox13 + + groupBox12 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 6 + + 8 111, 82 @@ -1632,29 +2328,125 @@ 7 - - 213, 123 + + HDNG2RLL_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 0 + + + label61 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 1 + + + HDNG2RLL_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 2 + + + label62 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 3 + + + HDNG2RLL_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 4 + + + label63 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 5 + + + HDNG2RLL_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 6 + + + label64 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox11 + + + 7 + + + 12, 123 + + 195, 108 - - 19 + + 20 - - Nav Pitch AS Pid + + Nav Roll Pid - - groupBox12 + + groupBox11 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 7 + + 9 111, 82 @@ -1848,29 +2640,125 @@ 7 - - 12, 123 + + YW2SRV_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 0 + + + label57 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 1 + + + YW2SRV_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 2 + + + label58 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 3 + + + YW2SRV_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 4 + + + label59 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 5 + + + YW2SRV_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 6 + + + label60 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox10 + + + 7 + + + 414, 15 + + 195, 108 - - 20 + + 21 - - Nav Roll Pid + + Servo Yaw Pid - - groupBox11 + + groupBox10 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 8 + + 10 111, 82 @@ -2064,29 +2952,125 @@ 7 - - 414, 15 + + PTCH2SRV_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 0 + + + label53 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 1 + + + PTCH2SRV_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 2 + + + label54 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 3 + + + PTCH2SRV_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 4 + + + label55 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 5 + + + PTCH2SRV_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 6 + + + label56 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox9 + + + 7 + + + 213, 15 + + 195, 108 - - 21 + + 22 - - Servo Yaw Pid + + Servo Pitch Pid - - groupBox10 + + groupBox9 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 9 + + 11 111, 82 @@ -2280,29 +3264,125 @@ 7 - - 213, 15 + + RLL2SRV_IMAX - + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 0 + + + label49 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 1 + + + RLL2SRV_D + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 2 + + + label50 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 3 + + + RLL2SRV_I + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 4 + + + label51 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 5 + + + RLL2SRV_P + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 6 + + + label52 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox8 + + + 7 + + + 12, 15 + + 195, 108 - - 22 + + 23 - - Servo Pitch Pid + + Servo Roll Pid - - groupBox9 + + groupBox8 - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 10 + + 12 111, 82 @@ -2496,33 +3576,39 @@ 7 - - 12, 15 - - - 195, 108 - - - 23 - - - Servo Roll Pid - - - groupBox8 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 11 - 17, 17 + + Top, Right + + + NoControl + + + 261, 437 + + + 103, 19 + + + 70 + + + Write Params + + + BUT_writePIDS + + + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + True @@ -2542,6 +3628,6 @@ ConfigArduplane - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4498.24834, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs index b9795fb111..0cbdd791f8 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigHardwareOptions.cs @@ -25,12 +25,12 @@ namespace ArdupilotMega.GCSViews.ConfigurationView private void BUT_MagCalibration_Click(object sender, EventArgs e) { + // list of x,y,z 's List> data = new List>(); + // backup current rate and set to 10 hz byte backupratesens = MainV2.cs.ratesensors; - MainV2.cs.ratesensors = 10; - MainV2.comPort.requestDatastream((byte)MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.cs.ratesensors); // mag captures at 10 hz CustomMessageBox.Show("Data will be collected for 30 seconds, Please click ok and move the apm around all axises"); @@ -43,6 +43,7 @@ namespace ArdupilotMega.GCSViews.ConfigurationView while (deadline > DateTime.Now) { + // dont let the gui hang Application.DoEvents(); if (oldmx != MainV2.cs.mx && @@ -60,7 +61,9 @@ namespace ArdupilotMega.GCSViews.ConfigurationView } } + // restore old sensor rate MainV2.cs.ratesensors = backupratesens; + MainV2.comPort.requestDatastream((byte)MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.cs.ratesensors); if (data.Count < 10) { diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs index 2bd4051212..e40e406940 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs @@ -74,6 +74,8 @@ this.BUT_Joystick = new ArdupilotMega.Controls.MyButton(); this.BUT_videostop = new ArdupilotMega.Controls.MyButton(); this.BUT_videostart = new ArdupilotMega.Controls.MyButton(); + this.label1 = new System.Windows.Forms.Label(); + this.CHK_maprotation = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.NUM_tracklength)).BeginInit(); this.SuspendLayout(); // @@ -94,6 +96,7 @@ resources.GetString("CMB_ratesensors.Items4")}); resources.ApplyResources(this.CMB_ratesensors, "CMB_ratesensors"); this.CMB_ratesensors.Name = "CMB_ratesensors"; + this.CMB_ratesensors.SelectedIndexChanged += new System.EventHandler(this.CMB_ratesensors_SelectedIndexChanged); // // label26 // @@ -348,6 +351,7 @@ this.CMB_osdcolor.FormattingEnabled = true; resources.ApplyResources(this.CMB_osdcolor, "CMB_osdcolor"); this.CMB_osdcolor.Name = "CMB_osdcolor"; + this.CMB_osdcolor.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.CMB_osdcolor_DrawItem); this.CMB_osdcolor.SelectedIndexChanged += new System.EventHandler(this.CMB_osdcolor_SelectedIndexChanged); // // CMB_language @@ -377,7 +381,7 @@ resources.ApplyResources(this.CHK_hudshow, "CHK_hudshow"); this.CHK_hudshow.Name = "CHK_hudshow"; this.CHK_hudshow.UseVisualStyleBackColor = true; - this.CHK_hudshow.Click += new System.EventHandler(this.CHK_hudshow_CheckedChanged); + this.CHK_hudshow.CheckedChanged += new System.EventHandler(this.CHK_hudshow_CheckedChanged); // // label92 // @@ -391,6 +395,7 @@ resources.ApplyResources(this.CMB_videosources, "CMB_videosources"); this.CMB_videosources.Name = "CMB_videosources"; this.CMB_videosources.SelectedIndexChanged += new System.EventHandler(this.CMB_videosources_SelectedIndexChanged); + this.CMB_videosources.Click += new System.EventHandler(this.CMB_videosources_Click); // // BUT_Joystick // @@ -413,10 +418,24 @@ this.BUT_videostart.UseVisualStyleBackColor = true; this.BUT_videostart.Click += new System.EventHandler(this.BUT_videostart_Click); // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.Name = "label1"; + // + // CHK_maprotation + // + resources.ApplyResources(this.CHK_maprotation, "CHK_maprotation"); + this.CHK_maprotation.Name = "CHK_maprotation"; + this.CHK_maprotation.UseVisualStyleBackColor = true; + this.CHK_maprotation.CheckedChanged += new System.EventHandler(this.CHK_maprotation_CheckedChanged); + // // ConfigPlanner // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Controls.Add(this.CHK_maprotation); this.Controls.Add(this.label33); this.Controls.Add(this.CMB_ratesensors); this.Controls.Add(this.label26); @@ -463,6 +482,7 @@ this.Controls.Add(this.BUT_videostop); this.Controls.Add(this.BUT_videostart); this.Name = "ConfigPlanner"; + this.Load += new System.EventHandler(this.ConfigPlanner_Load); ((System.ComponentModel.ISupportInitialize)(this.NUM_tracklength)).EndInit(); this.ResumeLayout(false); @@ -515,5 +535,7 @@ private ArdupilotMega.Controls.MyButton BUT_Joystick; private ArdupilotMega.Controls.MyButton BUT_videostop; private ArdupilotMega.Controls.MyButton BUT_videostart; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox CHK_maprotation; } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs index 11e3e4a01e..1cb8bf6522 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.cs @@ -11,13 +11,15 @@ using System.Windows.Forms; using DirectShowLib; using ArdupilotMega.Controls.BackstageView; using ArdupilotMega.Controls; +using ArdupilotMega.Utilities; +using System.Threading; namespace ArdupilotMega.GCSViews.ConfigurationView { public partial class ConfigPlanner : BackStageViewContentPanel { - // AR todo: replicate this functionality private bool startup = false; + List languages = new List(); public ConfigPlanner() { @@ -291,32 +293,54 @@ namespace ArdupilotMega.GCSViews.ConfigurationView private void CMB_rateattitude_SelectedIndexChanged(object sender, EventArgs e) { + if (startup) + return; MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.rateattitude = byte.Parse(((ComboBox)sender).Text); + + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.EXTRA1, MainV2.cs.rateattitude); // request attitude + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.EXTRA2, MainV2.cs.rateattitude); // request vfr } private void CMB_rateposition_SelectedIndexChanged(object sender, EventArgs e) { + if (startup) + return; MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.rateposition = byte.Parse(((ComboBox)sender).Text); + + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.POSITION, MainV2.cs.rateposition); // request gps } private void CMB_ratestatus_SelectedIndexChanged(object sender, EventArgs e) { + if (startup) + return; MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.ratestatus = byte.Parse(((ComboBox)sender).Text); + + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.EXTENDED_STATUS, MainV2.cs.ratestatus); // mode } private void CMB_raterc_SelectedIndexChanged(object sender, EventArgs e) { + if (startup) + return; MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.raterc = byte.Parse(((ComboBox)sender).Text); + + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.RC_CHANNELS, MainV2.cs.raterc); // request rc info } private void CMB_ratesensors_SelectedIndexChanged(object sender, EventArgs e) { + if (startup) + return; MainV2.config[((ComboBox)sender).Name] = ((ComboBox)sender).Text; MainV2.cs.ratesensors = byte.Parse(((ComboBox)sender).Text); + + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.EXTRA3, MainV2.cs.ratesensors); // request extra stuff - tridge + MainV2.comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.cs.ratesensors); // request raw sensor } private void CHK_mavdebug_CheckedChanged(object sender, EventArgs e) @@ -371,5 +395,154 @@ namespace ArdupilotMega.GCSViews.ConfigurationView MainV2.config["CHK_GDIPlus"] = CHK_GDIPlus.Checked.ToString(); } + private void ConfigPlanner_Load(object sender, EventArgs e) + { + startup = true; + + // setup up camera button states + if (MainV2.cam != null) + { + BUT_videostart.Enabled = false; + CHK_hudshow.Checked = GCSViews.FlightData.myhud.hudon; + } + else + { + BUT_videostart.Enabled = true; + } + + // setup speech states + if (MainV2.config["speechenable"] != null) + CHK_enablespeech.Checked = bool.Parse(MainV2.config["speechenable"].ToString()); + if (MainV2.config["speechwaypointenabled"] != null) + CHK_speechwaypoint.Checked = bool.Parse(MainV2.config["speechwaypointenabled"].ToString()); + if (MainV2.config["speechmodeenabled"] != null) + CHK_speechmode.Checked = bool.Parse(MainV2.config["speechmodeenabled"].ToString()); + if (MainV2.config["speechcustomenabled"] != null) + CHK_speechcustom.Checked = bool.Parse(MainV2.config["speechcustomenabled"].ToString()); + if (MainV2.config["speechbatteryenabled"] != null) + CHK_speechbattery.Checked = bool.Parse(MainV2.config["speechbatteryenabled"].ToString()); + if (MainV2.config["speechaltenabled"] != null) + CHK_speechaltwarning.Checked = bool.Parse(MainV2.config["speechaltenabled"].ToString()); + + // this can't fail because it set at startup + NUM_tracklength.Value = int.Parse(MainV2.config["NUM_tracklength"].ToString()); + + // get wps on connect + if (MainV2.config["loadwpsonconnect"] != null) + CHK_loadwponconnect.Checked = bool.Parse(MainV2.config["loadwpsonconnect"].ToString()); + + // setup other config state + if (MainV2.config["CHK_resetapmonconnect"] != null) + CHK_resetapmonconnect.Checked = bool.Parse(MainV2.config["CHK_resetapmonconnect"].ToString()); + + CMB_rateattitude.Text = MainV2.cs.rateattitude.ToString(); + CMB_rateposition.Text = MainV2.cs.rateposition.ToString(); + CMB_raterc.Text = MainV2.cs.raterc.ToString(); + CMB_ratestatus.Text = MainV2.cs.ratestatus.ToString(); + CMB_ratesensors.Text = MainV2.cs.ratesensors.ToString(); + + + if (MainV2.config["CHK_GDIPlus"] != null) + CHK_GDIPlus.Checked = bool.Parse(MainV2.config["CHK_GDIPlus"].ToString()); + + if (MainV2.config["CHK_maprotation"] != null) + CHK_maprotation.Checked = bool.Parse(MainV2.config["CHK_maprotation"].ToString()); + + //set hud color state + string hudcolor = (string)MainV2.config["hudcolor"]; + + CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor)); + if (hudcolor != null) + { + int index = CMB_osdcolor.Items.IndexOf(hudcolor); + CMB_osdcolor.SelectedIndex = index; + } + else + { + int index = CMB_osdcolor.Items.IndexOf("White"); + CMB_osdcolor.SelectedIndex = index; + } + + // set distance/speed unit states + CMB_distunits.DataSource = Enum.GetNames(typeof(Common.distances)); + CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds)); + + if (MainV2.config["distunits"] != null) + CMB_distunits.Text = MainV2.config["distunits"].ToString(); + if (MainV2.config["speedunits"] != null) + CMB_speedunits.Text = MainV2.config["speedunits"].ToString(); + + // setup language selection + CultureInfo ci = null; + foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr", "Pl", "it-IT", "es-ES" }) + { + ci = CultureInfoEx.GetCultureInfo(name); + if (ci != null) + languages.Add(ci); + } + + CMB_language.DisplayMember = "DisplayName"; + CMB_language.DataSource = languages; + ci = Thread.CurrentThread.CurrentUICulture; + for (int i = 0; i < languages.Count; i++) + { + if (ci.IsChildOf(languages[i])) + { + CMB_language.SelectedIndex = i; + break; + } + } + CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged; + + startup = false; + } + + private void CMB_osdcolor_DrawItem(object sender, DrawItemEventArgs e) + { + if (e.Index < 0) + return; + + Graphics g = e.Graphics; + Rectangle rect = e.Bounds; + Brush brush = null; + + if ((e.State & DrawItemState.Selected) == 0) + brush = new SolidBrush(CMB_osdcolor.BackColor); + else + brush = SystemBrushes.Highlight; + + g.FillRectangle(brush, rect); + + brush = new SolidBrush(Color.FromName((string)CMB_osdcolor.Items[e.Index])); + + g.FillRectangle(brush, rect.X + 2, rect.Y + 2, 30, rect.Height - 4); + g.DrawRectangle(Pens.Black, rect.X + 2, rect.Y + 2, 30, rect.Height - 4); + + if ((e.State & DrawItemState.Selected) == 0) + brush = new SolidBrush(CMB_osdcolor.ForeColor); + else + brush = SystemBrushes.HighlightText; + g.DrawString(CMB_osdcolor.Items[e.Index].ToString(), + CMB_osdcolor.Font, brush, rect.X + 35, rect.Top + rect.Height - CMB_osdcolor.Font.Height); + } + + private void CMB_videosources_Click(object sender, EventArgs e) + { + // the reason why i dont populate this list is because on linux/mac this call will fail. + WebCamService.Capture capt = new WebCamService.Capture(); + + List devices = WebCamService.Capture.getDevices(); + + CMB_videosources.DataSource = devices; + + capt.Dispose(); + } + + private void CHK_maprotation_CheckedChanged(object sender, EventArgs e) + { + if (startup) + return; + MainV2.config["CHK_maprotation"] = CHK_maprotation.Checked.ToString(); + } } } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.resx index 8e15fbeacf..5ce06086d2 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigPlanner.resx @@ -145,7 +145,7 @@ $this - 0 + 2 0 @@ -181,7 +181,7 @@ $this - 1 + 3 NoControl @@ -208,7 +208,7 @@ $this - 2 + 4 124, 49 @@ -229,7 +229,7 @@ $this - 3 + 5 NoControl @@ -256,7 +256,7 @@ $this - 4 + 6 NoControl @@ -283,7 +283,7 @@ $this - 5 + 7 NoControl @@ -310,7 +310,7 @@ $this - 6 + 8 NoControl @@ -337,7 +337,7 @@ $this - 7 + 9 NoControl @@ -364,7 +364,7 @@ $this - 8 + 10 124, 293 @@ -385,7 +385,7 @@ $this - 9 + 11 NoControl @@ -412,7 +412,7 @@ $this - 10 + 12 NoControl @@ -439,7 +439,7 @@ $this - 11 + 13 NoControl @@ -466,7 +466,7 @@ $this - 12 + 14 Bottom, Left @@ -475,7 +475,7 @@ NoControl - 15, 378 + 15, 398 144, 17 @@ -496,7 +496,7 @@ $this - 13 + 15 NoControl @@ -523,7 +523,7 @@ $this - 14 + 16 0 @@ -556,7 +556,7 @@ $this - 15 + 17 NoControl @@ -583,7 +583,7 @@ $this - 16 + 18 NoControl @@ -610,7 +610,7 @@ $this - 17 + 19 NoControl @@ -637,7 +637,7 @@ $this - 18 + 20 NoControl @@ -664,7 +664,7 @@ $this - 19 + 21 0 @@ -697,7 +697,7 @@ $this - 20 + 22 0 @@ -730,7 +730,7 @@ $this - 21 + 23 0 @@ -763,7 +763,7 @@ $this - 22 + 24 NoControl @@ -791,7 +791,7 @@ $this - 23 + 25 NoControl @@ -818,7 +818,7 @@ $this - 24 + 26 NoControl @@ -845,7 +845,7 @@ $this - 25 + 27 124, 216 @@ -866,7 +866,7 @@ $this - 26 + 28 124, 189 @@ -887,7 +887,7 @@ $this - 27 + 29 NoControl @@ -914,7 +914,7 @@ $this - 28 + 30 NoControl @@ -941,7 +941,7 @@ $this - 29 + 31 NoControl @@ -968,7 +968,7 @@ $this - 30 + 32 NoControl @@ -995,7 +995,7 @@ $this - 31 + 33 NoControl @@ -1022,7 +1022,7 @@ $this - 32 + 34 NoControl @@ -1049,7 +1049,7 @@ $this - 33 + 35 NoControl @@ -1076,7 +1076,7 @@ $this - 34 + 36 124, 82 @@ -1097,7 +1097,7 @@ $this - 35 + 37 124, 133 @@ -1118,7 +1118,7 @@ $this - 36 + 38 NoControl @@ -1145,7 +1145,7 @@ $this - 37 + 39 NoControl @@ -1172,7 +1172,7 @@ $this - 38 + 40 NoControl @@ -1199,7 +1199,7 @@ $this - 39 + 41 NoControl @@ -1226,7 +1226,7 @@ $this - 40 + 42 124, 15 @@ -1247,7 +1247,7 @@ $this - 41 + 43 NoControl @@ -1268,13 +1268,13 @@ BUT_Joystick - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.31567, Culture=neutral, PublicKeyToken=null $this - 42 + 44 NoControl @@ -1295,13 +1295,13 @@ BUT_videostop - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.31567, Culture=neutral, PublicKeyToken=null $this - 43 + 45 NoControl @@ -1322,13 +1322,67 @@ BUT_videostart - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.31567, Culture=neutral, PublicKeyToken=null $this - 44 + 46 + + + NoControl + + + 15, 365 + + + 81, 17 + + + 89 + + + Map Follow + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + NoControl + + + 124, 365 + + + 205, 17 + + + 90 + + + Map is rotated to follow the plane + + + CHK_maprotation + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 True @@ -1337,12 +1391,12 @@ 6, 13 - 682, 398 + 682, 418 ConfigPlanner - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4491.33622, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4498.31567, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs index 2ee33bf48a..f763608069 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/ConfigRawParams.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Text; using System.Xml.Linq; using System.Windows.Forms; -using ArdupilotMega.Constants; using ArdupilotMega.Utilities; using log4net; using ArdupilotMega.Controls.BackstageView; @@ -22,7 +21,6 @@ namespace ArdupilotMega.GCSViews.ConfigurationView { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private readonly ParameterMetaDataRepository _parameterMetaDataRepository; // Changes made to the params between writing to the copter @@ -47,8 +45,6 @@ namespace ArdupilotMega.GCSViews.ConfigurationView public ConfigRawParams() { InitializeComponent(); - - // Init the accessor class for the parameter meta data _parameterMetaDataRepository = new ParameterMetaDataRepository(); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.Designer.cs deleted file mode 100644 index 9878d6c542..0000000000 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.Designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace ArdupilotMega.GCSViews.ConfigurationView -{ - partial class Configuration - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Configuration)); - this.backstageView = new ArdupilotMega.Controls.BackstageView.BackstageView(); - this.SuspendLayout(); - // - // backstageView - // - this.backstageView.AutoSize = true; - this.backstageView.Dock = System.Windows.Forms.DockStyle.Fill; - this.backstageView.Location = new System.Drawing.Point(0, 0); - this.backstageView.Name = "backstageView"; - this.backstageView.Size = new System.Drawing.Size(634, 336); - this.backstageView.TabIndex = 0; - // - // Configuration - // - this.ClientSize = new System.Drawing.Size(634, 336); - this.Controls.Add(this.backstageView); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "Configuration"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Configuration_FormClosing); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Controls.BackstageView.BackstageView backstageView; - } -} diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.cs deleted file mode 100644 index 60cc50f7b9..0000000000 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using ArdupilotMega.Controls.BackstageView; - -namespace ArdupilotMega.GCSViews.ConfigurationView -{ - public partial class Configuration : Form - { - public Configuration() - { - InitializeComponent(); - - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRadioInput(), "Radio Calibration")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigFlightModes(), "Flight Modes")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigHardwareOptions(), "Hardware Options")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigBatteryMonitoring(), "Battery Monitor")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationQuad(), "ArduCopter")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationPlane(), "ArduPlane")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigArducopter(), "Arducopter Setup")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigArduplane(), "Arduplane Setup")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigTradHeli(), "Heli Setup")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRawParams(), "Raw params (Advanced)")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigPlanner(), "Planner")); - } - - private void Configuration_FormClosing(object sender, FormClosingEventArgs e) - { - backstageView.Close(); - } - } -} diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.resx b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.resx deleted file mode 100644 index 222a74addf..0000000000 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Configuration.resx +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABILAAASCwAAAAAAAAAA - AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADOxkjAtnoOAKpJ4vyiK - c+8nh3D/J4Zv/yeHcP8oi3PvKpJ4vy6fg4AzsZIwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADjGo2AyspPfLZ+D/yiQ - d/8hlXj/G6F9/xeqg/8XqYL/GKqD/xuhfv8ilnn/KZB3/y2fhP8yspPfN8ajYAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADvRrDA1vpzfL6uN/yel - hP8XvJD/DMyY/wfQl/8FzJP/A8qS/wPJkf8EypL/BsyU/wnRmP8PzZn/Gb2R/yemhP8tqoz/Mb2a3zbQ - qkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAA4y6ZgMbWV/yin - iP8WwZP/Btqf/wDPlf8AyI7/A8aP/yfNnv9T2LP/UNax/03XsP8506b/G8ya/wHKkf8F0Zf/CNuf/xLB - kv8fpYT/J7KQ/y7IomAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAAAAAAAAAAAAAAAAAAANcajny+w - kf8hqoj/CNSd/wDRlf8Axor/Hcyd/3Lhwf+p7Nj/o+vV/57m0/+X5dD/k+TN/4/jzf+K5Mz/fuHH/0PW - rf8HzJT/ANCT/wDRlv8OpX//HayI/yrFn58AAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAADDC - nmAtro7/H62J/wPWmv8Ay47/AMaO/3XhxP+e6tT/mObP/5Pjy/+Q4sr/jODJ/4ffx/+C3MT/f9vC/3nb - wf9y2r7/adq7/2DauP8ZzZv/Fdae/8T/9/9WxKj/HKuI/y7IomAAAAAAAAAAAAAAAAD///8AAAAAAAAA - AAAiuZMwKKyM/x6ohf8C1Zr/AMmL/wHGjv+49OL///////////9+3ML/f9zD/4Dcwv9+28L/e9rA/3bZ - vv9w1rr/Z9S4/17Rs/9Qz63/Qcyn/3LewP////////////n///8MpH7/JbKP/zXQqUAAAAAAAAAAAP// - /wAAAAAAAAAAABymhN8dnn//BNGa/wDKjP8AxY3/sfHf/////////////////2nXt/9w1rv/c9e8/3TX - vP9x17z/a9W5/2TTtf9Y0K//SMyp/zXFoP9i07X/////////////////f/LR/wDQlf8epYT/Mb2a3wAA - AAAAAAAA////AAAAAAADlnJgFZR1/wq4iv8AzpH/AMCD/4rmzf//////////////////////WdGv/2PU - tf9p1rf/atS4/2nUtv9i0rT/Vc+u/0fKpv8zxZz/Ws+w//////////////////////8GyJL/ANCS/xLB - kv8tq4z/OMajYAAAAAD///8AAAAAAACHZt8NkW//ANKV/wDChP9i27r//////////////////////9Dx - 6P9MzKn/Vc+v/17Rsv9g0rP/XNCx/1XNrv9Fyaf/McSd/1fPr///////////////////////QM2m/ynK - oP8JzJX/C9yh/ymmhf80spPfAAAAAP///wAAcUwwAHtc/wCrfP8AyIv/AMKK//////////////////// - /////////////5Dgyv9Gyqb/TMyq/07Nq/9MzKn/Qcmj/y/Fnf9Wzq3//////////////////////57k - 0v8av5T/Lceg/yzOo/8M05v/Hr6T/zCghf80spIw////AABoRYAAclT/AL2H/wDBhf9R1rL///////// - ////////4vfw//////////////////H8+P9KzKn/Ocah/zTFnv8qwpj/Us2t//////////////////// - ////////DLqM/yDBlv8wxp//OM6m/xPPm/8Xz53/LZF5/y+fg4////8AAGNAvwB7Wf8Aw4j/ALyC/4bj - yP+g5tL/g93E/2HSsv9Pzqz/Us6s//////////////////////9Yzq//Gr2S/0jLp/////////////// - /////////////yrDm/8SvI//JMGY/zDHn/81zKT/Is2e/xTUnf8nl3v/LJJ5v////wAAXz3vAIlg/wDA - hf8AuoD/quzZ/5Hjyv9628D/ada2/1jRsP9Jy6f/a9a4//////////////////////+Y4s7///////// - //////////////////+c4tD/AbaH/xW8kf8jwZj/LcWd/y/Jn/8kzJ3/E9Ca/yGjgf8ri3Tv////AABd - PP8Ak2b/AL6D/w/Ekv+m6tf/j+HJ/3vawP9p1rf/W9Gx/0rNqf85yJ//Nsaf//////////////////// - /////////////////////////////wCwe/8AtoT/ELqP/xu+k/8jwZj/KMeb/yHKm/8QzZf/HqyG/ymI - cf////8AAF07/wCSZP8AvYL/GMWU/6Dn1P+K38f/ddi+/27Wuf+E3MX/leHN/6fm1f+l5tX/neLQ//// - ////////////////////////////////////////j9/J/27Vuv9Tzq7/JsKY/xa/kv8aw5T/FcaW/wvL - lf8aqoT/J4dw/////wAAXTv/AJFk/wC9gP8GwY3/mObQ/5rkz/+26dv/y/Hl/8Dt3/+06tz/pebV/5bg - zP+g5NL//////////////v///f7+//7+/v//////7fn2////////////tOnb/6Ll0v+v6Nj/jeDI/zXK - o/8IxJD/BMqS/xaqgv8lh2//////AABeO+8AgVf/AL1//wDBif/R9uv/1PPq/8Tv5P+36t3/rujY/6Lk - 0v+U4cv/jt7J//j8+///////+/38//f8+//2+/r/+Pz7//3+/v/m9/P/9Pv6//D6+P9/28L/jd7J/5jj - z/+h5dL/qOvX/4Hmyf8f1J//E596/yOJcO////8AAGA8vwB3U/8p06P/hufM/8Ty5f/D7+T/s+vb/6bm - 1P+c4c//j9/K/4vcyP/t+fb///7///j8/P/0+/r/8vr5//P7+f/1+/r/+/39///////i9fL/ZNO1/3HW - vP992sH/htzG/4vhyv+S5dD/mO7W/6X74v80noT/Io90v////wAAZkCAAHla/33ny/945cb/nunV/7Xr - 3v+l5tT/luDN/4ndxv992cL/1vLq//v9/P/1+/n/8vv4//L69//z+/j/9Pv5/7Xo2//x+vn///////// - //+y59n/aNS3/3LWvP932r//fNzD/4Ljyf+J7ND/l/bd/yORdf8knH6A////AABuRzAAdlT/Xc6x/23o - xv9s4MH/qurZ/5jiz/+I3cb/edjA/8ju5f/3/Pv/8vv4//H6+P/y+/j/6/f0/7np3v/7/fz//v7+/6fk - 1f+56tz///////////9h0bT/aNW4/23Wu/9v3L//dOLG/37w0f9m1rn/Hpt8/ymujTD///8AAAAAAACD - X98po4X/Z+7K/1vgvP+A4sf/jOHK/3rZwv+r59f/9Pv6/+/69//v+vf/8vr4/9fy6/9n0rf/VM6t/6Di - 0v/N7+f/adO4/1PMrf9t1Lr/i9zI/1/Rs/9h0rX/ZNe4/2bbvf9s5sb/ePfV/z2ylf8lrozfAAAAAP// - /wAAAAAAAJNsYAWQbf9U1rP/Vee//0rYsf993sb/pebV//P7+v/s+Pb/6/f1/+749v+s5tj/Vc2u/1jP - r/9ZzrD/btW5/1bOr/9Wza//Vs6v/1fOr/9Z0LD/WdCy/1vTtP9d1rX/Xt+8/2btyP9k4L//IaaF/y7D - nmAAAAAA////AAAAAAAAAAAAD6J9zyCjgv9S68L/P9+0/2Pevv/5////7/v6/+v59//j9/L/gtvF/1PN - r/9Wz7D/Wc+x/1nQsf9Zz7H/WM6w/1fPsP9UzrD/VM+w/1TPrv9U0a//U9Oy/1Tatv9Z5sD/Y/LL/zSx - lP8qupbPAAAAAAAAAAD///8AAAAAAAAAAAAYto4wGaeE/y23lP8+5rn/6/////j////w//3/ve/i/2bV - uP9Tzq7/Vc+v/1jPsP9Z0LL/WM+w/1fOsf9Wz7D/Us2w/1HOrf9Qzq3/T9Cu/0zSr/9M2LP/TeC5/1bt - xP9HxaX/KLKQ/zTPqDAAAAAAAAAAAP///wAAAAAAAAAAAAAAAAAkvpdgG6iF/y++m//e/////P///3rl - yf9G0K3/VdKy/1bPsf9Wz7H/Vs6w/1bPsP9Sza//Ucyu/0/Nrf9NzKz/S82s/0fOrP9G0a7/QdWv/0Le - tP9I6L7/Q8Ok/yitjP8yyKJgAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAmwJlgG6iF/yK3 - kP8k3q7/H9el/x7Pn/8tzKT/Q9Cs/1HQsP9Q0K7/TM6u/0nMrf9Hzaz/RMyp/0LNqf8+zqn/ONGo/zTV - qf833rD/O+S4/zvCof8orIv/MMSfYAAAAAAAAAAAAAAAAAAAAAD///8AAAAAAAAAAAAAAAAAAAAAAAAA - AAAkvpdgG6iE/xukgv8gy53/HNql/xzRn/8czJz/HcmZ/yXJnP8qyp7/Lcqg/yzLn/8nypz/JMqc/yTO - n/8l1KT/KN2r/y3Tpv8nq4n/JaqJ/yzAm2AAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAato8wFKN/zxCScv8RnHn/DbqM/wjIlP8GyZT/BsaS/wbFkf8GxZH/B8WR/wfH - k/8IypX/DMmV/xG3jP8WoX3/Fph2/xqkgs8ft5EwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJVvYACGZM8Aelr/AHlZ/wCFX/8AiWL/AJlr/wCb - bP8AlGf/AI5k/wB/W/8AeFj/AHtb/wCHZd8ClXBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwSzAAaESAAGI/vwBf - Pd8AXTz/AF08/wBdPP8AXz3fAGJAvwBoRIAAcUswAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// - /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// - /wD///8A////AP///wD///8A/+AD//+AAP/+AAA//AAAH/gAAA/wAAAH4AAAA+AAAAPAAAABwAAAAYAA - AACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAwAAAAcAAAAHgAAAD4AAAA/AA - AAf4AAAP/AAAH/4AAD//gAD//+AD//////8= - - - \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.Designer.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.Designer.cs index 79ba73a8cd..889a316981 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.Designer.cs @@ -45,7 +45,7 @@ // this.ClientSize = new System.Drawing.Size(931, 468); this.Controls.Add(this.backstageView); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + //this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(947, 506); this.Name = "Setup"; this.Text = "Setup"; diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs index 9b13408161..29cabc91f7 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/ConfigurationView/Setup.cs @@ -10,26 +10,62 @@ using ArdupilotMega.Controls.BackstageView; namespace ArdupilotMega.GCSViews.ConfigurationView { - public partial class Setup : Form + public partial class Setup : MyUserControl { public Setup() { InitializeComponent(); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRadioInput(), "Radio Calibration")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigFlightModes(), "Flight Modes")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigHardwareOptions(), "Hardware Options")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigBatteryMonitoring(), "Battery Monitor")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationQuad(), "ArduCopter Level")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationPlane(), "ArduPlane Level")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigTradHeli(), "Heli Setup")); + if (MainV2.comPort.BaseStream.IsOpen) + { + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRadioInput(), "Radio Calibration")); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigFlightModes(), "Flight Modes")); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigHardwareOptions(), "Hardware Options")); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigBatteryMonitoring(), "Battery Monitor")); - this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRawParams(), "Raw params (Advanced)")); + + /******************************HELI **************************/ + if (MainV2.comPort.param["H_GYR_ENABLE"] != null) // heli + { + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationQuad(), "ArduCopter Level")); + + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigTradHeli(), "Heli Setup")); + + var configpanel = new Controls.ConfigPanel(); + configpanel.LoadXML("ArduCopterConfig.xml"); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(configpanel, "ArduCopter Config")); + + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigArducopter(), "OLD ArduCopter Config")); + } + /****************************** ArduCopter **************************/ + else if (MainV2.cs.firmware == MainV2.Firmwares.ArduCopter2) + { + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationQuad(), "ArduCopter Level")); + + var configpanel = new Controls.ConfigPanel(); + configpanel.LoadXML("ArduCopterConfig.xml"); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(configpanel, "ArduCopter Config")); + + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigArducopter(), "OLD ArduCopter Config")); + } + /****************************** ArduPlane **************************/ + else if (MainV2.cs.firmware == MainV2.Firmwares.ArduPlane) + { + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigAccelerometerCalibrationPlane(), "ArduPlane Level")); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigArduplane(), "ArduPlane Config")); + } + + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigRawParams(), "Raw params (Adv)")); + } + + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ArdupilotMega._3DRradio(), "3DR Radio")); this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ArdupilotMega.Antenna.Tracker(), "Antenna Tracker")); + this.backstageView.AddPage(new BackstageView.BackstageViewPage(new ConfigPlanner(), "Planner")); + this.backstageView.ActivatePage(backstageView.Pages[0]); if (!MainV2.comPort.BaseStream.IsOpen) diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs index cc696b6745..fe1c616f36 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs @@ -8,6 +8,7 @@ using System.Xml; using System.Net; using log4net; using ArdupilotMega.Arduino; +using ArdupilotMega.Utilities; namespace ArdupilotMega.GCSViews { @@ -649,8 +650,16 @@ namespace ArdupilotMega.GCSViews private void BUT_setup_Click(object sender, EventArgs e) { - Form temp = new GCSViews.ConfigurationView.Setup(); + Form temp = new Form(); + MyUserControl configview = new GCSViews.ConfigurationView.Setup(); + temp.Controls.Add(configview); ThemeManager.ApplyThemeTo(temp); + // fix title + temp.Text = configview.Name; + // fix size + temp.Size = configview.Size; + configview.Dock = DockStyle.Fill; + temp.FormClosing += configview.Close; temp.ShowDialog(); } diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs index da690be453..36e947d99f 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs @@ -152,7 +152,9 @@ namespace ArdupilotMega.GCSViews CMB_action.DataSource = list; - CMB_modes.DataSource = Enum.GetNames(typeof(Common.apmmodes)); + CMB_modes.DataSource = Common.getModesList(); + CMB_modes.ValueMember = "Key"; + CMB_modes.DisplayMember = "Value"; CMB_setwp.SelectedIndex = 0; @@ -288,7 +290,7 @@ namespace ArdupilotMega.GCSViews comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.RC_CHANNELS, MainV2.cs.raterc); // request rc info } catch { } - lastdata = DateTime.Now.AddSeconds(12); // prevent flooding + lastdata = DateTime.Now.AddSeconds(120); // prevent flooding } if (!MainV2.comPort.logreadmode) @@ -408,6 +410,11 @@ namespace ArdupilotMega.GCSViews if (tracklast.AddSeconds(1) < DateTime.Now) { + if (MainV2.config["CHK_maprotation"] != null && MainV2.config["CHK_maprotation"].ToString() == "True") + { + setMapBearing(); + } + gMapControl1.HoldInvalidation = true; while (gMapControl1.inOnPaint == true) @@ -423,7 +430,6 @@ namespace ArdupilotMega.GCSViews trackPoints.Add(new PointLatLng(MainV2.cs.lat, MainV2.cs.lng)); - // if (CB_tuning.Checked == false) // draw if in view { @@ -514,6 +520,14 @@ namespace ArdupilotMega.GCSViews Console.WriteLine("FD Main loop exit"); } + private void setMapBearing() + { + this.Invoke((System.Windows.Forms.MethodInvoker)delegate() + { + gMapControl1.Bearing = (int)MainV2.cs.yaw; + }); + } + // to prevent cross thread calls while in a draw and exception private void updateClearRoutes() diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx index 8921faf5e3..d4124399bd 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.resx @@ -208,7 +208,7 @@ hud1 - hud.HUD, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.HUD, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null SubMainLeft.Panel1 @@ -247,7 +247,7 @@ BUT_script - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -280,7 +280,7 @@ BUT_joystick - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -310,7 +310,7 @@ BUT_quickmanual - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -340,7 +340,7 @@ BUT_quickrtl - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -370,7 +370,7 @@ BUT_quickauto - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -424,7 +424,7 @@ BUT_setwp - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -475,7 +475,7 @@ BUT_setmode - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -505,7 +505,7 @@ BUT_clear_track - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -556,7 +556,7 @@ BUT_Homealt - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -586,7 +586,7 @@ BUT_RAWSensor - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -616,7 +616,7 @@ BUTrestartmission - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -646,7 +646,7 @@ BUTactiondo - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabActions @@ -700,7 +700,7 @@ Gvspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabGauges @@ -730,7 +730,7 @@ Gheading - AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabGauges @@ -760,7 +760,7 @@ Galt - AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabGauges @@ -793,7 +793,7 @@ Gspeed - AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + AGaugeApp.AGauge, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabGauges @@ -874,7 +874,7 @@ lbl_logpercent - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabTLogs @@ -925,7 +925,7 @@ BUT_log2kml - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabTLogs @@ -976,7 +976,7 @@ BUT_playlog - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1003,7 +1003,7 @@ BUT_loadtelem - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null tabTLogs @@ -1192,7 +1192,7 @@ lbl_hdop - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1225,7 +1225,7 @@ lbl_sats - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1255,7 +1255,7 @@ lbl_winddir - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1285,7 +1285,7 @@ lbl_windvel - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1457,7 +1457,7 @@ gMapControl1 - ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.myGMAP, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null splitContainer1.Panel2 @@ -1520,7 +1520,7 @@ TXT_lat - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null panel1 @@ -1577,7 +1577,7 @@ label1 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null panel1 @@ -1607,7 +1607,7 @@ TXT_long - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null panel1 @@ -1637,7 +1637,7 @@ TXT_alt - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null panel1 @@ -1838,7 +1838,7 @@ label6 - ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyLabel, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null $this @@ -1916,6 +1916,6 @@ FlightData - System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner, Version=1.1.4497.35992, Culture=neutral, PublicKeyToken=null + System.Windows.Forms.MyUserControl, ArdupilotMegaPlanner, Version=1.1.4498.22301, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs index bdf89907b3..0cfe83d42a 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightPlanner.cs @@ -22,7 +22,7 @@ using log4net; using SharpKml.Base; using SharpKml.Dom; using ArdupilotMega.Controls; - +using ArdupilotMega.Utilities; namespace ArdupilotMega.GCSViews diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs index 9dbeb0d323..d1ba06794d 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Terminal.cs @@ -9,7 +9,7 @@ using System.Windows.Forms; using ArdupilotMega; using System.IO.Ports; using ArdupilotMega.Comms; - +using ArdupilotMega.Utilities; namespace ArdupilotMega.GCSViews { diff --git a/Tools/ArdupilotMegaPlanner/MAVLink.cs b/Tools/ArdupilotMegaPlanner/MAVLink.cs index 485ef2a42a..cdf63dbd26 100644 --- a/Tools/ArdupilotMegaPlanner/MAVLink.cs +++ b/Tools/ArdupilotMegaPlanner/MAVLink.cs @@ -13,6 +13,7 @@ using ArdupilotMega.Controls; using System.ComponentModel; using log4net; using ArdupilotMega.Comms; +using ArdupilotMega.Utilities; namespace ArdupilotMega { @@ -678,7 +679,7 @@ namespace ArdupilotMega continue; } - log.Info(DateTime.Now.Millisecond + " got param " + (par.param_index) + " of " + (par.param_count - 2) + " name: " + paramID); + log.Info(DateTime.Now.Millisecond + " got param " + (par.param_index) + " of " + (par.param_count - 2) + " name: " + paramID ); modifyParamForDisplay(true, paramID, ref par.param_value); param[paramID] = (par.param_value); @@ -1027,7 +1028,7 @@ namespace ArdupilotMega public void requestDatastream(byte id, byte hzrate) { - /* + double pps = 0; switch (id) @@ -1118,7 +1119,7 @@ namespace ArdupilotMega { return; } - */ + log.InfoFormat("Request stream {0} at {1} hz", Enum.Parse(typeof(MAV_DATA_STREAM), id.ToString()), hzrate); getDatastream(id, hzrate); @@ -1148,7 +1149,7 @@ namespace ArdupilotMega { return true; } - + return false; } diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index a8ace39bd8..f04826220b 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -19,7 +19,6 @@ using System.Speech.Synthesis; using System.Globalization; using System.Threading; using System.Net.Sockets; -using ArdupilotMega.Utilities; using IronPython.Hosting; using log4net; using ArdupilotMega.Controls; @@ -27,6 +26,7 @@ using System.Security.Cryptography; using ArdupilotMega.Comms; using ArdupilotMega.Arduino; using System.IO.Ports; +using ArdupilotMega.Utilities; namespace ArdupilotMega { @@ -128,8 +128,8 @@ namespace ArdupilotMega /// GCSViews.FlightData FlightData; GCSViews.FlightPlanner FlightPlanner; - GCSViews.Configuration Configuration; - //GCSViews.ConfigurationView.Configuration Configuration; + //GCSViews.Configuration Configuration; + GCSViews.ConfigurationView.Setup Configuration; GCSViews.Simulation Simulation; GCSViews.Firmware Firmware; GCSViews.Terminal Terminal; @@ -427,23 +427,19 @@ namespace ArdupilotMega catch { } } - Configuration = new GCSViews.Configuration(); - //Configuration = new GCSViews.ConfigurationView.Configuration(); + //Configuration = new GCSViews.Configuration(); + Configuration = new GCSViews.ConfigurationView.Setup(); UserControl temp = Configuration; ThemeManager.ApplyThemeTo(temp); - //temp.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; - temp.Location = new Point(0, 0); temp.Dock = DockStyle.Fill; temp.Size = MyView.Size; - //temp.Parent = MyView; - MyView.Controls.Add(temp); } @@ -1230,9 +1226,6 @@ namespace ArdupilotMega log.Error("Update check failed", ex); } } - - // TODO: Move this to a more appropriate place, like right after CheckForUpdate(); - ParameterMetaDataParser.GetParameterInformation(); } @@ -2042,7 +2035,7 @@ namespace ArdupilotMega cfg.LoadXML("ArduCopterConfig.xml"); - cfg.ShowDialog(); + //cfg.ShowDialog(); return true; } diff --git a/Tools/ArdupilotMegaPlanner/MavlinkLog.cs b/Tools/ArdupilotMegaPlanner/MavlinkLog.cs index 681968f35e..f5422532e9 100644 --- a/Tools/ArdupilotMegaPlanner/MavlinkLog.cs +++ b/Tools/ArdupilotMegaPlanner/MavlinkLog.cs @@ -26,6 +26,8 @@ using System.Xml; using log4net; using ZedGraph; // Graphs +using ArdupilotMega.Utilities; + using System.CodeDom.Compiler; namespace ArdupilotMega diff --git a/Tools/ArdupilotMegaPlanner/Msi/wix.pdb b/Tools/ArdupilotMegaPlanner/Msi/wix.pdb index a80ac1fd2d..e2bd4a8c51 100644 Binary files a/Tools/ArdupilotMegaPlanner/Msi/wix.pdb and b/Tools/ArdupilotMegaPlanner/Msi/wix.pdb differ diff --git a/Tools/ArdupilotMegaPlanner/Program.cs b/Tools/ArdupilotMegaPlanner/Program.cs index c4051b1c2e..cefe48848f 100644 --- a/Tools/ArdupilotMegaPlanner/Program.cs +++ b/Tools/ArdupilotMegaPlanner/Program.cs @@ -60,7 +60,7 @@ namespace ArdupilotMega static void Application_Idle(object sender, EventArgs e) { - Console.Write("Idle\r"); + // Console.Write("Idle\r"); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) diff --git a/Tools/ArdupilotMegaPlanner/RAW_Sensor.cs b/Tools/ArdupilotMegaPlanner/RAW_Sensor.cs index 33db53e8f2..e36709761f 100644 --- a/Tools/ArdupilotMegaPlanner/RAW_Sensor.cs +++ b/Tools/ArdupilotMegaPlanner/RAW_Sensor.cs @@ -214,10 +214,6 @@ namespace ArdupilotMega { if (sw != null) sw.Close(); - - MainV2.cs.ratesensors = 3; // hardcode 3 hz - - comPort.requestDatastream((byte)ArdupilotMega.MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.cs.ratesensors); // request raw sensor } catch { } } diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs index ba32270f0c..d693b73eeb 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.Designer.cs @@ -294,7 +294,6 @@ // // RS4 // - resources.ApplyResources(this.RS4, "RS4"); this.RS4.FormattingEnabled = true; this.RS4.Items.AddRange(new object[] { resources.GetString("RS4.Items"), @@ -318,12 +317,12 @@ resources.GetString("RS4.Items18"), resources.GetString("RS4.Items19"), resources.GetString("RS4.Items20")}); + resources.ApplyResources(this.RS4, "RS4"); this.RS4.Name = "RS4"; this.toolTip1.SetToolTip(this.RS4, resources.GetString("RS4.ToolTip")); // // RS3 // - resources.ApplyResources(this.RS3, "RS3"); this.RS3.FormattingEnabled = true; this.RS3.Items.AddRange(new object[] { resources.GetString("RS3.Items"), @@ -356,12 +355,12 @@ resources.GetString("RS3.Items27"), resources.GetString("RS3.Items28"), resources.GetString("RS3.Items29")}); + resources.ApplyResources(this.RS3, "RS3"); this.RS3.Name = "RS3"; this.toolTip1.SetToolTip(this.RS3, resources.GetString("RS3.ToolTip")); // // RS2 // - resources.ApplyResources(this.RS2, "RS2"); this.RS2.FormattingEnabled = true; this.RS2.Items.AddRange(new object[] { resources.GetString("RS2.Items"), @@ -374,12 +373,12 @@ resources.GetString("RS2.Items7"), resources.GetString("RS2.Items8"), resources.GetString("RS2.Items9")}); + resources.ApplyResources(this.RS2, "RS2"); this.RS2.Name = "RS2"; this.toolTip1.SetToolTip(this.RS2, resources.GetString("RS2.ToolTip")); // // RS1 // - resources.ApplyResources(this.RS1, "RS1"); this.RS1.FormattingEnabled = true; this.RS1.Items.AddRange(new object[] { resources.GetString("RS1.Items"), @@ -391,6 +390,7 @@ resources.GetString("RS1.Items6"), resources.GetString("RS1.Items7"), resources.GetString("RS1.Items8")}); + resources.ApplyResources(this.RS1, "RS1"); this.RS1.Name = "RS1"; this.toolTip1.SetToolTip(this.RS1, resources.GetString("RS1.ToolTip")); // @@ -458,17 +458,16 @@ // // RS12 // - resources.ApplyResources(this.RS12, "RS12"); this.RS12.FormattingEnabled = true; this.RS12.Items.AddRange(new object[] { resources.GetString("RS12.Items"), resources.GetString("RS12.Items1")}); + resources.ApplyResources(this.RS12, "RS12"); this.RS12.Name = "RS12"; this.toolTip1.SetToolTip(this.RS12, resources.GetString("RS12.ToolTip")); // // RS11 // - resources.ApplyResources(this.RS11, "RS11"); this.RS11.FormattingEnabled = true; this.RS11.Items.AddRange(new object[] { resources.GetString("RS11.Items"), @@ -481,12 +480,12 @@ resources.GetString("RS11.Items7"), resources.GetString("RS11.Items8"), resources.GetString("RS11.Items9")}); + resources.ApplyResources(this.RS11, "RS11"); this.RS11.Name = "RS11"; this.toolTip1.SetToolTip(this.RS11, resources.GetString("RS11.ToolTip")); // // RS10 // - resources.ApplyResources(this.RS10, "RS10"); this.RS10.FormattingEnabled = true; this.RS10.Items.AddRange(new object[] { resources.GetString("RS10.Items"), @@ -508,6 +507,7 @@ resources.GetString("RS10.Items16"), resources.GetString("RS10.Items17"), resources.GetString("RS10.Items18")}); + resources.ApplyResources(this.RS10, "RS10"); this.RS10.Name = "RS10"; this.toolTip1.SetToolTip(this.RS10, resources.GetString("RS10.ToolTip")); // @@ -548,7 +548,6 @@ // // RS8 // - resources.ApplyResources(this.RS8, "RS8"); this.RS8.FormattingEnabled = true; this.RS8.Items.AddRange(new object[] { resources.GetString("RS8.Items"), @@ -560,11 +559,11 @@ resources.GetString("RS8.Items6"), resources.GetString("RS8.Items7"), resources.GetString("RS8.Items8")}); + resources.ApplyResources(this.RS8, "RS8"); this.RS8.Name = "RS8"; // // RS9 // - resources.ApplyResources(this.RS9, "RS9"); this.RS9.FormattingEnabled = true; this.RS9.Items.AddRange(new object[] { resources.GetString("RS9.Items"), @@ -576,6 +575,7 @@ resources.GetString("RS9.Items6"), resources.GetString("RS9.Items7"), resources.GetString("RS9.Items8")}); + resources.ApplyResources(this.RS9, "RS9"); this.RS9.Name = "RS9"; // // RS0 @@ -632,8 +632,8 @@ // // lbl_status // - resources.ApplyResources(this.lbl_status, "lbl_status"); this.lbl_status.BackColor = System.Drawing.Color.Transparent; + resources.ApplyResources(this.lbl_status, "lbl_status"); this.lbl_status.Name = "lbl_status"; // // BUT_upload diff --git a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx index d13b7ec707..94a14edc26 100644 --- a/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx +++ b/Tools/ArdupilotMegaPlanner/Radio/3DRradio.resx @@ -117,10 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Bottom, Left, Right - 12, 389 @@ -767,9 +763,6 @@ 51 - - Top, Right - 499, 287 @@ -795,9 +788,6 @@ 41 - - Top, Right - 499, 260 @@ -823,9 +813,6 @@ 42 - - Top, Right - 499, 233 @@ -851,9 +838,6 @@ 43 - - Top, Right - 0 @@ -942,9 +926,6 @@ 44 - - Top, Right - 1 @@ -1059,9 +1040,6 @@ 45 - - Top, Right - 250 @@ -1116,9 +1094,6 @@ 46 - - Top, Right - 115 @@ -1373,9 +1348,6 @@ which result in a valid packet CRC 27 - - Top, Right - 0 @@ -1407,9 +1379,6 @@ which result in a valid packet CRC 17 - - Top, Right - 10 @@ -1465,9 +1434,6 @@ which result in a valid packet CRC 18 - - Top, Right - 5 @@ -1655,9 +1621,6 @@ which result in a valid packet CRC 26 - - Top, Right - 902000 @@ -1706,9 +1669,6 @@ which result in a valid packet CRC 16 - - Top, Right - 902000 @@ -1757,9 +1717,6 @@ which result in a valid packet CRC 20 - - Top, Right - 499, 99 @@ -1808,9 +1765,6 @@ which result in a valid packet CRC 40 - - Top, Right - True @@ -1838,9 +1792,6 @@ which result in a valid packet CRC 39 - - Top, Right - 543, 25 @@ -1937,9 +1888,6 @@ which result in a valid packet CRC 34 - - Bottom - False @@ -1959,7 +1907,7 @@ which result in a valid packet CRC BUT_savesettings - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -1967,9 +1915,6 @@ which result in a valid packet CRC 49 - - Bottom - 253, 319 @@ -1986,7 +1931,7 @@ which result in a valid packet CRC BUT_getcurrent - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -1994,9 +1939,6 @@ which result in a valid packet CRC 64 - - Bottom, Left, Right - 12, 361 @@ -2018,9 +1960,6 @@ which result in a valid packet CRC 67 - - Bottom - 403, 319 @@ -2037,7 +1976,7 @@ which result in a valid packet CRC BUT_upload - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2061,7 +2000,7 @@ which result in a valid packet CRC BUT_syncS2 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2085,7 +2024,7 @@ which result in a valid packet CRC BUT_syncS3 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2109,7 +2048,7 @@ which result in a valid packet CRC BUT_syncS5 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2120,6 +2059,7 @@ which result in a valid packet CRC True + NoControl @@ -2267,9 +2207,6 @@ which result in a valid packet CRC 21 - - Top, Right - True @@ -2300,9 +2237,6 @@ which result in a valid packet CRC 11 - - Top, Right - True @@ -2333,9 +2267,6 @@ which result in a valid packet CRC 12 - - Top, Right - True @@ -2366,9 +2297,6 @@ which result in a valid packet CRC 13 - - Top, Right - True @@ -2399,9 +2327,6 @@ which result in a valid packet CRC 14 - - Top, Right - True @@ -2432,9 +2357,6 @@ which result in a valid packet CRC 15 - - Top, Right - True @@ -2465,9 +2387,6 @@ which result in a valid packet CRC 3 - - Top, Right - True @@ -2498,9 +2417,6 @@ which result in a valid packet CRC 4 - - Top, Right - True @@ -2531,9 +2447,6 @@ which result in a valid packet CRC 5 - - Top, Right - True @@ -2564,9 +2477,6 @@ which result in a valid packet CRC 6 - - Top, Right - True @@ -2597,9 +2507,6 @@ which result in a valid packet CRC 7 - - Top, Right - True @@ -2630,9 +2537,6 @@ which result in a valid packet CRC 8 - - Top, Right - True @@ -2663,9 +2567,6 @@ which result in a valid packet CRC 9 - - Top, Right - True @@ -2715,7 +2616,7 @@ which result in a valid packet CRC BUT_syncS8 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2742,7 +2643,7 @@ which result in a valid packet CRC BUT_syncS9 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2769,7 +2670,7 @@ which result in a valid packet CRC BUT_syncS10 - ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.MyButton, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null $this @@ -2796,6 +2697,6 @@ which result in a valid packet CRC _3DRradio - ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4494.22181, Culture=neutral, PublicKeyToken=null + ArdupilotMega.Controls.BackstageView.BackStageViewContentPanel, ArdupilotMegaPlanner, Version=1.1.4498.26252, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/AviWriter.cs b/Tools/ArdupilotMegaPlanner/Utilities/AviWriter.cs similarity index 96% rename from Tools/ArdupilotMegaPlanner/AviWriter.cs rename to Tools/ArdupilotMegaPlanner/Utilities/AviWriter.cs index 19f1d019c4..79f27421ab 100644 --- a/Tools/ArdupilotMegaPlanner/AviWriter.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/AviWriter.cs @@ -1,310 +1,310 @@ -using System; -using System.Runtime.InteropServices; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using u32 = System.UInt32; -using u16 = System.UInt16; -using u8 = System.Byte; - -/// -/// based off ftp://pserver.samba.org/pub/unpacked/picturebook/avi.c -/// - -public class AviWriter -{ - /* -avi debug: * LIST-root size:1233440040 pos:0 -avi debug: + RIFF-AVI size:1233440032 pos:0 -avi debug: | + LIST-hdrl size:310 pos:12 -avi debug: | | + avih size:56 pos:24 -avi debug: | | + LIST-strl size:124 pos:88 -avi debug: | | | + strh size:64 pos:100 -avi debug: | | | + strf size:40 pos:172 -avi debug: | | + LIST-strl size:102 pos:220 -avi debug: | | | + strh size:64 pos:232 -avi debug: | | | + strf size:18 pos:304 -avi debug: | + JUNK size:1698 pos:330 -avi debug: | + LIST-movi size:1232936964 pos:2036 -avi debug: | + idx1 size:501024 pos:1232939008 -avi debug: AVIH: 2 stream, flags HAS_INDEX -avi debug: stream[0] rate:1000000 scale:33333 samplesize:0 -avi debug: stream[0] video(MJPG) 1280x720 24bpp 30.000300fps - */ - - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct riff_head - { - [MarshalAs( - UnmanagedType.ByValArray, - SizeConst = 4)] - public char[] riff; /* "RIFF" */ - public u32 size; - [MarshalAs( - UnmanagedType.ByValArray, - SizeConst = 4)] - public char[] avistr; /* "AVI " */ - }; - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct stream_head - { /* 56 bytes */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] strh; /* "strh" */ - public u32 size; - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] vids; /* "vids" */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] codec; /* codec name */ - public u32 flags; - public u32 reserved1; - public u32 initialframes; - public u32 scale; /* 1 */ - public u32 rate; /* in frames per second */ - public u32 start; - public u32 length; /* what units?? fps*nframes ?? */ - public u32 suggested_bufsize; - public u32 quality; /* -1 */ - public u32 samplesize; - public short l; - public short t; - public short r; - public short b; - }; - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct avi_head - { /* 64 bytes */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] avih; /* "avih" */ - public u32 size; - public u32 time; /* microsec per frame? 1e6 / fps ?? */ - public u32 maxbytespersec; - public u32 reserved1; - public u32 flags; - public u32 nframes; - public u32 initialframes; - public u32 numstreams; /* 1 */ - public u32 suggested_bufsize; - public u32 width; - public u32 height; - public u32 scale; /* 1 */ - public u32 rate; /* fps */ - public u32 start; - public u32 length; /* what units?? fps*nframes ?? */ - }; - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct list_head - { /* 12 bytes */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] list; /* "LIST" */ - public u32 size; - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] type; - }; - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct db_head - { - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] db; /* "00db" */ - public u32 size; - }; - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct frame_head - { /* 48 bytes */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] strf; /* "strf" */ - public u32 size; - public UInt32 size2; /* repeat of previous field? */ - public Int32 width; - public Int32 height; - public Int16 planes; /* 1 */ - public Int16 bitcount; /* 24 */ - [MarshalAs( -UnmanagedType.ByValArray, -SizeConst = 4)] - public char[] codec; /* MJPG */ - public UInt32 unpackedsize; /* 3 * w * h */ - public Int32 r1; - public Int32 r2; - public UInt32 clr_used; - public UInt32 clr_important; - }; - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct BITMAPINFOHEADER - { - public UInt32 biSize; - public Int32 biWidth; - public Int32 biHeight; - public Int16 biPlanes; - public Int16 biBitCount; - public UInt32 biCompression; - public UInt32 biSizeImage; - public Int32 biXPelsPerMeter; - public Int32 biYPelsPerMeter; - public UInt32 biClrUsed; - public UInt32 biClrImportant; - } - - - - static int nframes; - static uint totalsize; - System.IO.BufferedStream fd; - - public void avi_close() - { - if (fd != null) - fd.Close(); - } - - /* start writing an AVI file */ - public void avi_start(string filename) - { - avi_close(); - - fd = new BufferedStream(File.Open(filename, FileMode.Create)); - - fd.Seek(2048,SeekOrigin.Begin); - - nframes = 0; - totalsize = 0; - } - - - /* add a jpeg frame to an AVI file */ - public void avi_add(u8[] buf, uint size) - { - Console.WriteLine(DateTime.Now.Millisecond + "avi frame"); - db_head db = new db_head { db = "00dc".ToCharArray(), size = size }; - fd.Write(StructureToByteArray(db), 0, Marshal.SizeOf(db)); - fd.Write(buf, 0, (int)size); - if (size % 2 == 1) - { - size++; - fd.Seek(1, SeekOrigin.Current); - } - nframes++; - totalsize += size; - } - - void strcpy(ref char[] to,string orig) - { - to = orig.ToCharArray(); - } - - /* finish writing the AVI file - filling in the header */ - public void avi_end(int width, int height, int fps) - { - riff_head rh = new riff_head { riff = "RIFF".ToCharArray(), size = 0, avistr = "AVI ".ToCharArray() }; - list_head lh1 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "hdrl".ToCharArray() }; - avi_head ah = new avi_head(); - list_head lh2 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "strl".ToCharArray() }; - stream_head sh = new stream_head(); - frame_head fh = new frame_head(); - list_head junk = new list_head() { list = "JUNK".ToCharArray(), size = 0 }; - list_head lh3 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "movi".ToCharArray() }; - - //bzero(&ah, sizeof(ah)); - strcpy(ref ah.avih, "avih"); - ah.time = (u32)(1e6 / fps); - ah.numstreams = 1; - //ah.scale = (u32)(1e6 / fps); - //ah.rate = (u32)fps; - //ah.length = (u32)(nframes); - ah.nframes = (u32)(nframes); - ah.width = (u32)width; - ah.height = (u32)height; - ah.flags = 0; - ah.suggested_bufsize = (u32)(3 * width * height * fps); - ah.maxbytespersec = (u32)(3 * width * height * fps); - - //bzero(&sh, sizeof(sh)); - strcpy(ref sh.strh, "strh"); - strcpy(ref sh.vids, "vids"); - strcpy(ref sh.codec, "MJPG"); - sh.scale = (u32)(1e6 / fps); - sh.rate = (u32)1000000; - sh.length = (u32)(nframes); - sh.suggested_bufsize = (u32)(3 * width * height * fps); - unchecked - { - sh.quality = (uint)-1; - } - - //bzero(&fh, sizeof(fh)); - strcpy(ref fh.strf, "strf"); - fh.width = width; - fh.height = height; - fh.planes = 1; - fh.bitcount = 24; - strcpy(ref fh.codec, "MJPG"); - fh.unpackedsize = (u32)(3 * width * height); - - rh.size = (u32)(Marshal.SizeOf(lh1) + Marshal.SizeOf(ah) + Marshal.SizeOf(lh2) + Marshal.SizeOf(sh) + - Marshal.SizeOf(fh) + Marshal.SizeOf(lh3) + - nframes * Marshal.SizeOf((new db_head())) + - totalsize); - lh1.size = (u32)(4 + Marshal.SizeOf(ah) + Marshal.SizeOf(lh2) + Marshal.SizeOf(sh) + Marshal.SizeOf(fh)); - ah.size = (u32)(Marshal.SizeOf(ah) - 8); - lh2.size = (u32)(4 + Marshal.SizeOf(sh) + Marshal.SizeOf(fh)); - sh.size = (u32)(Marshal.SizeOf(sh) - 8); - fh.size = (u32)(Marshal.SizeOf(fh) - 8); - fh.size2 = fh.size; - lh3.size = (u32)(4 + - nframes * Marshal.SizeOf((new db_head())) + - totalsize); - junk.size = 2048 - lh1.size - 12 - 12 - 12 - 4; // junk head, list head, rif head , 4 - long pos = fd.Position; - fd.Seek(0, SeekOrigin.Begin); - - fd.Write(StructureToByteArray(rh),0, Marshal.SizeOf(rh)); - fd.Write(StructureToByteArray(lh1), 0, Marshal.SizeOf(lh1)); - fd.Write(StructureToByteArray(ah), 0, Marshal.SizeOf(ah)); - fd.Write(StructureToByteArray(lh2), 0, Marshal.SizeOf(lh2)); - fd.Write(StructureToByteArray(sh), 0, Marshal.SizeOf(sh)); - fd.Write(StructureToByteArray(fh), 0, Marshal.SizeOf(fh)); - fd.Write(StructureToByteArray(junk), 0, Marshal.SizeOf(junk)); - fd.Seek(2036, SeekOrigin.Begin); - fd.Write(StructureToByteArray(lh3), 0, Marshal.SizeOf(lh3)); - - fd.Seek(pos, SeekOrigin.Begin); - } - - byte[] StructureToByteArray(object obj) - { - - int len = Marshal.SizeOf(obj); - - byte[] arr = new byte[len]; - - IntPtr ptr = Marshal.AllocHGlobal(len); - - Marshal.StructureToPtr(obj, ptr, true); - - Marshal.Copy(ptr, arr, 0, len); - - Marshal.FreeHGlobal(ptr); - - return arr; - - } +using System; +using System.Runtime.InteropServices; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using u32 = System.UInt32; +using u16 = System.UInt16; +using u8 = System.Byte; + +/// +/// based off ftp://pserver.samba.org/pub/unpacked/picturebook/avi.c +/// + +public class AviWriter +{ + /* +avi debug: * LIST-root size:1233440040 pos:0 +avi debug: + RIFF-AVI size:1233440032 pos:0 +avi debug: | + LIST-hdrl size:310 pos:12 +avi debug: | | + avih size:56 pos:24 +avi debug: | | + LIST-strl size:124 pos:88 +avi debug: | | | + strh size:64 pos:100 +avi debug: | | | + strf size:40 pos:172 +avi debug: | | + LIST-strl size:102 pos:220 +avi debug: | | | + strh size:64 pos:232 +avi debug: | | | + strf size:18 pos:304 +avi debug: | + JUNK size:1698 pos:330 +avi debug: | + LIST-movi size:1232936964 pos:2036 +avi debug: | + idx1 size:501024 pos:1232939008 +avi debug: AVIH: 2 stream, flags HAS_INDEX +avi debug: stream[0] rate:1000000 scale:33333 samplesize:0 +avi debug: stream[0] video(MJPG) 1280x720 24bpp 30.000300fps + */ + + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct riff_head + { + [MarshalAs( + UnmanagedType.ByValArray, + SizeConst = 4)] + public char[] riff; /* "RIFF" */ + public u32 size; + [MarshalAs( + UnmanagedType.ByValArray, + SizeConst = 4)] + public char[] avistr; /* "AVI " */ + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct stream_head + { /* 56 bytes */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] strh; /* "strh" */ + public u32 size; + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] vids; /* "vids" */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] codec; /* codec name */ + public u32 flags; + public u32 reserved1; + public u32 initialframes; + public u32 scale; /* 1 */ + public u32 rate; /* in frames per second */ + public u32 start; + public u32 length; /* what units?? fps*nframes ?? */ + public u32 suggested_bufsize; + public u32 quality; /* -1 */ + public u32 samplesize; + public short l; + public short t; + public short r; + public short b; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct avi_head + { /* 64 bytes */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] avih; /* "avih" */ + public u32 size; + public u32 time; /* microsec per frame? 1e6 / fps ?? */ + public u32 maxbytespersec; + public u32 reserved1; + public u32 flags; + public u32 nframes; + public u32 initialframes; + public u32 numstreams; /* 1 */ + public u32 suggested_bufsize; + public u32 width; + public u32 height; + public u32 scale; /* 1 */ + public u32 rate; /* fps */ + public u32 start; + public u32 length; /* what units?? fps*nframes ?? */ + }; + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct list_head + { /* 12 bytes */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] list; /* "LIST" */ + public u32 size; + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] type; + }; + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct db_head + { + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] db; /* "00db" */ + public u32 size; + }; + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct frame_head + { /* 48 bytes */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] strf; /* "strf" */ + public u32 size; + public UInt32 size2; /* repeat of previous field? */ + public Int32 width; + public Int32 height; + public Int16 planes; /* 1 */ + public Int16 bitcount; /* 24 */ + [MarshalAs( +UnmanagedType.ByValArray, +SizeConst = 4)] + public char[] codec; /* MJPG */ + public UInt32 unpackedsize; /* 3 * w * h */ + public Int32 r1; + public Int32 r2; + public UInt32 clr_used; + public UInt32 clr_important; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct BITMAPINFOHEADER + { + public UInt32 biSize; + public Int32 biWidth; + public Int32 biHeight; + public Int16 biPlanes; + public Int16 biBitCount; + public UInt32 biCompression; + public UInt32 biSizeImage; + public Int32 biXPelsPerMeter; + public Int32 biYPelsPerMeter; + public UInt32 biClrUsed; + public UInt32 biClrImportant; + } + + + + static int nframes; + static uint totalsize; + System.IO.BufferedStream fd; + + public void avi_close() + { + if (fd != null) + fd.Close(); + } + + /* start writing an AVI file */ + public void avi_start(string filename) + { + avi_close(); + + fd = new BufferedStream(File.Open(filename, FileMode.Create)); + + fd.Seek(2048,SeekOrigin.Begin); + + nframes = 0; + totalsize = 0; + } + + + /* add a jpeg frame to an AVI file */ + public void avi_add(u8[] buf, uint size) + { + Console.WriteLine(DateTime.Now.Millisecond + "avi frame"); + db_head db = new db_head { db = "00dc".ToCharArray(), size = size }; + fd.Write(StructureToByteArray(db), 0, Marshal.SizeOf(db)); + fd.Write(buf, 0, (int)size); + if (size % 2 == 1) + { + size++; + fd.Seek(1, SeekOrigin.Current); + } + nframes++; + totalsize += size; + } + + void strcpy(ref char[] to,string orig) + { + to = orig.ToCharArray(); + } + + /* finish writing the AVI file - filling in the header */ + public void avi_end(int width, int height, int fps) + { + riff_head rh = new riff_head { riff = "RIFF".ToCharArray(), size = 0, avistr = "AVI ".ToCharArray() }; + list_head lh1 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "hdrl".ToCharArray() }; + avi_head ah = new avi_head(); + list_head lh2 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "strl".ToCharArray() }; + stream_head sh = new stream_head(); + frame_head fh = new frame_head(); + list_head junk = new list_head() { list = "JUNK".ToCharArray(), size = 0 }; + list_head lh3 = new list_head { list = "LIST".ToCharArray(), size = 0, type = "movi".ToCharArray() }; + + //bzero(&ah, sizeof(ah)); + strcpy(ref ah.avih, "avih"); + ah.time = (u32)(1e6 / fps); + ah.numstreams = 1; + //ah.scale = (u32)(1e6 / fps); + //ah.rate = (u32)fps; + //ah.length = (u32)(nframes); + ah.nframes = (u32)(nframes); + ah.width = (u32)width; + ah.height = (u32)height; + ah.flags = 0; + ah.suggested_bufsize = (u32)(3 * width * height * fps); + ah.maxbytespersec = (u32)(3 * width * height * fps); + + //bzero(&sh, sizeof(sh)); + strcpy(ref sh.strh, "strh"); + strcpy(ref sh.vids, "vids"); + strcpy(ref sh.codec, "MJPG"); + sh.scale = (u32)(1e6 / fps); + sh.rate = (u32)1000000; + sh.length = (u32)(nframes); + sh.suggested_bufsize = (u32)(3 * width * height * fps); + unchecked + { + sh.quality = (uint)-1; + } + + //bzero(&fh, sizeof(fh)); + strcpy(ref fh.strf, "strf"); + fh.width = width; + fh.height = height; + fh.planes = 1; + fh.bitcount = 24; + strcpy(ref fh.codec, "MJPG"); + fh.unpackedsize = (u32)(3 * width * height); + + rh.size = (u32)(Marshal.SizeOf(lh1) + Marshal.SizeOf(ah) + Marshal.SizeOf(lh2) + Marshal.SizeOf(sh) + + Marshal.SizeOf(fh) + Marshal.SizeOf(lh3) + + nframes * Marshal.SizeOf((new db_head())) + + totalsize); + lh1.size = (u32)(4 + Marshal.SizeOf(ah) + Marshal.SizeOf(lh2) + Marshal.SizeOf(sh) + Marshal.SizeOf(fh)); + ah.size = (u32)(Marshal.SizeOf(ah) - 8); + lh2.size = (u32)(4 + Marshal.SizeOf(sh) + Marshal.SizeOf(fh)); + sh.size = (u32)(Marshal.SizeOf(sh) - 8); + fh.size = (u32)(Marshal.SizeOf(fh) - 8); + fh.size2 = fh.size; + lh3.size = (u32)(4 + + nframes * Marshal.SizeOf((new db_head())) + + totalsize); + junk.size = 2048 - lh1.size - 12 - 12 - 12 - 4; // junk head, list head, rif head , 4 + long pos = fd.Position; + fd.Seek(0, SeekOrigin.Begin); + + fd.Write(StructureToByteArray(rh),0, Marshal.SizeOf(rh)); + fd.Write(StructureToByteArray(lh1), 0, Marshal.SizeOf(lh1)); + fd.Write(StructureToByteArray(ah), 0, Marshal.SizeOf(ah)); + fd.Write(StructureToByteArray(lh2), 0, Marshal.SizeOf(lh2)); + fd.Write(StructureToByteArray(sh), 0, Marshal.SizeOf(sh)); + fd.Write(StructureToByteArray(fh), 0, Marshal.SizeOf(fh)); + fd.Write(StructureToByteArray(junk), 0, Marshal.SizeOf(junk)); + fd.Seek(2036, SeekOrigin.Begin); + fd.Write(StructureToByteArray(lh3), 0, Marshal.SizeOf(lh3)); + + fd.Seek(pos, SeekOrigin.Begin); + } + + byte[] StructureToByteArray(object obj) + { + + int len = Marshal.SizeOf(obj); + + byte[] arr = new byte[len]; + + IntPtr ptr = Marshal.AllocHGlobal(len); + + Marshal.StructureToPtr(obj, ptr, true); + + Marshal.Copy(ptr, arr, 0, len); + + Marshal.FreeHGlobal(ptr); + + return arr; + + } } \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/Capture.cs b/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs similarity index 96% rename from Tools/ArdupilotMegaPlanner/Capture.cs rename to Tools/ArdupilotMegaPlanner/Utilities/Capture.cs index 44775cb5eb..032a061c3a 100644 --- a/Tools/ArdupilotMegaPlanner/Capture.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/Capture.cs @@ -1,498 +1,498 @@ -/**************************************************************************** -While the underlying libraries are covered by LGPL, this sample is released -as public domain. It is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. -*****************************************************************************/ - -using System; -using System.Drawing; -using System.Drawing.Imaging; -using System.Collections; -using System.Runtime.InteropServices; -using System.Threading; -using System.Diagnostics; -using System.Collections.Generic; - -using DirectShowLib; - - -namespace WebCamService -{ - public delegate void CamImage(Image camimage); - - /// Summary description for MainForm. - public class Capture : ISampleGrabberCB, IDisposable - { - #region Member variables - - /// graph builder interface. - private IFilterGraph2 m_FilterGraph = null; - private IMediaControl m_mediaCtrl = null; - - /// so we can wait for the async job to finish - private ManualResetEvent m_PictureReady = null; - - /// Set by async routine when it captures an image - private volatile bool m_bGotOne = false; - - /// Indicates the status of the graph - private bool m_bRunning = false; - - /// Dimensions of the image, calculated once in constructor. - private IntPtr m_handle = IntPtr.Zero; - private int m_videoWidth; - private int m_videoHeight; - private int m_stride; - public int m_Dropped = 0; - - public Image image = null; - IntPtr ip = IntPtr.Zero; - - public event CamImage camimage; - System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); - - #endregion - - #region API - - [DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory")] - private static extern void CopyMemory(IntPtr Destination, IntPtr Source, int Length); - - #endregion - - public Capture() - { - } - - /// Use capture with selected media caps - public Capture(int iDeviceNum, AMMediaType media) - { - DsDevice[] capDevices; - - // Get the collection of video devices - capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); - - if (iDeviceNum + 1 > capDevices.Length) - { - throw new Exception("No video capture devices found at that index!"); - } - - try - { - // Set up the capture graph - SetupGraph(capDevices[iDeviceNum], media); - - // tell the callback to ignore new images - m_PictureReady = new ManualResetEvent(false); - m_bGotOne = true; - m_bRunning = false; - - timer1.Interval = 1000 / 15; // 15 fps - timer1.Tick += new EventHandler(timer1_Tick); - timer1.Start(); - - } - catch - { - Dispose(); - throw; - } - } - /// release everything. - public void Dispose() - { - timer1.Stop(); - if (camimage != null) - { - camimage(null); // clear last pic - } - CloseInterfaces(); - if (m_PictureReady != null) - { - m_PictureReady.Close(); - m_PictureReady = null; - } - } - // Destructor - ~Capture() - { - Dispose(); - } - - public int Width - { - get - { - return m_videoWidth; - } - } - public int Height - { - get - { - return m_videoHeight; - } - } - public int Stride - { - get - { - return m_stride; - } - } - /// capture the next image - public IntPtr GetBitMap() - { - if (m_handle == IntPtr.Zero) - m_handle = Marshal.AllocCoTaskMem(m_stride * m_videoHeight); - - try - { - // get ready to wait for new image - m_PictureReady.Reset(); - m_bGotOne = false; - - // If the graph hasn't been started, start it. - Start(); - - // Start waiting - if ( ! m_PictureReady.WaitOne(5000, false) ) - { - throw new Exception("Timeout waiting to get picture"); - } - //Pause(); //- we are effectivly pulling at 15 fps, so no need to pause - } - catch - { - Marshal.FreeCoTaskMem(m_handle); - throw; - } - - // Got one - return m_handle; - } - // Start the capture graph - public void Start() - { - if (!m_bRunning) - { - int hr = m_mediaCtrl.Run(); - DsError.ThrowExceptionForHR( hr ); - - m_bRunning = true; - } - } - // Pause the capture graph. - // Running the graph takes up a lot of resources. Pause it when it - // isn't needed. - public void Pause() - { - if (m_bRunning) - { - int hr = m_mediaCtrl.Pause(); - DsError.ThrowExceptionForHR( hr ); - - m_bRunning = false; - } - } - - public static List getDevices() - { - List list = new List(); - DsDevice[] capDevices; - - // Get the collection of video devices - capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); - - foreach (DsDevice dev in capDevices) - { - list.Add(dev.Name); - } - - return list; - } - - public bool showhud = true; - - void timer1_Tick(object sender, EventArgs e) - { - try - { - ip = this.GetBitMap(); - image = new Bitmap(this.Width, this.Height, this.Stride, PixelFormat.Format24bppRgb, ip); - image.RotateFlip(RotateFlipType.RotateNoneFlipY); - if (camimage != null) - { - camimage(image); - } - } - catch { Console.WriteLine("Grab bmp failed"); timer1.Enabled = false; this.CloseInterfaces(); System.Windows.Forms.CustomMessageBox.Show("Problem with capture device, grabbing frame took longer than 5 sec"); } - } - - /// build the capture graph for grabber. - private void SetupGraph(DsDevice dev, AMMediaType media) - { - int hr; - - ISampleGrabber sampGrabber = null; - IBaseFilter capFilter = null; - ICaptureGraphBuilder2 capGraph = null; - - // Get the graphbuilder object - m_FilterGraph = (IFilterGraph2) new FilterGraph(); - m_mediaCtrl = m_FilterGraph as IMediaControl; - try - { - // Get the ICaptureGraphBuilder2 - capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); - - // Get the SampleGrabber interface - sampGrabber = (ISampleGrabber) new SampleGrabber(); - - // Start building the graph - hr = capGraph.SetFiltergraph( m_FilterGraph ); - DsError.ThrowExceptionForHR( hr ); - - // Add the video device - hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter); - DsError.ThrowExceptionForHR( hr ); - - // add video crossbar - // thanks to Andrew Fernie - this is to get tv tuner cards working - IAMCrossbar crossbar = null; - object o; - - hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMCrossbar).GUID, out o); - if (hr >= 0) - { - crossbar = (IAMCrossbar)o; - int oPin, iPin; - int ovLink, ivLink; - ovLink = ivLink = 0; - - crossbar.get_PinCounts(out oPin, out iPin); - int pIdxRel; - PhysicalConnectorType tp; - for (int i = 0; i < iPin; i++) - { - crossbar.get_CrossbarPinInfo(true, i, out pIdxRel, out tp); - if (tp == PhysicalConnectorType.Video_Composite) ivLink = i; - } - - for (int i = 0; i < oPin; i++) - { - crossbar.get_CrossbarPinInfo(false, i, out pIdxRel, out tp); - if (tp == PhysicalConnectorType.Video_VideoDecoder) ovLink = i; - } - - try - { - crossbar.Route(ovLink, ivLink); - o = null; - } - - catch - { - throw new Exception("Failed to get IAMCrossbar"); - } - } - - //add AVI Decompressor - IBaseFilter pAVIDecompressor = (IBaseFilter)new AVIDec(); - hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor"); - DsError.ThrowExceptionForHR(hr); - - // - IBaseFilter baseGrabFlt = (IBaseFilter) sampGrabber; - ConfigureSampleGrabber(sampGrabber); - - // Add the frame grabber to the graph - hr = m_FilterGraph.AddFilter( baseGrabFlt, "Ds.NET Grabber" ); - DsError.ThrowExceptionForHR( hr ); - - SetConfigParms(capGraph, capFilter, media); - - hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, pAVIDecompressor, baseGrabFlt); - if (hr < 0) - { - hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt); - } - - DsError.ThrowExceptionForHR( hr ); - - SaveSizeInfo(sampGrabber); - } - finally - { - if (capFilter != null) - { - Marshal.ReleaseComObject(capFilter); - capFilter = null; - } - if (sampGrabber != null) - { - Marshal.ReleaseComObject(sampGrabber); - sampGrabber = null; - } - if (capGraph != null) - { - Marshal.ReleaseComObject(capGraph); - capGraph = null; - } - } - } - - private void SaveSizeInfo(ISampleGrabber sampGrabber) - { - int hr; - - // Get the media type from the SampleGrabber - AMMediaType media = new AMMediaType(); - hr = sampGrabber.GetConnectedMediaType( media ); - DsError.ThrowExceptionForHR( hr ); - - if( (media.formatType != FormatType.VideoInfo) || (media.formatPtr == IntPtr.Zero) ) - { - throw new NotSupportedException( "Unknown Grabber Media Format" ); - } - - // Grab the size info - VideoInfoHeader videoInfoHeader = (VideoInfoHeader) Marshal.PtrToStructure( media.formatPtr, typeof(VideoInfoHeader) ); - m_videoWidth = videoInfoHeader.BmiHeader.Width; - m_videoHeight = videoInfoHeader.BmiHeader.Height; - m_stride = m_videoWidth * (videoInfoHeader.BmiHeader.BitCount / 8); - - DsUtils.FreeAMMediaType(media); - media = null; - } - private void ConfigureSampleGrabber(ISampleGrabber sampGrabber) - { - AMMediaType media; - int hr; - - // Set the media type to Video/RBG24 - media = new AMMediaType(); - media.majorType = MediaType.Video; - media.subType = MediaSubType.RGB24; - media.formatType = FormatType.VideoInfo; - hr = sampGrabber.SetMediaType( media ); - DsError.ThrowExceptionForHR( hr ); - - DsUtils.FreeAMMediaType(media); - media = null; - - // Configure the samplegrabber - hr = sampGrabber.SetCallback( this, 1 ); - DsError.ThrowExceptionForHR( hr ); - } - - // Set the Framerate, and video size - private void SetConfigParms(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, AMMediaType media) - { - int hr; - object o; - - // Find the stream config interface - hr = capGraph.FindInterface( - PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o ); - - IAMStreamConfig videoStreamConfig = o as IAMStreamConfig; - if (videoStreamConfig == null) - { - throw new Exception("Failed to get IAMStreamConfig"); - } - - // Set the new format - hr = videoStreamConfig.SetFormat( media ); - DsError.ThrowExceptionForHR( hr ); - - DsUtils.FreeAMMediaType(media); - media = null; - } - - /// Shut down capture - private void CloseInterfaces() - { - int hr; - - try - { - if( m_mediaCtrl != null ) - { - // Stop the graph - hr = m_mediaCtrl.Stop(); - m_bRunning = false; - } - } - catch (Exception ex) - { - Debug.WriteLine(ex); - } - - if (m_FilterGraph != null) - { - Marshal.ReleaseComObject(m_FilterGraph); - m_FilterGraph = null; - } - } - - /// sample callback, NOT USED. - int ISampleGrabberCB.SampleCB( double SampleTime, IMediaSample pSample ) - { - if (!m_bGotOne) - { - // Set bGotOne to prevent further calls until we - // request a new bitmap. - m_bGotOne = true; - IntPtr pBuffer; - - pSample.GetPointer(out pBuffer); - int iBufferLen = pSample.GetSize(); - - if (pSample.GetSize() > m_stride * m_videoHeight) - { - throw new Exception("Buffer is wrong size"); - } - - CopyMemory(m_handle, pBuffer, m_stride * m_videoHeight); - - // Picture is ready. - m_PictureReady.Set(); - } - - Marshal.ReleaseComObject(pSample); - return 0; - } - - /// buffer callback, COULD BE FROM FOREIGN THREAD. - int ISampleGrabberCB.BufferCB( double SampleTime, IntPtr pBuffer, int BufferLen ) - { - if (!m_bGotOne) - { - // The buffer should be long enought - if(BufferLen <= m_stride * m_videoHeight) - { - // Copy the frame to the buffer - CopyMemory(m_handle, pBuffer, m_stride * m_videoHeight); - } - else - { - throw new Exception("Buffer is wrong size"); - } - - // Set bGotOne to prevent further calls until we - // request a new bitmap. - m_bGotOne = true; - - // Picture is ready. - m_PictureReady.Set(); - } - else - { - m_Dropped++; - } - return 0; - } - } -} +/**************************************************************************** +While the underlying libraries are covered by LGPL, this sample is released +as public domain. It is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. +*****************************************************************************/ + +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.Collections; +using System.Runtime.InteropServices; +using System.Threading; +using System.Diagnostics; +using System.Collections.Generic; + +using DirectShowLib; + + +namespace WebCamService +{ + public delegate void CamImage(Image camimage); + + /// Summary description for MainForm. + public class Capture : ISampleGrabberCB, IDisposable + { + #region Member variables + + /// graph builder interface. + private IFilterGraph2 m_FilterGraph = null; + private IMediaControl m_mediaCtrl = null; + + /// so we can wait for the async job to finish + private ManualResetEvent m_PictureReady = null; + + /// Set by async routine when it captures an image + private volatile bool m_bGotOne = false; + + /// Indicates the status of the graph + private bool m_bRunning = false; + + /// Dimensions of the image, calculated once in constructor. + private IntPtr m_handle = IntPtr.Zero; + private int m_videoWidth; + private int m_videoHeight; + private int m_stride; + public int m_Dropped = 0; + + public Image image = null; + IntPtr ip = IntPtr.Zero; + + public event CamImage camimage; + System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); + + #endregion + + #region API + + [DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory")] + private static extern void CopyMemory(IntPtr Destination, IntPtr Source, int Length); + + #endregion + + public Capture() + { + } + + /// Use capture with selected media caps + public Capture(int iDeviceNum, AMMediaType media) + { + DsDevice[] capDevices; + + // Get the collection of video devices + capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); + + if (iDeviceNum + 1 > capDevices.Length) + { + throw new Exception("No video capture devices found at that index!"); + } + + try + { + // Set up the capture graph + SetupGraph(capDevices[iDeviceNum], media); + + // tell the callback to ignore new images + m_PictureReady = new ManualResetEvent(false); + m_bGotOne = true; + m_bRunning = false; + + timer1.Interval = 1000 / 15; // 15 fps + timer1.Tick += new EventHandler(timer1_Tick); + timer1.Start(); + + } + catch + { + Dispose(); + throw; + } + } + /// release everything. + public void Dispose() + { + timer1.Stop(); + if (camimage != null) + { + camimage(null); // clear last pic + } + CloseInterfaces(); + if (m_PictureReady != null) + { + m_PictureReady.Close(); + m_PictureReady = null; + } + } + // Destructor + ~Capture() + { + Dispose(); + } + + public int Width + { + get + { + return m_videoWidth; + } + } + public int Height + { + get + { + return m_videoHeight; + } + } + public int Stride + { + get + { + return m_stride; + } + } + /// capture the next image + public IntPtr GetBitMap() + { + if (m_handle == IntPtr.Zero) + m_handle = Marshal.AllocCoTaskMem(m_stride * m_videoHeight); + + try + { + // get ready to wait for new image + m_PictureReady.Reset(); + m_bGotOne = false; + + // If the graph hasn't been started, start it. + Start(); + + // Start waiting + if ( ! m_PictureReady.WaitOne(5000, false) ) + { + throw new Exception("Timeout waiting to get picture"); + } + //Pause(); //- we are effectivly pulling at 15 fps, so no need to pause + } + catch + { + Marshal.FreeCoTaskMem(m_handle); + throw; + } + + // Got one + return m_handle; + } + // Start the capture graph + public void Start() + { + if (!m_bRunning) + { + int hr = m_mediaCtrl.Run(); + DsError.ThrowExceptionForHR( hr ); + + m_bRunning = true; + } + } + // Pause the capture graph. + // Running the graph takes up a lot of resources. Pause it when it + // isn't needed. + public void Pause() + { + if (m_bRunning) + { + int hr = m_mediaCtrl.Pause(); + DsError.ThrowExceptionForHR( hr ); + + m_bRunning = false; + } + } + + public static List getDevices() + { + List list = new List(); + DsDevice[] capDevices; + + // Get the collection of video devices + capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); + + foreach (DsDevice dev in capDevices) + { + list.Add(dev.Name); + } + + return list; + } + + public bool showhud = true; + + void timer1_Tick(object sender, EventArgs e) + { + try + { + ip = this.GetBitMap(); + image = new Bitmap(this.Width, this.Height, this.Stride, PixelFormat.Format24bppRgb, ip); + image.RotateFlip(RotateFlipType.RotateNoneFlipY); + if (camimage != null) + { + camimage(image); + } + } + catch { Console.WriteLine("Grab bmp failed"); timer1.Enabled = false; this.CloseInterfaces(); System.Windows.Forms.CustomMessageBox.Show("Problem with capture device, grabbing frame took longer than 5 sec"); } + } + + /// build the capture graph for grabber. + private void SetupGraph(DsDevice dev, AMMediaType media) + { + int hr; + + ISampleGrabber sampGrabber = null; + IBaseFilter capFilter = null; + ICaptureGraphBuilder2 capGraph = null; + + // Get the graphbuilder object + m_FilterGraph = (IFilterGraph2) new FilterGraph(); + m_mediaCtrl = m_FilterGraph as IMediaControl; + try + { + // Get the ICaptureGraphBuilder2 + capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); + + // Get the SampleGrabber interface + sampGrabber = (ISampleGrabber) new SampleGrabber(); + + // Start building the graph + hr = capGraph.SetFiltergraph( m_FilterGraph ); + DsError.ThrowExceptionForHR( hr ); + + // Add the video device + hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter); + DsError.ThrowExceptionForHR( hr ); + + // add video crossbar + // thanks to Andrew Fernie - this is to get tv tuner cards working + IAMCrossbar crossbar = null; + object o; + + hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMCrossbar).GUID, out o); + if (hr >= 0) + { + crossbar = (IAMCrossbar)o; + int oPin, iPin; + int ovLink, ivLink; + ovLink = ivLink = 0; + + crossbar.get_PinCounts(out oPin, out iPin); + int pIdxRel; + PhysicalConnectorType tp; + for (int i = 0; i < iPin; i++) + { + crossbar.get_CrossbarPinInfo(true, i, out pIdxRel, out tp); + if (tp == PhysicalConnectorType.Video_Composite) ivLink = i; + } + + for (int i = 0; i < oPin; i++) + { + crossbar.get_CrossbarPinInfo(false, i, out pIdxRel, out tp); + if (tp == PhysicalConnectorType.Video_VideoDecoder) ovLink = i; + } + + try + { + crossbar.Route(ovLink, ivLink); + o = null; + } + + catch + { + throw new Exception("Failed to get IAMCrossbar"); + } + } + + //add AVI Decompressor + IBaseFilter pAVIDecompressor = (IBaseFilter)new AVIDec(); + hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor"); + DsError.ThrowExceptionForHR(hr); + + // + IBaseFilter baseGrabFlt = (IBaseFilter) sampGrabber; + ConfigureSampleGrabber(sampGrabber); + + // Add the frame grabber to the graph + hr = m_FilterGraph.AddFilter( baseGrabFlt, "Ds.NET Grabber" ); + DsError.ThrowExceptionForHR( hr ); + + SetConfigParms(capGraph, capFilter, media); + + hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, pAVIDecompressor, baseGrabFlt); + if (hr < 0) + { + hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt); + } + + DsError.ThrowExceptionForHR( hr ); + + SaveSizeInfo(sampGrabber); + } + finally + { + if (capFilter != null) + { + Marshal.ReleaseComObject(capFilter); + capFilter = null; + } + if (sampGrabber != null) + { + Marshal.ReleaseComObject(sampGrabber); + sampGrabber = null; + } + if (capGraph != null) + { + Marshal.ReleaseComObject(capGraph); + capGraph = null; + } + } + } + + private void SaveSizeInfo(ISampleGrabber sampGrabber) + { + int hr; + + // Get the media type from the SampleGrabber + AMMediaType media = new AMMediaType(); + hr = sampGrabber.GetConnectedMediaType( media ); + DsError.ThrowExceptionForHR( hr ); + + if( (media.formatType != FormatType.VideoInfo) || (media.formatPtr == IntPtr.Zero) ) + { + throw new NotSupportedException( "Unknown Grabber Media Format" ); + } + + // Grab the size info + VideoInfoHeader videoInfoHeader = (VideoInfoHeader) Marshal.PtrToStructure( media.formatPtr, typeof(VideoInfoHeader) ); + m_videoWidth = videoInfoHeader.BmiHeader.Width; + m_videoHeight = videoInfoHeader.BmiHeader.Height; + m_stride = m_videoWidth * (videoInfoHeader.BmiHeader.BitCount / 8); + + DsUtils.FreeAMMediaType(media); + media = null; + } + private void ConfigureSampleGrabber(ISampleGrabber sampGrabber) + { + AMMediaType media; + int hr; + + // Set the media type to Video/RBG24 + media = new AMMediaType(); + media.majorType = MediaType.Video; + media.subType = MediaSubType.RGB24; + media.formatType = FormatType.VideoInfo; + hr = sampGrabber.SetMediaType( media ); + DsError.ThrowExceptionForHR( hr ); + + DsUtils.FreeAMMediaType(media); + media = null; + + // Configure the samplegrabber + hr = sampGrabber.SetCallback( this, 1 ); + DsError.ThrowExceptionForHR( hr ); + } + + // Set the Framerate, and video size + private void SetConfigParms(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, AMMediaType media) + { + int hr; + object o; + + // Find the stream config interface + hr = capGraph.FindInterface( + PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o ); + + IAMStreamConfig videoStreamConfig = o as IAMStreamConfig; + if (videoStreamConfig == null) + { + throw new Exception("Failed to get IAMStreamConfig"); + } + + // Set the new format + hr = videoStreamConfig.SetFormat( media ); + DsError.ThrowExceptionForHR( hr ); + + DsUtils.FreeAMMediaType(media); + media = null; + } + + /// Shut down capture + private void CloseInterfaces() + { + int hr; + + try + { + if( m_mediaCtrl != null ) + { + // Stop the graph + hr = m_mediaCtrl.Stop(); + m_bRunning = false; + } + } + catch (Exception ex) + { + Debug.WriteLine(ex); + } + + if (m_FilterGraph != null) + { + Marshal.ReleaseComObject(m_FilterGraph); + m_FilterGraph = null; + } + } + + /// sample callback, NOT USED. + int ISampleGrabberCB.SampleCB( double SampleTime, IMediaSample pSample ) + { + if (!m_bGotOne) + { + // Set bGotOne to prevent further calls until we + // request a new bitmap. + m_bGotOne = true; + IntPtr pBuffer; + + pSample.GetPointer(out pBuffer); + int iBufferLen = pSample.GetSize(); + + if (pSample.GetSize() > m_stride * m_videoHeight) + { + throw new Exception("Buffer is wrong size"); + } + + CopyMemory(m_handle, pBuffer, m_stride * m_videoHeight); + + // Picture is ready. + m_PictureReady.Set(); + } + + Marshal.ReleaseComObject(pSample); + return 0; + } + + /// buffer callback, COULD BE FROM FOREIGN THREAD. + int ISampleGrabberCB.BufferCB( double SampleTime, IntPtr pBuffer, int BufferLen ) + { + if (!m_bGotOne) + { + // The buffer should be long enought + if(BufferLen <= m_stride * m_videoHeight) + { + // Copy the frame to the buffer + CopyMemory(m_handle, pBuffer, m_stride * m_videoHeight); + } + else + { + throw new Exception("Buffer is wrong size"); + } + + // Set bGotOne to prevent further calls until we + // request a new bitmap. + m_bGotOne = true; + + // Picture is ready. + m_PictureReady.Set(); + } + else + { + m_Dropped++; + } + return 0; + } + } +} diff --git a/Tools/ArdupilotMegaPlanner/Utilities/EnumTranslator.cs b/Tools/ArdupilotMegaPlanner/Utilities/EnumTranslator.cs index e1901aadf1..3f4b4cb3ae 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/EnumTranslator.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/EnumTranslator.cs @@ -115,6 +115,19 @@ namespace ArdupilotMega.Utilities return displayText; } + public static int GetValue(string item) + { + var list = Translate(); + + foreach (var kvp in list) + { + if (kvp.Value == item) + return kvp.Key; + } + + return -1; + } + } } diff --git a/Tools/ArdupilotMegaPlanner/LangUtility.cs b/Tools/ArdupilotMegaPlanner/Utilities/LangUtility.cs similarity index 98% rename from Tools/ArdupilotMegaPlanner/LangUtility.cs rename to Tools/ArdupilotMegaPlanner/Utilities/LangUtility.cs index 9fa34a9f7f..aa0293cf30 100644 --- a/Tools/ArdupilotMegaPlanner/LangUtility.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/LangUtility.cs @@ -8,7 +8,7 @@ using System.Globalization; using System.ComponentModel; using System.Windows.Forms; -namespace ArdupilotMega +namespace ArdupilotMega.Utilities { static class CultureInfoEx { diff --git a/Tools/ArdupilotMegaPlanner/Constants/ParameterMetaDataConstants.cs b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataConstants.cs similarity index 90% rename from Tools/ArdupilotMegaPlanner/Constants/ParameterMetaDataConstants.cs rename to Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataConstants.cs index 73a226920b..7f189aa066 100644 --- a/Tools/ArdupilotMegaPlanner/Constants/ParameterMetaDataConstants.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataConstants.cs @@ -1,4 +1,4 @@ -namespace ArdupilotMega.Constants +namespace ArdupilotMega.Utilities { public sealed class ParameterMetaDataConstants { diff --git a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs index a737da4f53..2c3d2c0e13 100644 --- a/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ParameterMetaDataParser.cs @@ -7,7 +7,6 @@ using System.Net; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Xml; -using ArdupilotMega.Constants; using log4net; namespace ArdupilotMega.Utilities diff --git a/Tools/ArdupilotMegaPlanner/Speech.cs b/Tools/ArdupilotMegaPlanner/Utilities/Speech.cs similarity index 98% rename from Tools/ArdupilotMegaPlanner/Speech.cs rename to Tools/ArdupilotMegaPlanner/Utilities/Speech.cs index 0da3155cae..cbe9de6515 100644 --- a/Tools/ArdupilotMegaPlanner/Speech.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/Speech.cs @@ -5,7 +5,7 @@ using System.Text; using System.Speech.Synthesis; using log4net; -namespace ArdupilotMega +namespace ArdupilotMega.Utilities { public class Speech { diff --git a/Tools/ArdupilotMegaPlanner/TCPConsole.cs b/Tools/ArdupilotMegaPlanner/Utilities/TCPConsole.cs similarity index 98% rename from Tools/ArdupilotMegaPlanner/TCPConsole.cs rename to Tools/ArdupilotMegaPlanner/Utilities/TCPConsole.cs index 1a69413a40..20e9012a01 100644 --- a/Tools/ArdupilotMegaPlanner/TCPConsole.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/TCPConsole.cs @@ -5,7 +5,7 @@ using System.Text; using System.Net; using System.Net.Sockets; -namespace ArdupilotMega +namespace ArdupilotMega.Utilities { static class TCPConsole { diff --git a/Tools/ArdupilotMegaPlanner/ThemeManager.cs b/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs similarity index 99% rename from Tools/ArdupilotMegaPlanner/ThemeManager.cs rename to Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs index c15b74ec62..0d89857727 100644 --- a/Tools/ArdupilotMegaPlanner/ThemeManager.cs +++ b/Tools/ArdupilotMegaPlanner/Utilities/ThemeManager.cs @@ -5,7 +5,7 @@ using ArdupilotMega.Controls.BackstageView; using log4net; using ArdupilotMega.Controls; -namespace ArdupilotMega +namespace ArdupilotMega.Utilities { /// /// Helper class for the stylng 'theming' of forms and controls, and provides MessageBox diff --git a/Tools/ArdupilotMegaPlanner/hires.cs b/Tools/ArdupilotMegaPlanner/Utilities/hires.cs similarity index 100% rename from Tools/ArdupilotMegaPlanner/hires.cs rename to Tools/ArdupilotMegaPlanner/Utilities/hires.cs diff --git a/Tools/ArdupilotMegaPlanner/app.config b/Tools/ArdupilotMegaPlanner/app.config index 92d311e0c0..063dfdef78 100644 --- a/Tools/ArdupilotMegaPlanner/app.config +++ b/Tools/ArdupilotMegaPlanner/app.config @@ -8,10 +8,6 @@ - - diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/ArduCopterConfig.xml b/Tools/ArdupilotMegaPlanner/bin/Release/ArduCopterConfig.xml index e90fae40cf..2558e46e2c 100644 --- a/Tools/ArdupilotMegaPlanner/bin/Release/ArduCopterConfig.xml +++ b/Tools/ArdupilotMegaPlanner/bin/Release/ArduCopterConfig.xml @@ -56,14 +56,14 @@ When the sticks are fully deflected: Dampen STAB_D - 0.001 + 0 5 0.001 Dynamic STAB_D_S - 0.001 + 0 1 0.001 @@ -201,5 +201,87 @@ A distance error of 100cm * P of .25 = 25 cm/s 0.1 + WP Speed: + + How fast the copter should move towards the target. A larger value means a faster return to center, but can cause the copter to oscillate around the target. + + in m/s + + + + Speed + WP_SPEED_MAX + 1 + 30 + 1 + + + + + + Altitude Hold: + Altitude Error: + + How fast the copter should go to reach the correct altitude. + + + + P + THR_ALT_P + 0.001 + 5 + 0.001 + + + I + THR_ALT_I + 0 + 5 + 0.001 + + + IMAX + THR_ALT_IMAX + 0 + 50 + 0.1 + + + Thrust Rate: + + How much thrust to give us the desired rate. + + This will change depending on the weight and thrust of your copter. + + + + P + THR_RATE_P + 0.001 + 5 + 0.001 + + + I + THR_RATE_I + 0 + 5 + 0.001 + + + D + THR_RATE_D + 0 + 5 + 0.001 + + + IMAX + THR_RATE_IMAX + 0 + 50 + 0.1 + + diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb index b4768625fb..e0a3a65d92 100644 Binary files a/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb and b/Tools/ArdupilotMegaPlanner/bin/Release/ArdupilotMegaPlanner.pdb differ diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/version.txt b/Tools/ArdupilotMegaPlanner/bin/Release/version.txt index 0b1ae78e9c..cf279dbac7 100644 --- a/Tools/ArdupilotMegaPlanner/bin/Release/version.txt +++ b/Tools/ArdupilotMegaPlanner/bin/Release/version.txt @@ -1 +1 @@ -1.1.4494.38818 \ No newline at end of file +1.1.4498.32482 \ No newline at end of file diff --git a/Tools/ArdupilotMegaPlanner/temp.cs b/Tools/ArdupilotMegaPlanner/temp.cs index 28e7bb4dc2..18c528c433 100644 --- a/Tools/ArdupilotMegaPlanner/temp.cs +++ b/Tools/ArdupilotMegaPlanner/temp.cs @@ -17,6 +17,7 @@ using log4net; using System.Security.Permissions; using ArdupilotMega.Arduino; +using ArdupilotMega.Utilities; namespace ArdupilotMega {