Index: mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONDisplay.cs =================================================================== --- mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONDisplay.cs (revision 28267) +++ mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONDisplay.cs (working copy) @@ -25,6 +25,7 @@ using System.Reflection.Emit; using System.Runtime.InteropServices; using System.Threading; +using System.Text; using MediaPortal.Configuration; using MediaPortal.GUI.Library; using Microsoft.Win32; @@ -84,7 +85,7 @@ private static extern bool _A_iMONVFD_SetEQ(int[] arEQValue); [DllImport(@"..\VFD\SG_VFD.dll", EntryPoint = "iMONVFD_SetText")] - private static extern bool _A_iMONVFD_SetText(string firstLine, string secondLine); + private static extern bool _A_iMONVFD_SetText(byte[] firstLine, byte[] secondLine); [DllImport(@"..\VFD\SG_VFD.dll", EntryPoint = "iMONVFD_Uninit")] private static extern void _A_iMONVFD_Uninit(); @@ -102,7 +103,7 @@ private static extern bool _iMONVFD_SetEQ(int[] arEQValue); [DllImport(@".\SG_VFD.dll", EntryPoint = "iMONVFD_SetText")] - private static extern bool _iMONVFD_SetText(string firstLine, string secondLine); + private static extern bool _iMONVFD_SetText(byte[] firstLine, byte[] secondLine); [DllImport(@".\SG_VFD.dll", EntryPoint = "iMONVFD_Uninit")] private static extern void _iMONVFD_Uninit(); @@ -120,7 +121,7 @@ private static extern bool _S_iMONVFD_SetEQ(int[] arEQValue); [DllImport(@"..\iMON\SG_VFD.dll", EntryPoint = "iMONVFD_SetText")] - private static extern bool _S_iMONVFD_SetText(string firstLine, string secondLine); + private static extern bool _S_iMONVFD_SetText(byte[] firstLine, byte[] secondLine); [DllImport(@"..\iMON\SG_VFD.dll", EntryPoint = "iMONVFD_Uninit")] private static extern void _S_iMONVFD_Uninit(); @@ -676,15 +677,56 @@ return _iMONVFD_SetEQ(arEQValue); } - public bool iMONVFD_SetText(string firstLine, string secondLine) + private byte[] iMONVFD_StringToBytes(string line, bool translate) { + Byte[] bytes; + Encoding ANSI = Encoding.Default; + + if (DoDebug) + { + Log.Info("iMONLCDg.iMONDisplay.StringToBytes"); + } + int byteCount = ANSI.GetByteCount(line.ToCharArray(), 0, line.Length); + bytes = new Byte[byteCount + 1]; + int bytesEncodedCount = ANSI.GetBytes(line, 0, line.Length, bytes, 0); + bytes[bytesEncodedCount] = 0; + if (translate) + iMONVFD_TranslateBytes(ref bytes, ANSI.CodePage); + return bytes; + } + + private bool iMONVFD_TranslateBytes(ref Byte[] bytes, int codePage) + { + if (DoDebug) + { + Log.Info("iMONLCDg.iMONDisplay.TranscodeBytes: transcoding to page {0}",codePage); + } + codePage -= 1250; + if (codePage < 0 || codePage >= iMONLCDg._ANSI_To_VFD.Length || iMONLCDg._ANSI_To_VFD[codePage].Length <= 0) + return false; + for (int i = 0; i < bytes.Length; i++) + { + if (bytes[i] > 127) + { + byte c = iMONLCDg._ANSI_To_VFD[codePage][bytes[i] - 128]; + if (c != 0) + bytes[i] = c; + } + } + return true; + } + + public bool iMONVFD_SetText(string firstLine, string secondLine, bool translate = false) + { + Byte[] firstBytes = iMONVFD_StringToBytes(firstLine, translate); + Byte[] secondBytes = iMONVFD_StringToBytes(secondLine, translate); if (_A_DLL) { if (DoDebug) { Log.Info("iMONLCDg.iMONDisplay.iMONVFD_SetText(): Calling SetText() from Antec DLL"); } - return _A_iMONVFD_SetText(firstLine, secondLine); + return _A_iMONVFD_SetText(firstBytes, secondBytes); } if (_S_DLL) { @@ -692,13 +734,13 @@ { Log.Info("iMONLCDg.iMONDisplay.iMONVFD_SetText(): Calling SetText() from SoundGraph DLL"); } - return _S_iMONVFD_SetText(firstLine, secondLine); + return _S_iMONVFD_SetText(firstBytes, secondBytes); } if (DoDebug) { Log.Info("iMONLCDg.iMONDisplay.iMONVFD_SetText(): Calling SetText() from Default (V3) DLL"); } - return _iMONVFD_SetText(firstLine, secondLine); + return _iMONVFD_SetText(firstBytes, secondBytes); } public void iMONVFD_Uninit() Index: mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONLCDg.cs =================================================================== --- mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONLCDg.cs (revision 28267) +++ mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/Drivers/iMONLCDg.cs (working copy) @@ -52,6 +52,76 @@ public static readonly int _BrandTableLength = 1; + public static readonly byte[][] _ANSI_To_VFD = new byte[][] + { + new byte[] { //Win-1250 - Central Europe +// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + 0x68, 0,0x2C, 0,0x13,0x5F,0x2B,0xB1, 0,0x25,0x53,0x3C,0x53,0x54,0x5A,0x5A, //80 + 0,0xAF,0x27,0x13,0x12,0xB7,0x2d,0X2d, 0,0x9C,0x73,0x3E,0x73,0x74,0x7A,0x7A, //90 + 0x20,0x76,0x75,0x4C, 0,0x41, 0, 0,0x3A, 0,0x53, 0,0x2D,0x2D, 0,0x7E, //A0 + 0, 0, 0,0x6C,0x27, 0, 0, 0,0x2C,0x61,0x73, 0,0x4C,0x13,0x6C,0x7E, //B0 + 0x52, 0, 0,0xC5, 0,0x4C,0x43, 0,0x43, 0,0x45, 0,0xCA, 0, 0, 0, //C0 + 0,0x4E,0xD1, 0, 0,0xD6, 0, 0,0x52,0x55, 0,0xBC, 0, 0,0x54, 0, //D0 + 0x72, 0, 0, 0, 0,0x6C,0x63, 0,0x63, 0,0x65, 0,0x65, 0, 0,0x64, //E0 + 0,0x6E,0xF1, 0, 0,0xF6, 0, 0,0x72,0x75, 0,0xFC, 0, 0,0x74,0xB7, //F0 + }, + new byte[] { //Win-1251 - Cyrillic +// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + 0x68,0x92,0x2C,0x92,0x13,0x5F,0x2B,0xB1,0x45,0x25,0x86,0x3C,0x48,0x4B,0x68,0x56, //80 + 0x68,0xAF,0x27,0x13,0x12,0xB7,0X2d,0X2d, 0,0x9C,0x86,0x3E,0x48,0x4B,0x68,0x56, //90 + 0x20,0xFD,0xFD,0x4A, 0,0x92, 0, 0,0xCB, 0,0x45, 0,0x5E,0x2D, 0,0xCF, //A0 + 0, 0,0x49,0x49,0x92, 0, 0, 0,0xCB,0x4E,0x45, 0,0x4A,0x53,0x53,0xCF, //B0 + 0x41,0x80,0x42,0x92,0x81,0x45,0x82,0x83,0x84,0x85,0x4B,0x86,0x4D,0x48,0x4f,0x87, //C0 + 0x50,0x43,0x54,0x88,0xD8,0x58,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD, //D0 + 0x41,0x80,0x42,0x92,0x81,0x45,0x82,0x83,0x84,0x85,0x4B,0x86,0x4D,0x48,0x4f,0x87, //E0 + 0x50,0x43,0x54,0x88,0xD8,0x58,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD //F0 + }, + new byte[] { //Win-1252 - Western Europe +// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + 0x68, 0,0x2C,0xA8,0x13,0x5F,0x2B,0xB1,0x5E,0x25,0x53,0x3C,0x4F, 0,0x5A, 0, //80 + 0,0xAF,0x27,0x13,0x12,0xB7,0x2d,0X2d,0x7E,0x9C,0x73,0x3E,0x6F, 0,0x7A,0xFF, //90 + 0x20, 0, 0, 0, 0, 0, 0, 0,0x3A, 0, 0, 0,0x2D,0x2D, 0,0x7E, //A0 + 0, 0, 0, 0,0x27, 0, 0, 0,0x2C, 0, 0, 0, 0, 0, 0, 0, //B0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //C0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //D0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //E0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //F0 + }, + new byte[] { //Win-1253 - Greek +// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + 0x68, 0,0x2C,0xA8,0x13,0x5F,0x2B,0xB1, 0,0x25, 0,0x3C, 0, 0, 0, 0, //80 + 0,0xAF,0x27,0x13,0x12,0xB7,0x2d,0X2d, 0,0x9C, 0,0x3E, 0, 0, 0, 0, //90 + 0x20,0x13,0xC1, 0, 0, 0, 0, 0,0x3A, 0, 0, 0,0x2D,0x2D, 0,0x2D, //A0 + 0, 0, 0, 0,0x27, 0, 0, 0,0xC9,0x48,0xBD, 0,0xD3, 0,0xCD,0x9A, //B0 + 0xCF,0x41,0x42,0x92,0x7F,0x45,0x5A,0x48,0x99,0x49,0x4B,0x86,0x4D,0x4E,0xA7,0x4F, //C0 + 0x87,0x50, 0,0x94,0x54,0x59,0xD8,0x58,0xA5,0x9A,0xCF,0x59,0xC1,0xC9,0x48,0xBD, //D0 + 0xDC,0x41,0x42,0x92,0x7F,0x45,0x5A,0x48,0x99,0x49,0x4B,0x86,0x4D,0x4E,0xA7,0x4F, //E0 + 0x87,0x50, 0,0x94,0x54,0x59,0xD8,0x58,0xA5,0x9A,0xCF,0x59,0xC1,0xD3,0xDD,0x9A //F0 + }, + new byte[] { //Win-1254 - Turkish +// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F + 0x68, 0,0x2C,0xA8,0x13,0x5F,0x2B,0xB1,0x5E,0x25,0x53,0x3C,0x4F, 0, 0, 0, //80 + 0,0xAF,0x27,0x13,0x12,0xB7,0x2d,0X2d,0x7E,0x9C,0x73,0x3E,0x6F, 0, 0,0xFF, //90 + 0x20, 0, 0, 0, 0, 0, 0, 0,0x3A, 0, 0, 0,0x2D,0x2D, 0,0x7E, //A0 + 0, 0, 0, 0,0x27, 0, 0, 0,0x2C, 0, 0, 0, 0, 0, 0, 0, //B0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //C0 + 0x47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0x49,0x53, 0, //D0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //E0 + 0x67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0x69,0x73, 0, //F0 + }, + new byte[] { //Win-1255 - Hebrew + //No Compatible Symbols in ROM + }, + new byte[] { //Win-1256 - Arabic + //No Compatible Symbols in ROM + }, + new byte[] { //Win-1257 - Baltic + // Anyone interested? Fill It! + }, + new byte[] { //Win-1257 - Vietnamese + // Anyone interested? Fill It! + } + }; public static readonly byte[,] _Font8x5 = new byte[,] { {0, 0, 0, 0, 0, 0}, {0, 100, 0x18, 4, 100, 0x18}, @@ -3182,7 +3252,7 @@ { Log.Info("iMONLCDg.SetText(): Sending text to display"); } - _IMON.iMONVFD_SetText(Line1, Line2); + _IMON.iMONVFD_SetText(Line1, Line2, true); Thread.Sleep(_delay); } }