简体   繁体   English

如何清除VFD220F显示器上的数据

[英]How to clear Data off of a VFD220F Display

When I attempt to write to the display its working and shows me the text, but when I delete the text from textbox and press send data it does not change on display, leaving the previous text. 当我尝试向显示器写入内容并向我显示文本时,但是当我从文本框中删除文本并按发送数据时,它不会在显示上更改,而是保留先前的文本。 If I write another text and send it, it shows me both the old text and new text on the same line. 如果我写另一个文本并发送,它会在同一行上同时显示旧文本和新文本。

My question is: How I can delete old text from display and show the new text? 我的问题是:如何从显示中删除旧文本并显示新文本?
I am using the code below: 我正在使用以下代码:

Imports System.IO.Ports
Public Class Form1
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Clear()
        For Each Nport As String In SerialPort.GetPortNames
            ComboBox1.Items.Add(Nport)
        Next
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            With SerialPort1
                .PortName = ComboBox1.Text
                .BaudRate = 9600
                .DataBits = 8
                .Parity = IO.Ports.Parity.None
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.None
            End With
            If Not (SerialPort1.IsOpen = True) Then
                SerialPort1.Open()
            End If
            SerialPort1.DiscardOutBuffer()
            SerialPort1.Write(TextBox1.Text)
            SerialPort1.Close()
            MsgBox("Data sent")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

You will need to use the control codes that are provided by the display to clear it. 您将需要使用显示器提供的控制代码来清除它。 According to the manufacturers documentation some of the available control codes are: 根据制造商的文档,一些可用的控制代码为:

Home ---------------- 0x1 hex 1 Decimal Home ---------------- 0x1十六进制1十进制
Backspace --------- 0x8 hex 8 Decimal 退格键 --------- 0x8十六进制8十进制
Tab ------------------- 0x9 hex 9 Decimal 制表符 ------------------- 0x9十六进制9十进制
Line feed ----------- 0xA hex 10 Decimal 换行 ----------- 0xA十六进制10十进制
Clear Scrn --------- 0xC hex 12 Decimal 清除Scrn --------- 0xC hex 12十进制
Carriage Return - 0xD hex 13 Decimal 回车 -0xD十六进制13十进制

Using the above you can do something like this: 使用上面的方法,您可以执行以下操作:

Public Class Form1
    Dim displayHome As Byte() = New Byte(0) {&H1}
    Dim displayClear As Byte() = New Byte(0) {&HC}
    Dim displayNewLine As Byte() = New Byte(0) {&HD}
    Dim displayLineFd As Byte() = New Byte(0) {&HA}


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Clear()
        For Each Nport As String In SerialPort.GetPortNames
            ComboBox1.Items.Add(Nport)
        Next
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            With SerialPort1
                .PortName = ComboBox1.Text
                .BaudRate = 9600
                .DataBits = 8
                .Parity = IO.Ports.Parity.None
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.None
            End With
            If Not (SerialPort1.IsOpen = True) Then
                SerialPort1.Open()
            End If
            SerialPort1.DiscardOutBuffer()
            'This is one way though the manufacturer doesn't
            'recommend it do to screen flashing.
            SerialPort1.Write(displayClear, 0, 1)
            SerialPort1.Write(TextBox1.Text)
            'Another way would be to go to the home position
            'and make sure you pad enough to cover all of the 
            'previous total.
            SerialPort1.Write(displayHome, 0, 1)
            SerialPort1.Write(TextBox1.Text.PadLeft(20))
            SerialPort1.Close()
            MsgBox("Data sent")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM