Source

New LiquidCrystal / docs / html / _liquid_crystal___s_r2_w_8h_source.html

The default branch has multiple heads

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>LCD Library: /Users/fmalpartida/development/ardWorkspace/LiquidCrystal_I2C/LiquiCrystal_I2C/LiquidCrystal_SR2W.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logoGoogle.jpg"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">LCD Library&#160;<span id="projectnumber">1.2.1</span></div>
   <div id="projectbrief">LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">/Users/fmalpartida/development/ardWorkspace/LiquidCrystal_I2C/LiquiCrystal_I2C/LiquidCrystal_SR2W.h</div>  </div>
</div>
<div class="contents">
<a href="_liquid_crystal___s_r2_w_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// ---------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">// Created/Adapted by Bill Perry 2012-03-16</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright 2012 - Under creative commons license 3.0:</span>
<a name="l00004"></a>00004 <span class="comment">//        Attribution-ShareAlike CC BY-SA</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// This software is furnished &quot;as is&quot;, without technical support, and with no </span>
<a name="l00007"></a>00007 <span class="comment">// warranty, express or implied, as to its usefulness for any purpose.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// @file LiquidCrystal_SR2W.h</span>
<a name="l00010"></a>00010 <span class="comment">// Connects a hd44780 LCD using 2 pins from the Arduino, via an 8-bit </span>
<a name="l00011"></a>00011 <span class="comment">// ShiftRegister (SR2W from now on).</span>
<a name="l00012"></a>00012 <span class="comment">// </span>
<a name="l00013"></a>00013 <span class="comment">// @brief </span>
<a name="l00014"></a>00014 <span class="comment">// This is the 2 wire shift register interface class for the LCD library</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 <span class="comment">// The functionality provided by this class and its base class is a superset of</span>
<a name="l00017"></a>00017 <span class="comment">// the original functionality of the Arduino LiquidCrystal library and can</span>
<a name="l00018"></a>00018 <span class="comment">// be used as such.</span>
<a name="l00019"></a>00019 <span class="comment">// See the LCD class for a full description of the API functions available.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// It works with a 8-bit unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out)</span>
<a name="l00022"></a>00022 <span class="comment">// shift register (IE a very simple SR), and an hd44780 LCD in 4-bit mode.</span>
<a name="l00023"></a>00023 <span class="comment">// Any such shift register should do (pref. 74LS family IC&#39;s for 2-wire).</span>
<a name="l00024"></a>00024 <span class="comment">// 74LS164 and 74HC595 have been exstensively tested.</span>
<a name="l00025"></a>00025 <span class="comment">//</span>
<a name="l00026"></a>00026 <span class="comment">//</span>
<a name="l00027"></a>00027 <span class="comment">// 2 Pins required from the Arduino:</span>
<a name="l00028"></a>00028 <span class="comment">// - Data/Enable</span>
<a name="l00029"></a>00029 <span class="comment">// - Clock</span>
<a name="l00030"></a>00030 <span class="comment">// The Data pin is also used to control the enable signal</span>
<a name="l00031"></a>00031 <span class="comment">// LCD RW-pin hardwired to LOW (only writing to LCD).</span>
<a name="l00032"></a>00032 <span class="comment">// Busy Flag (BF, data bit D7) is not read.</span>
<a name="l00033"></a>00033 <span class="comment">//</span>
<a name="l00034"></a>00034 <span class="comment">//  Original project homepage: http://code.google.com/p/arduinoshiftreglcd/</span>
<a name="l00035"></a>00035 <span class="comment">//</span>
<a name="l00036"></a>00036 <span class="comment">// Shift register bits</span>
<a name="l00037"></a>00037 <span class="comment">// Bit  #0   - (cannot be used on 74HC595)</span>
<a name="l00038"></a>00038 <span class="comment">// Bit  #1   - optional backlight control</span>
<a name="l00039"></a>00039 <span class="comment">// Bit  #2   - connects to RS (Register Select) on the LCD</span>
<a name="l00040"></a>00040 <span class="comment">// Bit  #3   - connects to LCD data inputs D4</span>
<a name="l00041"></a>00041 <span class="comment">// Bit  #4   - connects to LCD data inputs D5</span>
<a name="l00042"></a>00042 <span class="comment">// Bit  #5   - connects to LCD data inputs D6</span>
<a name="l00043"></a>00043 <span class="comment">// Bit  #6   - connects to LCD data inputs D7</span>
<a name="l00044"></a>00044 <span class="comment">// Bit  #7   - enables the LCD enable-puls (via the diode-resistor AND &quot;gate&quot;)</span>
<a name="l00045"></a>00045 <span class="comment">// </span>
<a name="l00046"></a>00046 <span class="comment">// Wiring for a 74LS164</span>
<a name="l00047"></a>00047 <span class="comment">// ---------------------</span>
<a name="l00048"></a>00048 <span class="comment">//                          1k/4.7k</span>
<a name="l00049"></a>00049 <span class="comment">//              +--------[ Resistor ]--------+---(LCD Enable)</span>
<a name="l00050"></a>00050 <span class="comment">//              |                            |</span>
<a name="l00051"></a>00051 <span class="comment">//              |          74LS164    (VCC)  |</span>
<a name="l00052"></a>00052 <span class="comment">//              |        +----u----+    |   _V_ diode</span>
<a name="l00053"></a>00053 <span class="comment">// (data pin)---+---+--1-|A     VCC|-14-+    |</span>
<a name="l00054"></a>00054 <span class="comment">//                  |    |         |         |</span>
<a name="l00055"></a>00055 <span class="comment">//                  +--2-|B      Q7|-13------+</span>
<a name="l00056"></a>00056 <span class="comment">//                     3-|Q0     Q6|-12--(LCD D7)</span>
<a name="l00057"></a>00057 <span class="comment">// (BL Circuit)--------4-|Q1     Q5|-11--(LCD D6)</span>
<a name="l00058"></a>00058 <span class="comment">// (LCD RS)------------5-|Q2     Q4|-10--(LCD D5)</span>
<a name="l00059"></a>00059 <span class="comment">// (LCD D4)------------6-|Q3    /MR|--9--(VCC)</span>
<a name="l00060"></a>00060 <span class="comment">//                   +-7-|GND    CP|--8--(clock pin)</span>
<a name="l00061"></a>00061 <span class="comment">//                   |   +---------+ </span>
<a name="l00062"></a>00062 <span class="comment">//                   |      0.1uf</span>
<a name="l00063"></a>00063 <span class="comment">//                 (gnd)-----||----(vcc)</span>
<a name="l00064"></a>00064 <span class="comment">// </span>
<a name="l00065"></a>00065 <span class="comment">// Wiring for a 74HC595</span>
<a name="l00066"></a>00066 <span class="comment">// --------------------</span>
<a name="l00067"></a>00067 <span class="comment">// NOTE: the 74HC595 is a latching shift register. In order to get it to operate</span>
<a name="l00068"></a>00068 <span class="comment">// in a &quot;non latching&quot; mode, RCLK and SCLK are tied together. The side effect of this</span>
<a name="l00069"></a>00069 <span class="comment">// is that the latched output is one clock behind behind the internal shift register bits.</span>
<a name="l00070"></a>00070 <span class="comment">// To compensate for this the wiring is offset by one bit position lower.</span>
<a name="l00071"></a>00071 <span class="comment">// For example, while the backlight is hooked to Q0 it is still using bit 1 of</span>
<a name="l00072"></a>00072 <span class="comment">// of the shift register because the outputs are 1 clock behind the real internal shift</span>
<a name="l00073"></a>00073 <span class="comment">// register.</span>
<a name="l00074"></a>00074 <span class="comment">// </span>
<a name="l00075"></a>00075 <span class="comment">//                         74HC595    (VCC)</span>
<a name="l00076"></a>00076 <span class="comment">//                       +----u----+    |  +-----------------------(BL circuit)</span>
<a name="l00077"></a>00077 <span class="comment">// (LCD RS)------------1-|Q1    VCC|-16-+  |  +--------------------(data pin)</span>
<a name="l00078"></a>00078 <span class="comment">// (LCD D4)------------2-|Q2     Q0|-15----+  |      1k/4.7k</span>
<a name="l00079"></a>00079 <span class="comment">// (LCD D5)------------3-|Q3    SER|-14-------+---[ Resistor ]--+--(LCD Enable)</span>
<a name="l00080"></a>00080 <span class="comment">// (LCD D6)------------4-|Q4    /OE|-13--(gnd)                  |</span>
<a name="l00081"></a>00081 <span class="comment">// (LCD D7)------------5-|Q5   RCLK|-12-------+                 |</span>
<a name="l00082"></a>00082 <span class="comment">//                       |         |          |                 |</span>
<a name="l00083"></a>00083 <span class="comment">//              +------6-|Q6   SCLK|-11-------+--(clock pin)    |</span>
<a name="l00084"></a>00084 <span class="comment">//              |      7-|Q7    /MR|-10--(VCC)                  |</span>
<a name="l00085"></a>00085 <span class="comment">//              |    +-8-|GND   Q6&#39;|--9                         |</span>
<a name="l00086"></a>00086 <span class="comment">//              |    |   +---------+                    diode  _V_</span>
<a name="l00087"></a>00087 <span class="comment">//              |    |      0.1uf                               |</span>
<a name="l00088"></a>00088 <span class="comment">//              |  (gnd)-----||----(vcc)                        |</span>
<a name="l00089"></a>00089 <span class="comment">//              +-----------------------------------------------+</span>
<a name="l00090"></a>00090 <span class="comment">// </span>
<a name="l00091"></a>00091 <span class="comment">//</span>
<a name="l00092"></a>00092 <span class="comment">// Backlight Control circuit</span>
<a name="l00093"></a>00093 <span class="comment">// -------------------------</span>
<a name="l00094"></a>00094 <span class="comment">// Because the shift resiter is not latching the outputs, the backlight circuitry</span>
<a name="l00095"></a>00095 <span class="comment">// will &quot;see&quot; the output bits as they are shifted into the shift register which</span>
<a name="l00096"></a>00096 <span class="comment">// can cause the backlight to flicker rather than remain constantly on/off.</span>
<a name="l00097"></a>00097 <span class="comment">// The circuit below slows down the transitions to the transistor to remove</span>
<a name="l00098"></a>00098 <span class="comment">// the visible flicker. When the BL input is HIGH the LCD backlight will turn on.</span>
<a name="l00099"></a>00099 <span class="comment">//</span>
<a name="l00100"></a>00100 <span class="comment">//                (value depends on LCD, 100ohm is usually safe)</span>
<a name="l00101"></a>00101 <span class="comment">// (LCD BL anode)---[ resistor ]---(vcc)</span>
<a name="l00102"></a>00102 <span class="comment">//</span>
<a name="l00103"></a>00103 <span class="comment">// (LCD BL cathode)-------------------------------+</span>
<a name="l00104"></a>00104 <span class="comment">//                                                |</span>
<a name="l00105"></a>00105 <span class="comment">//                                                D</span>
<a name="l00106"></a>00106 <span class="comment">//                                                |</span>
<a name="l00107"></a>00107 <span class="comment">// (BL input)----[ 4.7k Resistor ]----+-------G-|-&lt;  (2N7000 FET)</span>
<a name="l00108"></a>00108 <span class="comment">//                                    |           |</span>
<a name="l00109"></a>00109 <span class="comment">//                          (0.1uf)   =           S</span>
<a name="l00110"></a>00110 <span class="comment">//                                    |           |</span>
<a name="l00111"></a>00111 <span class="comment">//                                  (gnd)        (gnd)</span>
<a name="l00112"></a>00112 <span class="comment">// </span>
<a name="l00113"></a>00113 <span class="comment">// </span>
<a name="l00114"></a>00114 <span class="comment">// </span>
<a name="l00115"></a>00115 <span class="comment">//</span>
<a name="l00116"></a>00116 <span class="comment">// History</span>
<a name="l00117"></a>00117 <span class="comment">// 2012.03.16  bperrybap - creation/adaption from SR header to create SR2W header.</span>
<a name="l00118"></a>00118 <span class="comment">//                         Fixed typo in SR2W mask define names</span>
<a name="l00119"></a>00119 <span class="comment">// @author B. Perry - bperrybap@opensource.billsworld.billandterrie.com</span>
<a name="l00120"></a>00120 <span class="comment">// --------------------------------------------------------------------------------</span>
<a name="l00121"></a>00121 <span class="preprocessor">#ifndef _LIQUIDCRYSTAL_SR2W_</span>
<a name="l00122"></a>00122 <span class="preprocessor"></span><span class="preprocessor">#define _LIQUIDCRYSTAL_SR2W_</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span>
<a name="l00124"></a>00124 <span class="preprocessor">#include &lt;inttypes.h&gt;</span>
<a name="l00125"></a>00125 <span class="preprocessor">#include &quot;<a class="code" href="_l_c_d_8h.html">LCD.h</a>&quot;</span>
<a name="l00126"></a>00126 <span class="preprocessor">#include &quot;<a class="code" href="_fast_i_o_8h.html">FastIO.h</a>&quot;</span>
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 <span class="comment">// two-wire SR output bit constants</span>
<a name="l00130"></a>00130 <span class="comment">// ---------------------------------------------------------------------------</span>
<a name="l00131"></a>00131 
<a name="l00132"></a><a class="code" href="_liquid_crystal___s_r2_w_8h.html#a53e3add69865ae57ca872cb41fcae9e3">00132</a> <span class="preprocessor">#define SR2W_BL_MASK 0x02</span>
<a name="l00133"></a><a class="code" href="_liquid_crystal___s_r2_w_8h.html#acce98b026d9fdcb2e126705c14af7500">00133</a> <span class="preprocessor"></span><span class="preprocessor">#define SR2W_RS_MASK 0x04</span>
<a name="l00134"></a><a class="code" href="_liquid_crystal___s_r2_w_8h.html#a7cf86f2a173473d01e02b2ac786a8690">00134</a> <span class="preprocessor"></span><span class="preprocessor">#define SR2W_DATA_MASK 0x78     // data bits are hard coded to be SR bits 6,5,4,3</span>
<a name="l00135"></a><a class="code" href="_liquid_crystal___s_r2_w_8h.html#a8d17b6abb5bcde6883dbdc86d34be9d8">00135</a> <span class="preprocessor"></span><span class="preprocessor">#define SR2W_EN_MASK 0x80       // cannot ever be changed</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span>
<a name="l00137"></a><a class="code" href="class_liquid_crystal___s_r2_w.html">00137</a> <span class="keyword">class </span><a class="code" href="class_liquid_crystal___s_r2_w.html">LiquidCrystal_SR2W</a> : <span class="keyword">public</span> <a class="code" href="class_l_c_d.html">LCD</a>
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139 <span class="keyword">public</span>:
<a name="l00151"></a>00151    <a class="code" href="class_liquid_crystal___s_r2_w.html#af307fdf5c8feb757e965074dcdeb1dd3">LiquidCrystal_SR2W</a> (uint8_t srdata, uint8_t srclock, <a class="code" href="_l_c_d_8h.html#aeeef728bf4726268aa5e99391a1502bc">t_backlighPol</a> blpol = <a class="code" href="_l_c_d_8h.html#aeeef728bf4726268aa5e99391a1502bca03d440bbbfb042afc85347f994b44fb5">POSITIVE</a>);
<a name="l00152"></a>00152    
<a name="l00165"></a>00165    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_liquid_crystal___s_r2_w.html#a65dc6f261c319be8e56f3c1f6a5c877d">send</a>(uint8_t value, uint8_t mode);
<a name="l00166"></a>00166    
<a name="l00167"></a>00167    
<a name="l00177"></a>00177    <span class="keywordtype">void</span> <a class="code" href="class_liquid_crystal___s_r2_w.html#a2158db27287c1564a03e7a1472beb3b6">setBacklight</a> ( uint8_t mode );
<a name="l00178"></a>00178    
<a name="l00179"></a>00179 <span class="keyword">private</span>:
<a name="l00180"></a>00180    
<a name="l00186"></a>00186    <span class="keywordtype">void</span> init ( uint8_t srdata, uint8_t srclock, <a class="code" href="_l_c_d_8h.html#aeeef728bf4726268aa5e99391a1502bc">t_backlighPol</a> blpol, uint8_t lines, uint8_t font );
<a name="l00187"></a>00187    
<a name="l00192"></a>00192    <span class="keywordtype">void</span> loadSR (uint8_t val);
<a name="l00193"></a>00193    
<a name="l00194"></a>00194    <a class="code" href="_fast_i_o_8h.html#ae44ea3af54ef26db03f1ae2ea62f9c1f">fio_register</a> _srDataRegister; <span class="comment">// Serial Data pin</span>
<a name="l00195"></a>00195    <a class="code" href="_fast_i_o_8h.html#a0a595a88b29bcfd1540b6fac75787937">fio_bit</a> _srDataMask;
<a name="l00196"></a>00196    <a class="code" href="_fast_i_o_8h.html#ae44ea3af54ef26db03f1ae2ea62f9c1f">fio_register</a> _srClockRegister; <span class="comment">// Clock Pin</span>
<a name="l00197"></a>00197    <a class="code" href="_fast_i_o_8h.html#a0a595a88b29bcfd1540b6fac75787937">fio_bit</a> _srClockMask;
<a name="l00198"></a>00198 
<a name="l00199"></a>00199    uint8_t _blPolarity;
<a name="l00200"></a>00200    uint8_t _blMask;
<a name="l00201"></a>00201 };
<a name="l00202"></a>00202 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated on Thu Apr 5 2012 18:17:46 for LCD Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.