From 28f86f898707aa08c60b3677cffa698824c9a784 Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Mon, 19 Sep 2011 07:42:22 +0800 Subject: [PATCH] APM Planner - 1.0.72 fix hud issues --- .../ArdupilotMegaPlanner/ArdupilotMega.csproj | 2 +- .../GCSViews/FlightData.cs | 6 ++++ Tools/ArdupilotMegaPlanner/HUD.cs | 28 ++++++++++++++---- Tools/ArdupilotMegaPlanner/MainV2.cs | 29 +++++++------------ .../Properties/AssemblyInfo.cs | 2 +- 5 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj index 02429fd7d4..85c3af5249 100644 --- a/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj +++ b/Tools/ArdupilotMegaPlanner/ArdupilotMega.csproj @@ -145,7 +145,7 @@ False ..\..\..\..\..\..\..\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.DirectInput.dll - True + False False diff --git a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs index 77bae958ef..b36e0f2679 100644 --- a/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs +++ b/Tools/ArdupilotMegaPlanner/GCSViews/FlightData.cs @@ -247,6 +247,8 @@ namespace ArdupilotMega.GCSViews if (MainV2.comPort.logreadmode && MainV2.comPort.logplaybackfile != null) { + BUT_playlog.Text = "Pause"; + if (comPort.BaseStream.IsOpen) MainV2.comPort.logreadmode = false; @@ -287,6 +289,10 @@ namespace ArdupilotMega.GCSViews MainV2.comPort.logreadmode = false; } } + else + { + BUT_playlog.Text = "Play"; + } try { diff --git a/Tools/ArdupilotMegaPlanner/HUD.cs b/Tools/ArdupilotMegaPlanner/HUD.cs index 416d131619..3045f85a21 100644 --- a/Tools/ArdupilotMegaPlanner/HUD.cs +++ b/Tools/ArdupilotMegaPlanner/HUD.cs @@ -49,6 +49,7 @@ namespace hud InitializeComponent(); graphicsObject = this; + graphicsObjectGDIP = Graphics.FromImage(objBitmap); } private void InitializeComponent() @@ -136,8 +137,7 @@ namespace hud public bool bgon = true; public bool hudon = true; - [System.ComponentModel.Browsable(true), -System.ComponentModel.Category("Values")] + [System.ComponentModel.Browsable(true), System.ComponentModel.Category("Values")] public Color hudcolor { get { return whitePen.Color; } set { whitePen = new Pen(value, 2); } } Pen whitePen = new Pen(Color.White, 2); @@ -261,10 +261,15 @@ System.ComponentModel.Category("Values")] huddrawtime += (int)(DateTime.Now - starttime).TotalMilliseconds; + if (huddrawtime > 500) + { + opengl = false; + } + if (DateTime.Now.Second != countdate.Second) { countdate = DateTime.Now; - Console.WriteLine("HUD " + count + " hz drawtime " + (huddrawtime / count)); + Console.WriteLine("HUD " + count + " hz drawtime " + (huddrawtime / count) + " gl " + opengl); count = 0; huddrawtime = 0; } @@ -624,11 +629,22 @@ System.ComponentModel.Category("Values")] void doPaint(PaintEventArgs e) { - graphicsObjectGDIP = Graphics.FromImage(objBitmap); - graphicsObjectGDIP.SmoothingMode = SmoothingMode.AntiAlias; - try { + if (graphicsObjectGDIP == null || !opengl && (objBitmap.Width != this.Width || objBitmap.Height != this.Height)) + { + objBitmap = new Bitmap(this.Width, this.Height); + graphicsObjectGDIP = Graphics.FromImage(objBitmap); + + graphicsObjectGDIP.SmoothingMode = SmoothingMode.AntiAlias; + graphicsObjectGDIP.InterpolationMode = InterpolationMode.NearestNeighbor; + graphicsObjectGDIP.CompositingMode = CompositingMode.SourceOver; + graphicsObjectGDIP.CompositingQuality = CompositingQuality.HighSpeed; + graphicsObjectGDIP.PixelOffsetMode = PixelOffsetMode.HighSpeed; + graphicsObjectGDIP.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; + } + + graphicsObject.Clear(Color.Gray); if (_bgimage != null) diff --git a/Tools/ArdupilotMegaPlanner/MainV2.cs b/Tools/ArdupilotMegaPlanner/MainV2.cs index 5175a7d52f..f526e29c77 100644 --- a/Tools/ArdupilotMegaPlanner/MainV2.cs +++ b/Tools/ArdupilotMegaPlanner/MainV2.cs @@ -161,20 +161,6 @@ namespace ArdupilotMega } catch (Exception e) { MessageBox.Show("A Major error has occured : " + e.ToString()); this.Close(); } - Console.WriteLine("check hud"); - - GCSViews.FlightData.myhud.Refresh(); - GCSViews.FlightData.myhud.Refresh(); - GCSViews.FlightData.myhud.Refresh(); - - if (GCSViews.FlightData.myhud.huddrawtime > 1000) - { - MessageBox.Show("The HUD draw time is above 1 seconds. Please update your graphics card driver."); - GCSViews.FlightData.myhud.opengl = false; - } - - Console.WriteLine("check hud done"); - changeunits(); try @@ -1370,27 +1356,34 @@ namespace ArdupilotMega } if (loadinglabel != null) loadinglabel.Text = "Checking " + file; + + string path = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + subdir + file; + + // Create a request using a URL that can receive a post. request = WebRequest.Create(baseurl + file); Console.Write(baseurl + file + " "); // Set the Method property of the request to POST. request.Method = "HEAD"; + + ((HttpWebRequest)request).IfModifiedSince = File.GetLastWriteTimeUtc(path); + // Get the response. response = request.GetResponse(); // Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. - dataStream = response.GetResponseStream(); + //dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. - string path = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + subdir + file; - bool getfile = false; if (File.Exists(path)) { FileInfo fi = new FileInfo(path); + Console.WriteLine(response.Headers[HttpResponseHeader.ETag]); + if (fi.Length != response.ContentLength) // && response.Headers[HttpResponseHeader.ETag] != "0") { StreamWriter sw = new StreamWriter(path+".etag"); @@ -1408,7 +1401,7 @@ namespace ArdupilotMega } reader.Close(); - dataStream.Close(); + //dataStream.Close(); response.Close(); if (getfile) diff --git a/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs b/Tools/ArdupilotMegaPlanner/Properties/AssemblyInfo.cs index 652a00b471..7c14b2205e 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.0.0.0")] -[assembly: AssemblyFileVersion("1.0.71")] +[assembly: AssemblyFileVersion("1.0.72")] [assembly: NeutralResourcesLanguageAttribute("")]