# HG changeset patch # User sl # Date 1405022609 -7200 # Node ID f37c5ff8af18c970392e351f764e3f89919d6862 # Parent de55741d90f0fda6cb5974a98ffb18c708880245 Power supply status, device id and firmware revision queries are now working. diff -r de55741d90f0 -r f37c5ff8af18 Display.cs --- a/Display.cs Wed Jul 09 11:06:46 2014 +0200 +++ b/Display.cs Thu Jul 10 22:03:29 2014 +0200 @@ -85,6 +85,43 @@ MiniDisplaySetPixel(iDevice,aX,aY,aValue); } + public void RequestPowerSupplyStatus() + { + MiniDisplayRequestPowerSupplyStatus(iDevice); + } + + public void RequestDeviceId() + { + MiniDisplayRequestDeviceId(iDevice); + } + + public void RequestFirmwareRevision() + { + MiniDisplayRequestFirmwareRevision(iDevice); + } + + public bool PowerSupplyStatus() + { + bool res = MiniDisplayPowerSupplyStatus(iDevice); + return res; + } + + public TMiniDisplayRequest AttemptRequestCompletion() + { + return MiniDisplayAttemptRequestCompletion(iDevice); + } + + public TMiniDisplayRequest CurrentRequest() + { + return MiniDisplayCurrentRequest(iDevice); + } + + public bool IsRequestPending() + { + return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone; + } + + public string Vendor() { IntPtr ptr = MiniDisplayVendor(iDevice); @@ -106,6 +143,20 @@ return str; } + public string DeviceId() + { + IntPtr ptr = MiniDisplayDeviceId(iDevice); + string str = Marshal.PtrToStringAnsi(ptr); + return str; + } + + public string FirmwareRevision() + { + IntPtr ptr = MiniDisplayFirmwareRevision(iDevice); + string str = Marshal.PtrToStringAnsi(ptr); + return str; + } + //Our display device handle IntPtr iDevice; @@ -166,6 +217,7 @@ public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice); [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice); [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] @@ -187,9 +239,5 @@ public static extern void MiniDisplayCancelRequest(IntPtr aDevice); - - - - } } diff -r de55741d90f0 -r f37c5ff8af18 MainForm.Designer.cs --- a/MainForm.Designer.cs Wed Jul 09 11:06:46 2014 +0200 +++ b/MainForm.Designer.cs Thu Jul 10 22:03:29 2014 +0200 @@ -49,6 +49,7 @@ this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel(); this.tabControl.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit(); @@ -237,7 +238,6 @@ this.marqueeLabelBottom.Name = "marqueeLabelBottom"; this.marqueeLabelBottom.OwnTimer = false; this.marqueeLabelBottom.PixelsPerSecond = 64; - this.marqueeLabelBottom.Separator = " | "; this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31); this.marqueeLabelBottom.TabIndex = 3; this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; @@ -276,6 +276,7 @@ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabelConnect, this.toolStripStatusLabelSpring, + this.toolStripStatusLabelPower, this.toolStripStatusLabelFps}); this.statusStrip.Location = new System.Drawing.Point(0, 420); this.statusStrip.Name = "statusStrip"; @@ -293,7 +294,7 @@ // toolStripStatusLabelSpring // this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring"; - this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(497, 17); + this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(442, 17); this.toolStripStatusLabelSpring.Spring = true; // // toolStripStatusLabelFps @@ -302,6 +303,12 @@ this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17); this.toolStripStatusLabelFps.Text = "FPS"; // + // toolStripStatusLabelPower + // + this.toolStripStatusLabelPower.Name = "toolStripStatusLabelPower"; + this.toolStripStatusLabelPower.Size = new System.Drawing.Size(24, 17); + this.toolStripStatusLabelPower.Text = "NA"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -346,6 +353,7 @@ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring; private System.Windows.Forms.CheckBox checkBoxShowBorders; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower; } } diff -r de55741d90f0 -r f37c5ff8af18 MainForm.cs --- a/MainForm.cs Wed Jul 09 11:06:46 2014 +0200 +++ b/MainForm.cs Thu Jul 10 22:03:29 2014 +0200 @@ -69,8 +69,41 @@ bmp.Save("c:\\capture.png"); } + private void CheckForRequestResults() + { + if (iDisplay.IsRequestPending()) + { + switch (iDisplay.AttemptRequestCompletion()) + { + case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus: + if (iDisplay.PowerSupplyStatus()) + { + toolStripStatusLabelPower.Text = "ON"; + } + else + { + toolStripStatusLabelPower.Text = "OFF"; + } + //Issue next request then + iDisplay.RequestDeviceId(); + break; + + case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId: + toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId(); + //Issue next request then + iDisplay.RequestFirmwareRevision(); + break; + + case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision: + toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision(); + //No more request to issue + break; + } + } + } + private void timer_Tick(object sender, EventArgs e) - { + { //Update our animations DateTime NewTickTime = DateTime.Now; @@ -80,6 +113,8 @@ //Update our display if (iDisplay.IsOpen()) { + CheckForRequestResults(); + //Draw to bitmap System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height); tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle); @@ -112,6 +147,7 @@ if (iDisplay.Open()) { UpdateStatus(); + iDisplay.RequestPowerSupplyStatus(); } else {