【问题标题】:Customer Pole Display Text Horizontal Scroll Continuously C#客户立柱显示文本水平滚动连续C#
【发布时间】:2019-07-17 16:23:50
【问题描述】:

我现在已经弄清楚如何使文本水平滚动如下

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 的十六进制代码的图片。任何帮助将非常感激。谢谢你:)

【问题讨论】:

  • 尝试使消息的长度大于显示宽度中的字符数。显示为 20x20 个字符。您的消息只有 15 个字符。因此,除非您的消息超过 20 个字符,否则您不会看到滚动。
  • EOT、SOH 和 ETB 在哪里?发布代码后,设备可能无法获取滚动命令。我也不确定当消息少于 20 个字符时是否需要设置窗口大小 ESC W。滚动不需要宏。
  • @jdweng 我试过超过 20 个字符的文本,比如说 25 个字符,它只是滚动到第 25 个字符并停止

标签: c# macros serial-port hex


【解决方案1】:
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;


            }
        }

【讨论】:

  • 你能解释一下你的代码是做什么的以及它是如何回答这个问题的吗?
  • 这里从自定义字符串中删除第一个字符并将删除的字符添加到相同自定义字符串的末尾位置,为自定义字符串中的每个字符填充相同的过程,并在每个循环中写入传递给 com 端口的命令因此它会产生水平滚动效果
  • 好的,感谢您添加信息作为评论。但是,这不是添加信息的推荐方式,相反,请将解释编辑到您的答案中。谢谢。
猜你喜欢
  • 1970-01-01
  • 2018-02-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-11
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 2021-11-13
相关资源
最近更新 更多