IdwTest:Adding support for sending text to VFD.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using System.Runtime.InteropServices;
12 public string StatusMessage { get; set; }
13 public DSPType Type { get; set; }
14 public bool IsLcd() { return Type == DSPType.DSPN_DSP_LCD; }
15 public bool IsVfd() { return Type == DSPType.DSPN_DSP_VFD; }
18 if (Type == DSPType.DSPN_DSP_VFD)
20 return "SoundGraph iMON VFD";
22 else if (Type == DSPType.DSPN_DSP_LCD)
24 return "SoundGraph iMON LCD";
26 else //(DisplayType == DSPType.DSPN_DSP_NONE)
33 /// Do display initialization.
34 /// Returns true on success
38 IDW_INITRESULT initResult = new IDW_INITRESULT();
39 DSPResult ret = IDW_Init(initResult);
40 //Check the API call worked
41 if (ret != DSPResult.DSP_SUCCEEDED)
43 StatusMessage = DSPResult2String(ret);
46 //Check that the initialization was carried out properly
47 else if (initResult.iInitResult != DSPNInitResult.DSPN_SUCCEEDED)
49 StatusMessage = DSPNResult2String(initResult.iInitResult);
52 //Check we that we have a display
53 else if (initResult.iDspType == DSPType.DSPN_DSP_NONE)
55 StatusMessage = "Unsupported device";
59 Type = initResult.iDspType;
64 /// Do display de-initialization.
65 /// Returns true on success
67 public void DoUninit()
69 Type = DSPType.DSPN_DSP_NONE;
75 /// Provide a string corresponding to the given DSPResult.
77 protected string DSPResult2String(DSPResult result)
81 case DSPResult.DSP_SUCCEEDED:
83 case DSPResult.DSP_E_FAIL:
84 return "An unknown error occurred";
85 case DSPResult.DSP_E_OUTOFMEMORY:
86 return "Out of memory";
87 case DSPResult.DSP_E_INVALIDARG:
88 return "One or more arguments are invalid";
89 case DSPResult.DSP_E_NOT_INITED:
90 return "API is not initialized";
91 case DSPResult.DSP_E_POINTER:
92 return "Pointer is invalid";
94 return "An unknown error occurred";
99 /// Provide a string corresponding to the given DSPNInitResult.
101 protected string DSPNResult2String(DSPNInitResult result)
105 case DSPNInitResult.DSPN_SUCCEEDED:
107 case DSPNInitResult.DSPN_ERR_IN_USE:
108 return "Display plug-in is already used by another application";
109 case DSPNInitResult.DSPN_ERR_HW_DISCONNECTED:
110 return "iMON hardware is not connected";
111 case DSPNInitResult.DSPN_ERR_NOT_SUPPORTED_HW:
112 return "The connected hardware does not support the plug-in mode";
113 case DSPNInitResult.DSPN_ERR_PLUGIN_DISABLED:
114 return "The plug-in mode option is disabled";
115 case DSPNInitResult.DSPN_ERR_IMON_NO_REPLY:
116 return "The latest iMON is not installed or iMON is not running";
118 return "An unknown error occurred";
122 //Possible return values from iMON Display APIs
123 public enum DSPResult : int
127 DSP_E_OUTOFMEMORY = 2,
128 DSP_E_INVALIDARG = 3,
129 DSP_E_NOT_INITED = 4,
131 DSP_S_INITED = 0x1000,
132 DSP_S_NOT_INITED = 0x1001,
133 DSP_S_IN_PLUGIN_MODE = 0x1002,
134 DSP_S_NOT_IN_PLUGIN_MODE = 0x1003
137 //Possible results from display initialization
138 public enum DSPNInitResult : int
141 DSPN_ERR_IN_USE = 0x0100,
142 DSPN_ERR_HW_DISCONNECTED = 0x0101,
143 DSPN_ERR_NOT_SUPPORTED_HW = 0x0102,
144 DSPN_ERR_PLUGIN_DISABLED = 0x0103,
145 DSPN_ERR_IMON_NO_REPLY = 0x0104,
146 DSPN_ERR_UNKNOWN = 0x0200
150 public enum DSPType : int
158 public enum DSPNotifyCode : int
160 DSPNM_PLUGIN_SUCCEED = 0,
162 DSPNM_IMON_RESTARTED,
165 DSPNM_HW_DISCONNECTED,
166 DSPNM_LCD_TEXT_SCROLL_DONE = 0x1000
170 public enum OrangeDiskPieces : byte
172 Piece1 = 0x80, // top piece
173 Piece2 = 0x40, // next piece counter-clockwise
174 Piece3 = 0x20, // and so on...
183 public enum OrangeDiskIcon : byte
190 public enum MediaTypes : byte
203 public enum Speakers : byte
216 public enum SpeakersRR : byte
223 public enum VideoCodecs : byte
237 public enum AudioCodecs : byte
247 public enum AspectRatios : byte
259 public enum EtcIcons : byte
270 //Provide results from our iMON Display initialization
271 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
272 protected class IDW_INITRESULT
274 [MarshalAs(UnmanagedType.U4)]
275 public DSPNotifyCode iNotification;
276 [MarshalAs(UnmanagedType.U4)]
277 public DSPNInitResult iInitResult;
278 [MarshalAs(UnmanagedType.U4)]
279 public DSPType iDspType;
282 //Provide result for our status query
283 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
284 protected class IDW_STATUS
286 [MarshalAs(UnmanagedType.U4)]
287 public DSPNotifyCode iNotification;
290 //Declare a struct to pass our EqData
291 [StructLayout(LayoutKind.Sequential)]
292 public class DSPEQDATA
296 BandData = new int[16];
299 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
300 public readonly int[] BandData;
303 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
304 protected static extern DSPResult IDW_Init(IDW_INITRESULT initResult);
306 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
307 protected static extern DSPResult IDW_Uninit();
309 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
310 protected static extern DSPResult IDW_IsInitialized();
312 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
313 protected static extern DSPResult IDW_GetStatus(IDW_STATUS status);
315 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
316 public static extern DSPResult IDW_SetVfdText([MarshalAs(UnmanagedType.LPWStr)] string line1, [MarshalAs(UnmanagedType.LPWStr)] string line2);
318 //Import function to set VFD EQDATA
319 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
320 public static extern int IDW_SetVfdEqData(DSPEQDATA EqData);
322 //Import function to set LCD EQDATA
323 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
324 public static extern int IDW_SetLcdEqData(DSPEQDATA EqDataLeft, DSPEQDATA EqDataRight);
326 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
327 public static extern DSPResult IDW_SetLcdText([MarshalAs(UnmanagedType.LPWStr)] string line);
329 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
330 public static extern DSPResult IDW_SetLcdAllIcons([MarshalAs(UnmanagedType.Bool)] bool on);
332 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
333 public static extern DSPResult IDW_SetLcdOrangeIcon(byte iconData1, byte iconData2);
335 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
336 public static extern DSPResult IDW_SetLcdMediaTypeIcon(byte iconData);
338 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
339 public static extern DSPResult IDW_SetLcdSpeakerIcon(byte iconData1, byte iconData2);
341 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
342 public static extern DSPResult IDW_SetLcdVideoCodecIcon(byte iconData);
344 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
345 public static extern DSPResult IDW_SetLcdAudioCodecIcon(byte iconData);
347 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
348 public static extern DSPResult IDW_SetLcdAspectRatioIcon(byte iconData);
350 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
351 public static extern DSPResult IDW_SetLcdEtcIcon(byte iconData);
353 [DllImport("iMONDisplayWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
354 public static extern DSPResult IDW_SetLcdProgress(int currentPosition, int total);