I have provided a sample program that uses the different Swing
JComponents provided in
virtlcd
. The sample program
com.jpeterson.virtlcd.TestHarness
(source)
provides three different tabs:
Character test
,
Display test
, and
Character set
.
You can easily run the application directly from the jar file. Here is a sample:
java -jar virtlcd-[version].jar
The
[version]
should be replaced with the actual version of the API.
The "Character test" tab provides an example usage of
com.jpeterson.virtlcd.swing.JDotMatrixSixByEight
. The
JDotMatrixSixByEight
is a component that displays a single character. The method
setChar(char)
is used to "set the character" to display. The character set
that the component uses to display characters can be found in
the
"Character set"
tab.
In the
"Character test"
tab, you will find a text field labeled "Character". The
text field allows just one character. As soon as you type a
character, it will be displayed in by the
JDotMatrixSixByEight
labeled "Display".
The "Display test" tab provides an example usage of
com.jpeterson.virtlcd.swing.JDotMatrixDisplay
. The
JDotMatrixDisplay
is a component that displays an array of characters in a grid
of columns and rows. The method
setText(java.lang.String)
is used to "set the character" to display. The text entered is
split across the different rows by breaking on "new line" (\n)
characters embedded in the text string. The character set that
the component uses to display characters can be found in the
"Character set"
tab.
In the
"Display test"
tab, you will find a text area labeled "Message". The text
area allows you to enter multiple lines of text. As soon as
you type a character, it will be displayed in by the
JDotMatrixDispley
labeled "Display". You can type multiple lines by typing a
"Enter" key. The "Backspace" key will remove characters. If
you type more characters than characters per row in the
JDotMatrixDispley
component, the excess characters are not displayed.
JDotMatrixSixByEight
. The character set is based on the
CFA-634 serial LCD
available from
Crystalfontz
.
This tab doesn't do much. Across the x-axis you will find numbers representing the first character in the column. Down the y-axis you will find numbers representing the row. To determine the character value of a certain cell, you add the column number with the row number. For instance, the character 'a' is 96 + 1 = 97. You can hover over the character and a tool tip will pop the decimal value for the character.