570 lines
28 KiB
HTML
570 lines
28 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>LCDCMD</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">LCDCMD</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/LcdcmdEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDCMD Example</a>
|
|
</p>
|
|
<p> </p>
|
|
</div>
|
|
<p class="clear"> </p>
|
|
<p> </p>
|
|
<p class="PlainText">Syntax: <span class="keyword_in_text">LCDCMD</span> <![CDATA[ ]]><i>Pin</i>,<i> Command</i></p>
|
|
<h2>Function</h2>
|
|
<p class="PlainText">Send a command 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.</li>
|
|
<li value="2"><b><i>Command</i></b> is a variable/constant/expression (0 - 255) indicating
|
|
the LCD command to send.</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 <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 <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">Special Notes</td>
|
|
<td align="center" colspan="1">LCDCMD is designed to use the LCD's 4-bit mode only.</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
|
|
<td align="center" colspan="1">
|
|
<p colspan="1" align="center"><a href="LCDIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDIN</a>, <a href="LCDOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LCDOUT</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 BS2px 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. </p>
|
|
<p class="PlainText">The Hitachi 44780 LCD controller supports a number of special instructions for
|
|
initializing the display, moving the cursor, changing the default layout, etc.
|
|
The <span class="keyword_in_text">LCDCMD</span> command is used to send one of these instructions to the LCD.
|
|
It is most commonly used to initialize the display upon a power-up or reset
|
|
condition. 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. Specifics on the initialization
|
|
sequence will follow.</p>
|
|
<p class="PlainText">The following is an example of the <span class="keyword_in_text">LCDCMD</span> command:</p><pre class="BScode" xml:space="preserve">
|
|
LCDCMD 1, 24
|
|
</pre>
|
|
<p class="PlainText">The preceding code will send the Scroll Left command (represented by the number
|
|
24) to the LCD whose enable pin is connected to I/O pin 1. This will cause the LCD
|
|
display to scroll, or shift, the entire display one character to the left.</p>
|
|
<p class="PlainText">You may have noticed that the <i>Pin</i> argument in the example above was 1.
|
|
The <span class="keyword_in_text">LCDCMD</span> command actually uses more than just this I/O pin, however.
|
|
The <span class="keyword_in_text">LCDCMD</span> 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. The figure below shows the required wiring for the above command
|
|
to work.</p>
|
|
<center>
|
|
<img src="../../graphics/lcd_sch.gif" border="0">
|
|
</img>
|
|
</center>
|
|
<p class="PlainText">Note that we could have used 0 for the Pin argument and moved the LCD's Enable
|
|
pin (pin 6) to I/O pin 0. Similarly, using 9 for the Pin argument would have
|
|
required us to wire the LCD's pins to I/O pins 9 through 15, rather than I/O pins
|
|
1 through 7.</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. The following code is a good example of LCD initialization.
|
|
(<i>Refer to Hitachi documentation for details</i>).</p><pre class="BScode" xml:space="preserve">
|
|
Init_LCD:
|
|
PAUSE 1000 ' allow LCD to power-up
|
|
LCDCMD 1, 48 ' Send wake-up sequence (3x)
|
|
PAUSE 5
|
|
LCDCMD 1, 48
|
|
PAUSE 1
|
|
LCDCMD 1, 48
|
|
PAUSE 1
|
|
LCDCMD 1, 32 ' Set data bus to 4-bit mode
|
|
LCDCMD 1, 40 ' Set 2-line mode with 5x8 font
|
|
LCDCMD 1, 8 ' Turn display off
|
|
LCDCMD 1, 12 ' Turn display on without cursor
|
|
LCDCMD 1, 6 ' Auto-increment cursor
|
|
LCDCMD 1, 1 ' Clear the display
|
|
</pre>
|
|
<p class="PlainText">This initialization code is the most commonly used sequence for a 2 x 16 and
|
|
4 x 20 LCD display (the 2-line mode instruction sets the 4 x 20 to 4-line mode).
|
|
The <span class="code_in_text">PAUSE 1000</span> command is optional, but only if your program takes more
|
|
than approximately 700 ms before it executes the Init_LCD code above. Without
|
|
it, upon powering your circuit, the BASIC Stamp may talk to the LCD too early,
|
|
the LCD will then miss some of the commands and the display will operate strangely,
|
|
or not at all.</p>
|
|
<p class="PlainText">Do not change the "wake-up" and "4-bit mode" sequence commands. However, the
|
|
commands below the line that says, "Set data bus to 4-bit mode" may be modified
|
|
to set other desired modes.</p>
|
|
<p class="PlainText">The table below shows the most commonly used LCD commands. Here's an example:</p><pre class="BScode" xml:space="preserve">
|
|
LCDCMD 1, 128 + 64
|
|
</pre>
|
|
<p class="PlainText">The preceding command will move the cursor to the first character position
|
|
on the second line (on a 2 x 16 display). 128 is the Move To Display Address
|
|
command and 64 is the location number. See the "Character Positioning" section
|
|
below, for more information.</p>
|
|
<h2>Common LCD Commands</h2>
|
|
<table cellpadding="4" cellspacing="0" border="1" width="100%">
|
|
<tr valign="top" bgcolor="#CFCFCF">
|
|
<td width="200" align="center"> </td>
|
|
<td width="125" align="center">Command<br></br>(Decimal)</td>
|
|
<td align="center">Description</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Do Nothing</td>
|
|
<td align="center">0</td>
|
|
<td>Don't perform any special function.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Clear Display</td>
|
|
<td align="center">1</td>
|
|
<td>Move cursor and display to home position.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Home Display</td>
|
|
<td align="center">2</td>
|
|
<td>Move cursor and display to home position.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Inc Cursor</td>
|
|
<td align="center">6</td>
|
|
<td>Set cursor direction to right, without a display shift.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Display Off</td>
|
|
<td align="center">8</td>
|
|
<td>Turn off display (display data is retained).</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Display On</td>
|
|
<td align="center">12</td>
|
|
<td>Turn on display without cursor (display is restored).</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Blinking Cursor</td>
|
|
<td align="center">13</td>
|
|
<td>Turn on display with blinking cursor.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Underline Cursor</td>
|
|
<td align="center">14</td>
|
|
<td>Turn on display with underline cursor.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Cursor Left</td>
|
|
<td align="center">16</td>
|
|
<td>Move cursor left one character.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Cursor Right</td>
|
|
<td align="center">20</td>
|
|
<td>Move cursor right one character.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Scroll Left</td>
|
|
<td align="center">24</td>
|
|
<td>Scroll display left one character.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Scroll Right</td>
|
|
<td align="center">28</td>
|
|
<td>Scroll display right one character.</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Move To CGRAM Address</td>
|
|
<td align="center">64 + address</td>
|
|
<td>Move pointer to Character Generator RAM location</td>
|
|
</tr>
|
|
<tr>
|
|
<td bgcolor="#CFCFCF">Move To DDRAM Address</td>
|
|
<td align="center">128 + address</td>
|
|
<td>Move cursor to Display Data RAM location</td>
|
|
</tr>
|
|
</table>
|
|
<p> </p>
|
|
<p class="PlainText">While most users will only need the commands shown above, the table below
|
|
details all of the instructions supported by the LCD (for advanced users). Many
|
|
instructions are multipurpose, depending on the state of special bits. Clever
|
|
manipulation of the instruction bits will allow for powerful control of the LCD.</p>
|
|
<table cellpadding="4" cellspacing="0" border="1" width="100%">
|
|
<tr valign="top" align="center" bgcolor="#CFCFCF">
|
|
<td width="200" rowspan="2"> </td>
|
|
<td width="200" colspan="8" align="center">Command Code (bits)</td>
|
|
<td rowspan="2">Description</td>
|
|
</tr>
|
|
<tr valign="top" bgcolor="#CFCFCF">
|
|
<td width="25" align="center">7</td>
|
|
<td width="25" align="center">6</td>
|
|
<td width="25" align="center">5</td>
|
|
<td width="25" align="center">4</td>
|
|
<td width="25" align="center">3</td>
|
|
<td width="25" align="center">2</td>
|
|
<td width="25" align="center">1</td>
|
|
<td width="25" align="center">0</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Clear Display</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td align="left">Clear entire display and move cursor home (address 0)</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Home Display</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td>0</td>
|
|
<td align="left">Move cursor home and return display to home position.</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Entry Mode</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td>M</td>
|
|
<td>S</td>
|
|
<td align="left">Sets cursor direction (M: 0=left, 1=right) and display scrolling
|
|
(S: 0=no scroll, 1=scroll)</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Display/Cursor</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td>D</td>
|
|
<td>U</td>
|
|
<td>B</td>
|
|
<td align="left">Sets display on/off (D), underline cursor (U) and blinking
|
|
block cursor (B). (0=off, 1=on)</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Scroll Display / Shift Cursor</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td>C</td>
|
|
<td>M</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td align="left">Shifts display or cursor (C: 0=cursor, 1=display) left or
|
|
right (M: 0=left, 1=right).</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Function Set</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td>1</td>
|
|
<td>B</td>
|
|
<td>L</td>
|
|
<td>F</td>
|
|
<td>0</td>
|
|
<td>0</td>
|
|
<td align="left">Sets bus size (B: 0=4-bits, 1=8-bits), number of lines
|
|
(L: 0=1?line, 1=2-lines) and font size (F: 0=5x8, 1=5x10)</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Move To CGRAM Address</td>
|
|
<td>O</td>
|
|
<td>1</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td align="left">Move pointer to Character Generator RAM location specified
|
|
by address (A)</td>
|
|
</tr>
|
|
<tr align="center" valign="top">
|
|
<td align="left" bgcolor="#CFCFCF">Move To DDRAM Address</td>
|
|
<td>1</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td>A</td>
|
|
<td align="left">Move cursor to Display Data RAM location specified by
|
|
address (A)</td>
|
|
</tr>
|
|
</table>
|
|
<p> </p>
|
|
<p class="PlainText">The last command shown above (Move To DDRAM Address) is used to move the cursor
|
|
to a specific position on the LCD. The LCD's DDRAM (Display Data RAM) is a fixed
|
|
size with unique position number for each character cell. The viewable portion
|
|
of the DDRAM depends on the LCD's logical view position (which can be altered with
|
|
the Scroll Display command). The default view position is called the Home position;
|
|
it means that the display's upper left character corresponds to DDRAM location 0.
|
|
The diagrams below indicates the position numbers for characters on the LCD screen.</p>
|
|
<p class="PlainText">Note that the diagram shows the most common DDRAM mapping, though some LCD's
|
|
may have organized the DDRAM differently. A little experimentation with your LCD
|
|
may reveal this.</p>
|
|
<h3>2 x 16 Display</h3>
|
|
<table border="0">
|
|
<tr nowrap="" align="center" bgcolor="#CFCFCF">
|
|
<td bgcolor="white"> </td>
|
|
<td nowrap="" colspan="16">On-screen Positions*</td>
|
|
<td colspan="3">Off-screen</td>
|
|
</tr>
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 1</td>
|
|
<td width="25">0</td>
|
|
<td width="25">1</td>
|
|
<td width="25">2</td>
|
|
<td width="25">3</td>
|
|
<td width="25">4</td>
|
|
<td width="25">5</td>
|
|
<td width="25">6</td>
|
|
<td width="25">7</td>
|
|
<td width="25">8</td>
|
|
<td width="25">9</td>
|
|
<td width="25">10</td>
|
|
<td width="25">11</td>
|
|
<td width="25">12</td>
|
|
<td width="25">13</td>
|
|
<td width="25">14</td>
|
|
<td width="25">15</td>
|
|
<td width="25" bgcolor="#CFCFCF">16</td>
|
|
<td width="25" bgcolor="#CFCFCF">...</td>
|
|
<td width="25" bgcolor="#CFCFCF">39</td>
|
|
</tr>
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 2</td>
|
|
<td width="25">64</td>
|
|
<td width="25">65</td>
|
|
<td width="25">66</td>
|
|
<td width="25">67</td>
|
|
<td width="25">68</td>
|
|
<td width="25">69</td>
|
|
<td width="25">79</td>
|
|
<td width="25">71</td>
|
|
<td width="25">72</td>
|
|
<td width="25">73</td>
|
|
<td width="25">74</td>
|
|
<td width="25">75</td>
|
|
<td width="25">76</td>
|
|
<td width="25">77</td>
|
|
<td width="25">78</td>
|
|
<td width="25">79</td>
|
|
<td width="25" bgcolor="#CFCFCF">80</td>
|
|
<td width="25" bgcolor="#CFCFCF">...</td>
|
|
<td width="25" bgcolor="#CFCFCF">103</td>
|
|
</tr>
|
|
</table>
|
|
<p class="PlainText">* Assuming the display is in the home position</p>
|
|
<h3>4 x 20 Display</h3>
|
|
<table border="0">
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 1</td>
|
|
<td width="25">0</td>
|
|
<td width="25">1</td>
|
|
<td width="25">2</td>
|
|
<td width="25">3</td>
|
|
<td width="25">4</td>
|
|
<td width="25">5</td>
|
|
<td width="25">6</td>
|
|
<td width="25">7</td>
|
|
<td width="25">8</td>
|
|
<td width="25">9</td>
|
|
<td width="25">10</td>
|
|
<td width="25">11</td>
|
|
<td width="25">12</td>
|
|
<td width="25">13</td>
|
|
<td width="25">14</td>
|
|
<td width="25">15</td>
|
|
<td width="25">16</td>
|
|
<td width="25">17</td>
|
|
<td width="25">18</td>
|
|
<td width="25">19</td>
|
|
</tr>
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 2</td>
|
|
<td width="25">64</td>
|
|
<td width="25">65</td>
|
|
<td width="25">66</td>
|
|
<td width="25">67</td>
|
|
<td width="25">68</td>
|
|
<td width="25">69</td>
|
|
<td width="25">79</td>
|
|
<td width="25">71</td>
|
|
<td width="25">72</td>
|
|
<td width="25">73</td>
|
|
<td width="25">74</td>
|
|
<td width="25">75</td>
|
|
<td width="25">76</td>
|
|
<td width="25">77</td>
|
|
<td width="25">78</td>
|
|
<td width="25">79</td>
|
|
<td width="25">80</td>
|
|
<td width="25">81</td>
|
|
<td width="25">82</td>
|
|
<td width="25">83</td>
|
|
</tr>
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 3</td>
|
|
<td width="25">20</td>
|
|
<td width="25">21</td>
|
|
<td width="25">22</td>
|
|
<td width="25">23</td>
|
|
<td width="25">24</td>
|
|
<td width="25">25</td>
|
|
<td width="25">26</td>
|
|
<td width="25">27</td>
|
|
<td width="25">28</td>
|
|
<td width="25">29</td>
|
|
<td width="25">30</td>
|
|
<td width="25">31</td>
|
|
<td width="25">32</td>
|
|
<td width="25">33</td>
|
|
<td width="25">34</td>
|
|
<td width="25">35</td>
|
|
<td width="25">36</td>
|
|
<td width="25">37</td>
|
|
<td width="25">38</td>
|
|
<td width="25">39</td>
|
|
</tr>
|
|
<tr nowrap="" align="center" bgcolor="#99CC66">
|
|
<td nowrap="" width="50" bgcolor="#CFCFCF">Line 4</td>
|
|
<td width="25">84</td>
|
|
<td width="25">85</td>
|
|
<td width="25">86</td>
|
|
<td width="25">87</td>
|
|
<td width="25">88</td>
|
|
<td width="25">89</td>
|
|
<td width="25">90</td>
|
|
<td width="25">91</td>
|
|
<td width="25">92</td>
|
|
<td width="25">93</td>
|
|
<td width="25">94</td>
|
|
<td width="25">95</td>
|
|
<td width="25">96</td>
|
|
<td width="25">97</td>
|
|
<td width="25">98</td>
|
|
<td width="25">99</td>
|
|
<td width="25">100</td>
|
|
<td width="25">101</td>
|
|
<td width="25">102</td>
|
|
<td width="25">103</td>
|
|
</tr>
|
|
</table>
|
|
<p> </p>
|
|
<p class="PlainText">On a standard 2 x 16 character display, the following command would move the
|
|
cursor to the third column of the second line:</p><pre class="BScode" xml:space="preserve">
|
|
LCDCMD 1, 128 + 66
|
|
</pre>
|
|
<p class="PlainText">The number 128 tells the LCD we wish to move the cursor and 66 is the location
|
|
number of the desired position. Similarly, sending just 128 (128 + 0) would move
|
|
the cursor to the first character of the first line (the upper left character if
|
|
the display is at the home position).</p>
|
|
<p class="PlainText">You may have noticed that the 2 x 16 display has many locations that are not
|
|
visible; they are to the right of the edge of the screen. These locations (16 -
|
|
39 and 80 to 103) become important for scrolling operations. For example, it is
|
|
possible to move the cursor to location 16, print some text there and then issue
|
|
a number of Scroll Left instructions (<span class="keyword_in_text">LCDCMD</span> 1, 24) to slowly scroll the
|
|
text onto the display from right to left. If you did so, the DDRAM positions that
|
|
were on the left of the screen would now be past the left edge of the screen. For
|
|
example:</p><pre class="BScode" xml:space="preserve">
|
|
LCDCMD 1, 24
|
|
LCDCMD 1, 24
|
|
</pre>
|
|
<p class="PlainText">...would cause the screen to scroll to the left by two characters. At this point,
|
|
the upper-left character in the display would actually be DDRAM location 2 and the
|
|
lower-left character would be DDRAM location 66. Locations 0, 1, 64 and 65 would
|
|
be off the left edge of the LCD and would no longer be visible. Some interesting
|
|
effects can be achieved by taking advantage of this feature.</p>
|
|
<p class="PlainText">The 4 x 20 LCD has a strange DDRAM map. The upper-right character is location
|
|
19 and the next location, 20, appears as the first character of the third line.
|
|
This strange mapping is due to constraints in the LCD controller and the
|
|
manufacturers design, and unfortunately makes the scrolling features virtually
|
|
useless on the 4 x 20 displays.</p>
|
|
<p class="PlainText">Even though the LCD requires many pins to talk to it, only the Enable pin needs
|
|
to remain dedicated to the LCD and all the other pins can be multiplexed (shared)
|
|
with certain other devices (if wired carefully). In addition, the I/O pin connected
|
|
to the LCD's R/W pin is only necessary if the <span class="keyword_in_text">LCDIN</span> command will be used
|
|
in the application. If the <span class="keyword_in_text">LCDIN</span> command will not be used, LCD pin 5 (R/W
|
|
pin) can be connected to ground and I/O pin 2 (shown above) may be left disconnected.
|
|
I/O pin 2 will still be set to output mode for each <span class="keyword_in_text">LCDCMD</span> and <span class="keyword_in_text">LCDOUT</span>command executed, however.</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> |