Adding bitmap field object.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Runtime.InteropServices;
8 //using System.Runtime.Serialization;
10 namespace SharpDisplayManager
14 /// Provide access to our display hardware through MiniDisplay API.
22 iDevice = IntPtr.Zero;
26 public bool Open(TMiniDisplayType aType)
28 if (iDevice == IntPtr.Zero)
30 iDevice = MiniDisplayOpen(aType);
32 return iDevice != IntPtr.Zero;
37 MiniDisplayClose(iDevice);
38 iDevice = IntPtr.Zero;
43 return iDevice != IntPtr.Zero;
48 MiniDisplayClear(iDevice);
53 MiniDisplayFill(iDevice);
56 public void SwapBuffers()
58 MiniDisplaySwapBuffers(iDevice);
61 public int MaxBrightness()
63 return MiniDisplayMaxBrightness(iDevice);
66 public int MinBrightness()
68 return MiniDisplayMinBrightness(iDevice);
71 public void SetBrightness(int aBrightness)
73 if (!IsOpen()) return;
75 MiniDisplaySetBrightness(iDevice, aBrightness);
78 public int WidthInPixels()
80 return MiniDisplayWidthInPixels(iDevice);
83 public int HeightInPixels()
85 return MiniDisplayHeightInPixels(iDevice);
88 public void SetPixel(int aX, int aY, uint aValue)
90 MiniDisplaySetPixel(iDevice,aX,aY,aValue);
93 public void RequestPowerSupplyStatus()
95 MiniDisplayRequest(iDevice, TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus);
98 public void RequestDeviceId()
100 MiniDisplayRequest(iDevice, TMiniDisplayRequest.EMiniDisplayRequestDeviceId);
103 public void RequestFirmwareRevision()
105 MiniDisplayRequest(iDevice, TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision);
108 public void PowerOn()
110 MiniDisplayPowerOn(iDevice);
113 public void PowerOff()
115 MiniDisplayPowerOff(iDevice);
118 public bool SupportPowerOnOff()
120 return MiniDisplaySupportPowerOnOff(iDevice);
123 public void ShowClock()
125 MiniDisplayShowClock(iDevice);
128 public void HideClock()
130 MiniDisplayHideClock(iDevice);
133 public bool SupportClock()
135 return MiniDisplaySupportClock(iDevice);
138 public bool PowerSupplyStatus()
140 bool res = MiniDisplayPowerSupplyStatus(iDevice);
144 public TMiniDisplayRequest AttemptRequestCompletion()
146 return MiniDisplayAttemptRequestCompletion(iDevice);
149 public TMiniDisplayRequest CurrentRequest()
151 return MiniDisplayCurrentRequest(iDevice);
154 public bool IsRequestPending()
156 return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
160 public string Vendor()
162 IntPtr ptr = MiniDisplayVendor(iDevice);
163 string str = Marshal.PtrToStringUni(ptr);
167 public string Product()
169 IntPtr ptr = MiniDisplayProduct(iDevice);
170 string str = Marshal.PtrToStringUni(ptr);
174 public string SerialNumber()
176 IntPtr ptr = MiniDisplaySerialNumber(iDevice);
177 string str = Marshal.PtrToStringUni(ptr);
181 public string DeviceId()
183 IntPtr ptr = MiniDisplayDeviceId(iDevice);
184 string str = Marshal.PtrToStringAnsi(ptr);
188 public string FirmwareRevision()
190 IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
191 string str = Marshal.PtrToStringAnsi(ptr);
195 //Our display device handle
200 public enum TMiniDisplayType
202 EMiniDisplayAutoDetect, /*Not yet implemented*/
203 //[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
204 EMiniDisplayFutabaGP1212A01,
205 //[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
206 EMiniDisplayFutabaGP1212A02
210 public enum TMiniDisplayRequest
212 EMiniDisplayRequestNone,
213 EMiniDisplayRequestDeviceId,
214 EMiniDisplayRequestFirmwareRevision,
215 EMiniDisplayRequestPowerSupplyStatus
218 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
219 public static extern IntPtr MiniDisplayOpen(TMiniDisplayType aType);
221 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
222 public static extern void MiniDisplayClose(IntPtr aDevice);
224 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
225 public static extern void MiniDisplayClear(IntPtr aDevice);
227 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
228 public static extern void MiniDisplayFill(IntPtr aDevice);
230 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
231 public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
233 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
234 public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
236 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
237 public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
239 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
240 public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
242 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
243 public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
245 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
246 public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
248 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
249 public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, uint aValue);
251 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
252 public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
254 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
255 public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
257 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
258 public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
260 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
261 public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
263 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
264 public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
266 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
267 [return: MarshalAs(UnmanagedType.I1)]
268 public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
270 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
271 public static extern void MiniDisplayRequest(IntPtr aDevice, TMiniDisplayRequest aRequest);
273 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
274 public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
276 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
277 public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
279 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
280 public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
282 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
283 public static extern void MiniDisplayPowerOn(IntPtr aDevice);
285 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
286 public static extern void MiniDisplayPowerOff(IntPtr aDevice);
288 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
289 [return: MarshalAs(UnmanagedType.I1)]
290 public static extern bool MiniDisplaySupportPowerOnOff(IntPtr aDevice);
292 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
293 public static extern void MiniDisplayShowClock(IntPtr aDevice);
295 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
296 public static extern void MiniDisplayHideClock(IntPtr aDevice);
298 [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
299 [return: MarshalAs(UnmanagedType.I1)]
300 public static extern bool MiniDisplaySupportClock(IntPtr aDevice);