From a0b3966f09f05dc834f05c339b0209e117c61f0d Mon Sep 17 00:00:00 2001 From: Michael Oborne <mich146@hotmail.com> Date: Thu, 3 May 2012 21:13:28 +0800 Subject: [PATCH] APM Planner 1.1.79 modify hud modify apm1 vs apm2 detector --- .../Arduino/ArduinoDetect.cs | 24 +++++++++-- Tools/ArdupilotMegaPlanner/Controls/HUD.cs | 43 ++++++++++++------- .../ArdupilotMegaPlanner/GCSViews/Firmware.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../bin/Release/version.txt | 2 +- 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs b/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs index b5a62da0d..76f0a6d57 100644 --- a/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs +++ b/Tools/ArdupilotMegaPlanner/Arduino/ArduinoDetect.cs @@ -49,6 +49,7 @@ namespace ArdupilotMega.Arduino if (b1 == 0x14 && b2 == 0x10) { serialPort.Close(); + log.Info("is a 1280"); return "1280"; } } @@ -79,7 +80,7 @@ namespace ArdupilotMega.Arduino if (temp[0] == 6 && temp[1] == 0 && temp.Length == 2) { serialPort.Close(); - + log.Info("is a 2560"); return "2560"; } @@ -130,6 +131,7 @@ namespace ArdupilotMega.Arduino if (b1 == 0x14 && b2 == 0x10) { serialPort.Close(); + log.Info("is a 1280"); return "1280"; } } @@ -163,7 +165,7 @@ namespace ArdupilotMega.Arduino //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_2341&PID_0010\640333439373519060F0\Device Parameters if (!MainV2.MONO && !Thread.CurrentThread.CurrentUICulture.IsChildOf(CultureInfoEx.GetCultureInfo("zh-Hans"))) { - ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_USBControllerDevice"); + ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_SerialPort"); // Win32_USBControllerDevice ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); foreach (ManagementObject obj2 in searcher.Get()) { @@ -171,12 +173,28 @@ namespace ArdupilotMega.Arduino // all apm 1-1.4 use a ftdi on the imu board. - if (obj2["Dependent"].ToString().Contains(@"USB\\VID_2341&PID_0010")) + obj2.Properties.ForEach(x => + { + try + { + log.Info(((PropertyData)x).Name.ToString() + " = " + ((PropertyData)x).Value.ToString()); + } + catch { } + }); + + // check vid and pid + if (obj2.Properties["PNPDeviceID"].Value.ToString().Contains(@"USB\VID_2341&PID_0010")) { + // check port name as well + if (obj2.Properties["Name"].Value.ToString().ToUpper().Contains(serialPort.PortName.ToUpper())) + { + log.Info("is a 2560-2"); return "2560-2"; + } } } + log.Info("is a 2560"); return "2560"; } else diff --git a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs index da4faef1e..57df0acbd 100644 --- a/Tools/ArdupilotMegaPlanner/Controls/HUD.cs +++ b/Tools/ArdupilotMegaPlanner/Controls/HUD.cs @@ -736,7 +736,7 @@ namespace ArdupilotMega.Controls int fontsize = this.Height / 30; // = 10 int fontoffset = fontsize - 10; - float every5deg = -this.Height / 60; + float every5deg = -this.Height / 65; float pitchoffset = -_pitch * every5deg; @@ -842,20 +842,20 @@ namespace ArdupilotMega.Controls // draw roll ind needle - graphicsObject.TranslateTransform(this.Width / 2, this.Height / 2 + this.Height / 14); - - // graphicsObject.RotateTransform(_roll); - + graphicsObject.TranslateTransform(this.Width / 2, this.Height / 2); + Point[] pointlist = new Point[3]; lengthlong = this.Height / 66; - int extra = this.Height / 15 * 7; + int extra = (int)(this.Height / 15 * 4.9f); pointlist[0] = new Point(0, -lengthlong * 2 - extra); pointlist[1] = new Point(-lengthlong, -lengthlong - extra); pointlist[2] = new Point(lengthlong, -lengthlong - extra); + redPen.Width = 4; + if (Math.Abs(_roll) > 45) { redPen.Width = 10; @@ -870,19 +870,23 @@ namespace ArdupilotMega.Controls foreach (int a in array) { graphicsObject.ResetTransform(); - graphicsObject.TranslateTransform(this.Width / 2, this.Height / 2 + this.Height / 14); + graphicsObject.TranslateTransform(this.Width / 2, this.Height / 2); graphicsObject.RotateTransform(a - _roll); - drawstring(graphicsObject, Math.Abs(a).ToString("##"), font, fontsize, whiteBrush, 0 - 6 - fontoffset, -lengthlong * 2 - extra); - graphicsObject.DrawLine(whitePen, 0, -halfheight, 0, -halfheight - 10); + drawstring(graphicsObject, Math.Abs(a).ToString("0").PadLeft(2), font, fontsize, whiteBrush, 0 - 6 - fontoffset, -lengthlong * 8 - extra); + graphicsObject.DrawLine(whitePen, 0, -lengthlong * 3 - extra, 0, -lengthlong * 3 - extra - lengthlong); } graphicsObject.ResetTransform(); + graphicsObject.TranslateTransform(this.Width / 2, this.Height / 2); // draw roll ind + RectangleF arcrect = new RectangleF(-lengthlong * 3 - extra, -lengthlong * 3 - extra, (extra + lengthlong * 3) * 2f, (extra + lengthlong * 3) * 2f); - Rectangle arcrect = new Rectangle(this.Width / 2 - this.Height / 2, this.Height / 14, this.Height, this.Height); + //DrawRectangle(Pens.Beige, arcrect); - graphicsObject.DrawArc(whitePen, arcrect, 180 + 30 + -_roll, 120); + graphicsObject.DrawArc(whitePen, arcrect, 180 + 30 + -_roll, 120); // 120 + + graphicsObject.ResetTransform(); //draw centre / current att @@ -912,7 +916,7 @@ namespace ArdupilotMega.Controls graphicsObject.FillRectangle(solidBrush, headbg); // center - graphicsObject.DrawLine(redPen, headbg.Width / 2, headbg.Bottom, headbg.Width / 2, headbg.Top); + // graphicsObject.DrawLine(redPen, headbg.Width / 2, headbg.Bottom, headbg.Width / 2, headbg.Top); //bottom line graphicsObject.DrawLine(whitePen, headbg.Left + 5, headbg.Bottom - 5, headbg.Width - 5, headbg.Bottom - 5); @@ -984,13 +988,20 @@ namespace ArdupilotMega.Controls } } - RectangleF rect = new RectangleF(headbg.Width / 2 - fontoffset - fontoffset, 0, fontoffset * 4, (int)(fontoffset * 1.7) + 24); + RectangleF rect = new RectangleF(headbg.Width / 2 - (fontsize * 2.4f) / 2, 0, (fontsize * 2.4f), headbg.Height); - DrawRectangle(whitePen, rect); + //DrawRectangle(whitePen, rect); - FillRectangle(Brushes.Black, rect); + FillRectangle(new SolidBrush(Color.FromArgb(220,255,255,255)), rect); - drawstring(graphicsObject, (heading % 360).ToString("0").PadLeft(3), font, fontsize, whiteBrush, headbg.Width / 2 - fontoffset - fontoffset, headbg.Bottom - 24 - (int)(fontoffset * 1.7)); + if (Math.Abs(_heading - _targetheading) < 4) + { + drawstring(graphicsObject, (heading % 360).ToString("0").PadLeft(3), font, fontsize, Brushes.Green, headbg.Width / 2 - (fontsize * 1f), headbg.Bottom - 24 - (int)(fontoffset * 1.7)); + } + else + { + drawstring(graphicsObject, (heading % 360).ToString("0").PadLeft(3), font, fontsize, Brushes.Red, headbg.Width / 2 - (fontsize * 1f), headbg.Bottom - 24 - (int)(fontoffset * 1.7)); + } // Console.WriteLine("HUD 0 " + (DateTime.Now - starttime).TotalMilliseconds + " " + DateTime.Now.Millisecond); diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs index fe1c616f3..81f1f291b 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/Firmware.cs @@ -455,7 +455,7 @@ namespace ArdupilotMega.GCSViews if (port.connectAP()) { log.Info("starting"); - lbl_status.Text = "Uploading " + FLASH.Length + " bytes to APM"; + lbl_status.Text = "Uploading " + FLASH.Length + " bytes to APM Board: "+board; progress.Value = 0; this.Refresh(); diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 7f5cef621..55c948c3a 100644 --- a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs +++ b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ using System.Resources; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.1.*")] -[assembly: AssemblyFileVersion("1.1.78")] +[assembly: AssemblyFileVersion("1.1.79")] [assembly: NeutralResourcesLanguageAttribute("")] diff --git a/Tools/ArdupilotMegaPlanner/bin/Release/version.txt b/Tools/ArdupilotMegaPlanner/bin/Release/version.txt index 6162c5a63..b0dfd7c8e 100644 --- a/Tools/ArdupilotMegaPlanner/bin/Release/version.txt +++ b/Tools/ArdupilotMegaPlanner/bin/Release/version.txt @@ -1 +1 @@ -1.1.4506.13406 \ No newline at end of file +1.1.4506.37964 \ No newline at end of file -- GitLab