Adding disconnect function to our interface.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Runtime.InteropServices;
9 namespace SharpDisplayManager
17 iDevice = IntPtr.Zero;
23 if (iDevice == IntPtr.Zero)
25 iDevice = MiniDisplayOpen();
27 return iDevice != IntPtr.Zero;
32 MiniDisplayClose(iDevice);
33 iDevice = IntPtr.Zero;
38 return iDevice != IntPtr.Zero;
43 MiniDisplayClear(iDevice);
48 MiniDisplayFill(iDevice);
51 public void SwapBuffers()
53 MiniDisplaySwapBuffers(iDevice);
56 public int MaxBrightness()
58 return MiniDisplayMaxBrightness(iDevice);
61 public int MinBrightness()
63 return MiniDisplayMinBrightness(iDevice);
66 public void SetBrightness(int aBrightness)
68 if (!IsOpen()) return;
70 MiniDisplaySetBrightness(iDevice, aBrightness);
73 public int WidthInPixels()
75 return MiniDisplayWidthInPixels(iDevice);
78 public int HeightInPixels()
80 return MiniDisplayHeightInPixels(iDevice);
83 public void SetPixel(int aX, int aY, int aValue)
85 MiniDisplaySetPixel(iDevice,aX,aY,aValue);
88 public void RequestPowerSupplyStatus()
90 MiniDisplayRequestPowerSupplyStatus(iDevice);
93 public void RequestDeviceId()
95 MiniDisplayRequestDeviceId(iDevice);
98 public void RequestFirmwareRevision()
100 MiniDisplayRequestFirmwareRevision(iDevice);
103 public bool PowerSupplyStatus()
105 bool res = MiniDisplayPowerSupplyStatus(iDevice);
109 public TMiniDisplayRequest AttemptRequestCompletion()
111 return MiniDisplayAttemptRequestCompletion(iDevice);
114 public TMiniDisplayRequest CurrentRequest()
116 return MiniDisplayCurrentRequest(iDevice);
119 public bool IsRequestPending()
121 return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
125 public string Vendor()
127 IntPtr ptr = MiniDisplayVendor(iDevice);
128 string str = Marshal.PtrToStringUni(ptr);
132 public string Product()
134 IntPtr ptr = MiniDisplayProduct(iDevice);
135 string str = Marshal.PtrToStringUni(ptr);
139 public string SerialNumber()
141 IntPtr ptr = MiniDisplaySerialNumber(iDevice);
142 string str = Marshal.PtrToStringUni(ptr);
146 public string DeviceId()
148 IntPtr ptr = MiniDisplayDeviceId(iDevice);
149 string str = Marshal.PtrToStringAnsi(ptr);
153 public string FirmwareRevision()
155 IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
156 string str = Marshal.PtrToStringAnsi(ptr);
160 //Our display device handle
163 public enum TMiniDisplayRequest
165 EMiniDisplayRequestNone,
166 EMiniDisplayRequestDeviceId,
167 EMiniDisplayRequestFirmwareRevision,
168 EMiniDisplayRequestPowerSupplyStatus
171 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
172 public static extern IntPtr MiniDisplayOpen();
174 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
175 public static extern void MiniDisplayClose(IntPtr aDevice);
177 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
178 public static extern void MiniDisplayClear(IntPtr aDevice);
180 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
181 public static extern void MiniDisplayFill(IntPtr aDevice);
183 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
184 public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
186 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
187 public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
189 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
190 public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
192 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
193 public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
195 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
196 public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
198 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
199 public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
201 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
202 public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
204 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
205 public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
207 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
208 public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
210 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
211 public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
213 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
214 public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
216 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
217 public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
219 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
220 [return: MarshalAs(UnmanagedType.I1)]
221 public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
223 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
224 public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
226 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
227 public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
229 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
230 public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
232 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
233 public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
235 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
236 public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
238 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
239 public static extern void MiniDisplayCancelRequest(IntPtr aDevice);