Interop/MiniDisplay.cs
author StephaneLenclud
Wed, 06 May 2015 21:25:49 +0200
changeset 37 d3b88ef66bfe
parent 36 3b94d0640115
permissions -rw-r--r--
Trying to sort out our interop nicely.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Runtime.InteropServices;
     5 
     6 namespace MiniDisplayInterop
     7 {
     8 	public class MiniDisplay
     9     {
    10 
    11 		//[Serializable]
    12 		public enum Type
    13 		{
    14 			AutoDetect, /*Not yet implemented*/
    15 			//[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
    16 			FutabaGP1212A01,
    17 			//[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
    18 			FutabaGP1212A02
    19 		};
    20 
    21 		/// <summary>
    22 		/// 
    23 		/// </summary>
    24 		public enum Request
    25 		{
    26 			None,
    27 			DeviceId,
    28 			FirmwareRevision,
    29 			PowerSupplyStatus
    30 		};
    31 
    32 
    33 		/// <summary>
    34 		/// Define the various type of icons we support.
    35 		/// For binary compatibility new entries must be added at the end.
    36 		/// </summary>
    37 		public enum IconType
    38 		{
    39 			NetworkSignal = 0,
    40 			Internet,
    41 			Email,
    42 			Mute,
    43 			Volume,
    44 			VolumeLabel,
    45 			Play,
    46 			Pause,
    47 			Recording
    48 		};
    49 
    50 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayOpen", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    51 		public static extern IntPtr Open(Type aType);
    52 
    53 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClose", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    54 		public static extern void Close(IntPtr aDevice);
    55 
    56 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayTypeCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    57 		public static extern int TypeCount();
    58 
    59 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayTypeName", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    60 		public static extern IntPtr TypeName(Type aType);
    61 
    62 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClear", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    63 		public static extern void Clear(IntPtr aDevice);
    64 
    65 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayFill", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    66 		public static extern void Fill(IntPtr aDevice);
    67 
    68 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySwapBuffers", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    69 		public static extern void SwapBuffers(IntPtr aDevice);
    70 
    71 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    72 		public static extern void SetBrightness(IntPtr aDevice, int aBrightness);
    73 
    74 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayMinBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    75 		public static extern int MinBrightness(IntPtr aDevice);
    76 
    77 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayMaxBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    78 		public static extern int MaxBrightness(IntPtr aDevice);
    79 
    80 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayWidthInPixels", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    81 		public static extern int WidthInPixels(IntPtr aDevice);
    82 
    83 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayHeightInPixels", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    84 		public static extern int HeightInPixels(IntPtr aDevice);
    85 
    86 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetPixel", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    87 		public static extern int SetPixel(IntPtr aDevice, int aX, int aY, uint aValue);
    88 
    89 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayVendor", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    90 		public static extern IntPtr Vendor(IntPtr aDevice);
    91 
    92 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayProduct", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    93 		public static extern IntPtr Product(IntPtr aDevice);
    94 
    95 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySerialNumber", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    96 		public static extern IntPtr SerialNumber(IntPtr aDevice);
    97 
    98 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayDeviceId", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    99 		public static extern IntPtr DeviceId(IntPtr aDevice);
   100 
   101 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayFirmwareRevision", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   102 		public static extern IntPtr FirmwareRevision(IntPtr aDevice);
   103 
   104 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayPowerSupplyStatus", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   105 		[return: MarshalAs(UnmanagedType.I1)]
   106 		public static extern bool PowerSupplyStatus(IntPtr aDevice);
   107 
   108 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   109 		public static extern void SendRequest(IntPtr aDevice, Request aRequest);
   110 
   111 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayAttemptRequestCompletion", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   112 		public static extern Request AttemptRequestCompletion(IntPtr aDevice);
   113 
   114 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayCurrentRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   115 		public static extern Request CurrentRequest(IntPtr aDevice);
   116 
   117 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayCancelRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   118 		public static extern void CancelRequest(IntPtr aDevice);
   119 
   120 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClose", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   121 		public static extern void PowerOn(IntPtr aDevice);
   122 
   123 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayPowerOff", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   124 		public static extern void PowerOff(IntPtr aDevice);
   125 
   126 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySupportPowerOnOff", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   127 		[return: MarshalAs(UnmanagedType.I1)]
   128 		public static extern bool SupportPowerOnOff(IntPtr aDevice);
   129 
   130 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayShowClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   131 		public static extern void ShowClock(IntPtr aDevice);
   132 
   133 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayHideClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   134 		public static extern void HideClock(IntPtr aDevice);
   135 
   136 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySupportClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   137 		[return: MarshalAs(UnmanagedType.I1)]
   138 		public static extern bool SupportClock(IntPtr aDevice);
   139 
   140 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayIconCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   141 		public static extern int IconCount(IntPtr aDevice, IconType aIcon);
   142 
   143 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayIconStatusCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   144 		public static extern int IconStatusCount(IntPtr aDevice, IconType aIcon);
   145 
   146 		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetIconStatus", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   147 		public static extern void SetIconStatus(IntPtr aDevice, IconType aIcon, int aIndex, int aStatus);
   148 
   149 
   150     }
   151 }