客户杆显示文本水平滚动连续C#

时间:2019-02-23 21:21:15

标签: c# macros serial-port hex

我现在想出了如何使文本如下所示水平滚动

byte[] byteScrollMSGHorizontal = new byte[2] { 0x1F, 0x03 };
port.Write(byteScrollMSGHorizontal, 0, byteScrollMSGHorizontal.Length);

char[] Msg = " *HELLO WORLD* ".ToCharArray();
               for (int i = 0; i < Msg.Length; i++)
               {


                       port.Write(Msg[i].ToString());
                       Thread.Sleep(110);

               }

但是它只滚动到Msg的末尾。我希望文本连续滚动。我想使用宏是一种方法,但无法弄清楚。 下面的附件是客户立杆显示器VFD-850的十六进制代码的图片。任何帮助将非常感激。谢谢:)

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

public void  comtest ()
        {
            SerialPort sport = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
            sport.Open();
            string Msg = "*HELLO WORLD*";
            string ogstring = Msg + " ";
            string mystring = "";
            string displaystring = "";
            for (int count = 0; count <= Msg.Length; count++)
            {
                if (mystring == "")
                {
                    mystring = ogstring;
                }
                if (mystring.Length > 20)
                {
                    displaystring = mystring.Substring(0, 20);
                }
                else
                {
                    displaystring = mystring;
                }
                sport.Write(new byte[] { 0x0A, 0x0D }, 0, 2);
                sport.Write(displaystring);
                System.Threading.Thread.Sleep(1000);
                string s = mystring[0].ToString();
                mystring = mystring.Substring(1);
                mystring = mystring + s;


            }
        }