309 lines
18 KiB
HTML
309 lines
18 KiB
HTML
|
<?xml version="1.0" encoding="utf-8"?>
|
|||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|||
|
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
|||
|
<head><title>LCDOUT</title>
|
|||
|
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
|||
|
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
|||
|
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
|||
|
</script>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<h1 class="code">LCDOUT</h1>
|
|||
|
<div class="ImagePlusCaption">
|
|||
|
<div class="Col2">
|
|||
|
<p>
|
|||
|
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
|||
|
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
|||
|
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<p style="text-align: right;"><a href="../ExampleTopics/LcdoutEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT Example</a>
|
|||
|
</p>
|
|||
|
<p> </p>
|
|||
|
</div>
|
|||
|
<p class="clear"> </p>
|
|||
|
<p> </p>
|
|||
|
<p class="PlainText">Syntax: <span class="keyword_in_text">LCDOUT</span> <![CDATA[ ]]><i>Pin</i>,<i> Command</i>, [<i>OutputData</i>]</p>
|
|||
|
<h2>Function</h2>
|
|||
|
<p class="PlainText">Send data to an LCD display.
|
|||
|
|
|||
|
</p>
|
|||
|
<ul>
|
|||
|
<li value="1"><b><i>Pin</i></b> is a variable/constant/expression (0 - 1 or 8 - 9) that
|
|||
|
specifies which I/O pins to use. The LCD requires, at most, seven I/O pins
|
|||
|
to operate. The <i>Pin</i> argument serves a double purpose; specifying the
|
|||
|
first pin and, indirectly, the group of other required pins. See explanation
|
|||
|
below. All I/O pins will be set to output mode initially and the upper I/O
|
|||
|
pins (4 - 7 or 12 - 15) will be set to output mode by the end of the <span class="keyword_in_text">LCDOUT</span> command.</li>
|
|||
|
<li value="2"><b><i>Command</i></b> is a variable/constant/expression (0 - 255) indicating
|
|||
|
an LCD command to send.</li>
|
|||
|
<li value="3"><b><i>OutputData</i></b> is a list of variables, constants, expressions and
|
|||
|
formatters that tells <span class="keyword_in_text">LCDOUT</span> how to format outgoing data. <span class="keyword_in_text">LCDOUT</span>
|
|||
|
can transmit individual or repeating bytes, convert values into decimal, hex
|
|||
|
or binary text representations, or transmit strings of bytes from variable
|
|||
|
arrays. These actions can be combined in any order in the <i>OutputData</i>list.</li>
|
|||
|
</ul>
|
|||
|
<h2>Quick Facts</h2>
|
|||
|
<table cellpadding="4" cellspacing="0" border="1">
|
|||
|
<tr bgcolor="#CFCFCF">
|
|||
|
<td width="275" align="center"> </td>
|
|||
|
<td width="1200" align="center">BS2p, BS2pe, and BS2px</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" bgcolor="#CFCFCF">Values for <i>Pin</i></td>
|
|||
|
<td align="center">0, 1, 8, or 9</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
|
|||
|
0 or 1</td>
|
|||
|
<td>0 or 1 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 2 : LCD Read/Write (R/W) pin<br></br> 3 : LCD Register Select (RS) pin<br></br> 4 - 7 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" bgcolor="#CFCFCF">I/O pin arrangement when<br></br><i>Pin</i> is
|
|||
|
8 or 9</td>
|
|||
|
<td>8 or 9 (depending on <i>Pin</i>) : LCD Enable (E) pin<br></br> 10 : LCD Read/Write (R/W) pin<br></br> 11 : LCD Register Select (RS) pin<br></br> 12 - 15 : LCD Data Bus (DB4 - DB7, respectively) pins</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
|
|||
|
<td align="center" colspan="1">
|
|||
|
<p colspan="1" align="center"><a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a>, <a href="LCDIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN</a></p>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<h2>Explanation</h2>
|
|||
|
<p class="PlainText">The three LCD commands (<span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span>) allow the
|
|||
|
BS2p, BS2pe, or BS2pe to interface directly to standard LCD displays that feature
|
|||
|
a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16,
|
|||
|
and 4 x 20 character LCD displays. Note that <span class="keyword_in_text">LCDCMD</span>, <span class="keyword_in_text">LCDIN</span> and
|
|||
|
<span class="keyword_in_text">LCDOUT</span> use a 4-bit interface to the LCD which requires a specific
|
|||
|
initialization sequence before <span class="keyword_in_text">LCDIN</span> and <span class="keyword_in_text">LCDOUT</span> can be used
|
|||
|
(see <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> for initialization details).</p>
|
|||
|
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command is used to send one instruction followed by at least
|
|||
|
one data byte to the LCD. The data that is output is written to the LCD's
|
|||
|
Character Generator RAM (CGRAM) or Display Data RAM (DDRAM). The following is an
|
|||
|
example of the <span class="keyword_in_text">LCDOUT</span> command:</p><pre class="BScode" xml:space="preserve">
|
|||
|
LCDOUT 1, 1, ["Hello World!"]
|
|||
|
</pre>
|
|||
|
<p class="PlainText">The preceding example will clear the LCD screen and then send "Hello World!" to
|
|||
|
the screen. The first argument (1) is the starting I/O pin number and the second
|
|||
|
argument (also 1) is the LCD's instruction for Clear Screen.</p>
|
|||
|
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command actually uses more than just the I/O pin specified
|
|||
|
by the <i>Pin</i> argument. The LCDOUT command requires seven I/O pins. This is
|
|||
|
because the standard LCD displays have a parallel interface, rather than a serial
|
|||
|
one. The <i>Pin</i> argument can be the numbers 0, 1, 8, or 9 and will result in
|
|||
|
the use of the I/O pins shown above. Please refer to the
|
|||
|
<a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command description for information on properly
|
|||
|
wiring the LCD display.</p>
|
|||
|
<p class="PlainText">When the LCD is first powered-up, it will be in an unknown state and must be
|
|||
|
properly configured before sending commands like the one shown above. This process
|
|||
|
is known as initializing the LCD and is the first thing your program should do
|
|||
|
upon starting up. Please refer to the <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> command
|
|||
|
description for information on properly initializing the LCD display.</p>
|
|||
|
<p class="PlainText">The <span class="keyword_in_text">LCDOUT</span> command's <i>OutputData</i> argument is exactly like that
|
|||
|
of the <span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">SEROUT</span> command's <i>OutputData</i> argument.
|
|||
|
This means data can be sent as literal text, ASCII character values, repetitive
|
|||
|
values, decimal, hexadecimal and binary translations and string data as in the
|
|||
|
examples below.</p><pre class="BScode" xml:space="preserve">
|
|||
|
value VAR Byte
|
|||
|
|
|||
|
Setup:
|
|||
|
value = 65
|
|||
|
|
|||
|
Main:
|
|||
|
LCDOUT 1, 0, [value] ' send ASCII character "A"
|
|||
|
LCDOUT 1, 0, [REP value\5] ' send "AAAAA"
|
|||
|
LCDOUT 1, 0, [DEC value] ' send "6" and "5"
|
|||
|
LCDOUT 1, 0, [HEX value] ' send "4" and "1"
|
|||
|
LCDOUT 1, 0, [BIN value] ' send "1000001"
|
|||
|
STOP
|
|||
|
</pre>
|
|||
|
<p class="PlainText">The tables below list all the available conversion formatters and special
|
|||
|
formatters available to the <span class="keyword_in_text">LCDOUT</span> command. See the
|
|||
|
<a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a> and <a href="SEROUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SEROUT</a> commands for
|
|||
|
additional information and examples of their use.</p>
|
|||
|
<table width="100%" cellpadding="4" cellspacing="0" border="1">
|
|||
|
<tr bgcolor="#CFCFCF" align="center" valign="top">
|
|||
|
<td width="20%">Conversion Formatter</td>
|
|||
|
<td width="70%">Type of Number</td>
|
|||
|
<td width="10%">Notes</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>DEC{1..5}</td>
|
|||
|
<td align="left">Decimal, optionally fixed to 1 - 5 digits</td>
|
|||
|
<td>1</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>SDEC{1..5}</td>
|
|||
|
<td align="left">Signed decimal, optionally fixed to 1 - 5 digits</td>
|
|||
|
<td>1,2</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>HEX{1..4}</td>
|
|||
|
<td align="left">Hexadecimal, optionally fixed to 1 - 4 digits</td>
|
|||
|
<td>1</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>SHEX{1..4}</td>
|
|||
|
<td align="left">Signed hexadecimal, optionally fixed to 1 - 4 digits </td>
|
|||
|
<td>1,2</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>IHEX{1..4}</td>
|
|||
|
<td align="left">Indicated hexadecimal, optionally fixed to 1 - 4 digits</td>
|
|||
|
<td>1</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>ISHEX{1..4}</td>
|
|||
|
<td align="left">Signed, indicated hexadecimal, optionally fixed to 1 - 4
|
|||
|
digits ($ prefix)</td>
|
|||
|
<td>1,2</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>BIN{1..16}</td>
|
|||
|
<td align="left">Binary, optionally fixed to 1 - 16 digits</td>
|
|||
|
<td>1</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>SBIN{1..16}</td>
|
|||
|
<td align="left">Signed binary, optionally fixed to 1 - 16 digits</td>
|
|||
|
<td>1,2</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>IBIN{1..16}</td>
|
|||
|
<td align="left">Indicated binary, optionally fixed to 1 - 16 digits</td>
|
|||
|
<td>1</td>
|
|||
|
</tr>
|
|||
|
<tr align="center">
|
|||
|
<td>ISBIN{1..16}</td>
|
|||
|
<td align="left">Signed, indicated binary, optionally fixed to 1 - 16 digits</td>
|
|||
|
<td>1,2</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<ol>
|
|||
|
<li value="1">Fixed-digit formatters like DEC4 will pad the number with leading 0s if
|
|||
|
necessary; ex: DEC4 65 sends 0065. If a number is larger than the specified
|
|||
|
number of digits, the leading digits will be dropped; ex: DEC4 56422 sends
|
|||
|
6422.</li>
|
|||
|
<li value="2">Signed modifiers work under two's complement rules.</li>
|
|||
|
</ol>
|
|||
|
<table width="100%" cellpadding="4" cellspacing="0" border="1">
|
|||
|
<tr bgcolor="#CFCFCF" align="center" valign="top">
|
|||
|
<td width="20%">Special Formatter</td>
|
|||
|
<td width="80%">Action</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center">?</td>
|
|||
|
<td>Displays "symbol = x' + carriage return; where x is a number. Default
|
|||
|
format is decimal, but may be combined with conversion formatters (ex: BIN
|
|||
|
? x to display "x = binary_number").</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center">ASC ?</td>
|
|||
|
<td>Displays "symbol = 'x'" + carriage return; where x is an ASCII character.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center">STR ByteArray {\L}</td>
|
|||
|
<td>Send character string from an array. The optional \L argument can be used
|
|||
|
to limit the output to L characters, otherwise, characters will be sent up
|
|||
|
to the first byte equal to 0 or the end of RAM space is reached.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center">REP Byte\L</td>
|
|||
|
<td>Send a string consisting of Byte repeated L times (ex: REP "X"\10 sends
|
|||
|
"XXXXXXXXXX").</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<h3>Using the <i>Command</i> Argument</h3>
|
|||
|
<p class="PlainText">The <i>Command</i> argument is useful for proceeding a set of data with a
|
|||
|
special LCD instruction. For example, the code below will move the cursor to
|
|||
|
location 64 (the first character on the second line) and print "Hi":</p><pre class="BScode" xml:space="preserve">
|
|||
|
LCDOUT 1, 128 + 64, ["Hi"]
|
|||
|
</pre>
|
|||
|
<p class="PlainText">The next example, below, will turn on the blinking block cursor and print
|
|||
|
"Yo!":</p><pre class="BScode" xml:space="preserve">
|
|||
|
LCDOUT 1, 13, ["Yo!"]
|
|||
|
</pre>
|
|||
|
<p class="PlainText">Occasionally, you will want to send data without preceding it with a command.
|
|||
|
To do this, simply use 0 for the <i>Command</i> argument, as in:</p><pre class="BScode" xml:space="preserve">
|
|||
|
LCDOUT 1, 0, ["Hello there!"]
|
|||
|
</pre>
|
|||
|
<p class="PlainText">Another use for the <span class="keyword_in_text">LCDOUT</span> command is to access and create custom
|
|||
|
characters. The Hitachi 44780 controller has a built-in character set that is
|
|||
|
similar to the ASCII character set (at least for the first 128 characters).
|
|||
|
Most of these characters are stored in ROM and are not changeable, however, the
|
|||
|
first eight characters (ASCII 0 though 7) are programmable.</p>
|
|||
|
<p class="PlainText">Each of the programmable characters is five pixels wide and eight pixels tall.
|
|||
|
It takes eight bytes to describe each character; one byte per row (the left-most
|
|||
|
three bits are ignored). For example, the character at ASCII location 0 is defined
|
|||
|
by the bit patterns stored in bytes 0 through 7 of Character Generator RAM (CGRAM).
|
|||
|
The character at ASCII location 1 is defined by the bit patterns stored in bytes
|
|||
|
8 through 15 of CGRAM, and so on.</p>
|
|||
|
<p class="PlainText">To create a custom character, use some graph paper to plot out the bit pattern
|
|||
|
(on and off pixels) in a 5 x 8 pattern, as shown in below. Then calculate the
|
|||
|
corresponding binary value of the bit pattern for each of the eight rows of
|
|||
|
character data.</p>
|
|||
|
<center>
|
|||
|
<table border="0">
|
|||
|
<tr>
|
|||
|
<td align="center"><b>Character Cell Structure and Data</b>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>
|
|||
|
<img src="../../graphics/lcd_char.gif" border="0">
|
|||
|
</img>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
</center>
|
|||
|
<p class="PlainText">After the data is calculated for each character (8 byte values per character),
|
|||
|
use the <span class="keyword_in_text">LCDOUT</span> command with the "Move To CGRAM Address" instruction to
|
|||
|
insert the data into the character's CGRAM locations. For example, the code
|
|||
|
below will store the character shown in above into character 0's CGRAM data
|
|||
|
locations. Then it will place the cursor back on the display (DDRAM) and print
|
|||
|
the character on the screen.</p><pre class="BScode" xml:space="preserve">
|
|||
|
LCDOUT 1, 64+0, [00, 10, 10, 00, 17, 14, 06, 00]
|
|||
|
LCDOUT 1, 128+0, ["Custom Char: ", 0]
|
|||
|
</pre>
|
|||
|
<p class="PlainText">The number 64 in the <i>Command</i> argument is the LCD's "Move to CGRAM Address"
|
|||
|
instruction and the 0 that is added to it is the location of the first row of data
|
|||
|
for the character 0. The <span class="keyword_in_text">LCDOUT</span> command will write the first <i>OutputData</i>
|
|||
|
value (00) to this location, the second <i>OutputData</i> value (10) to location 1,
|
|||
|
etc. If we wanted this custom character to affect character 1, instead of 0, we'd
|
|||
|
have to adjust value of the "Move To..." command, i.e., 64+8. To affect character 2,
|
|||
|
we'd use 64+16.</p>
|
|||
|
<p class="PlainText">To try the example above, don't forget to execute the LCD initialization code
|
|||
|
(shown in the <a href="LCDCMD.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD</a> description) first and never forget
|
|||
|
to move the cursor back to the screen (as with the last command, above) when you're
|
|||
|
done writing the character data to CGRAM.</p>
|
|||
|
<div class="Col2">
|
|||
|
<div class="MasterFoot">
|
|||
|
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="Col2">
|
|||
|
<div class="MasterFoot">
|
|||
|
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
|||
|
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
|||
|
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<script type="text/javascript">/* <![CDATA[ */
|
|||
|
|
|||
|
var _gaq = _gaq || [];
|
|||
|
_gaq.push(['_setAccount', 'UA-285614-1']);
|
|||
|
_gaq.push(['_trackPageview']);
|
|||
|
|
|||
|
(function() {
|
|||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|||
|
})();
|
|||
|
|
|||
|
/* ]]> */</script>
|
|||
|
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|