avr-lc7981/doc/html/lc7981_8h_source.html

188 lines
20 KiB
HTML

<!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>glcd: include/lc7981.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>include/lc7981.h</h1><a href="lc7981_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"> * lc7981.h</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Created on: 01.05.2009</span>
<a name="l00005"></a>00005 <span class="comment"> * Author: sebastian</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * Version 0.7 beta</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * The contents of this file are subject to the Mozilla Public License</span>
<a name="l00010"></a>00010 <span class="comment"> * Version 1.1 (the &quot;License&quot;); you may not use this file except in</span>
<a name="l00011"></a>00011 <span class="comment"> * compliance with the License. You may obtain a copy of the License at</span>
<a name="l00012"></a>00012 <span class="comment"> * http://www.mozilla.org/MPL/</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * Software distributed under the License is distributed on an &quot;AS IS&quot;</span>
<a name="l00015"></a>00015 <span class="comment"> * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the</span>
<a name="l00016"></a>00016 <span class="comment"> * License for the specific language governing rights and limitations</span>
<a name="l00017"></a>00017 <span class="comment"> * under the License.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * The Original Code is Sebastians AVR Library for lc7981.</span>
<a name="l00020"></a>00020 <span class="comment"> *</span>
<a name="l00021"></a>00021 <span class="comment"> * The Initial Developer of the Original Code is Sebastian Schumb (webmaster@sebastians-site.de).</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> * Contributor(s): None so far.</span>
<a name="l00024"></a>00024 <span class="comment"> *</span>
<a name="l00025"></a>00025 <span class="comment"> * Any version below 0.6 is still licensed under GPL.</span>
<a name="l00026"></a>00026 <span class="comment"> * The GPLed versions will neither be supported, nor developed any further.</span>
<a name="l00027"></a>00027 <span class="comment"> *</span>
<a name="l00028"></a>00028 <span class="comment"> * &apos;Do the thing you want to do and let your spirits guide you through.</span>
<a name="l00029"></a>00029 <span class="comment"> * Live a life, worth being remembered.&apos;</span>
<a name="l00030"></a>00030 <span class="comment"> * -- Remembered - Firewind --</span>
<a name="l00031"></a>00031 <span class="comment"> */</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#ifndef LC7981_H_</span>
<a name="l00035"></a><a class="code" href="lc7981_8h.html#ae6ff861bd55f4dc46f25f5f6abfca15f">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define LC7981_H_ LC7981_H_ </span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include &lt;avr/io.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;util/delay.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;avr/pgmspace.h&gt;</span>
<a name="l00040"></a>00040
<a name="l00041"></a><a class="code" href="lc7981_8h.html#a8e945df7ca614325cafa08258e82a63c">00041</a> <span class="preprocessor">#define LCD_CTRL PORTA </span>
<a name="l00042"></a><a class="code" href="lc7981_8h.html#a4b6c8400da9a1ca3d4d83f3ef1f9c34a">00042</a> <span class="preprocessor">#define LCD_CRTL_DDR DDRA </span>
<a name="l00043"></a><a class="code" href="lc7981_8h.html#a4781e073871c6f27f89b9463ad3a4ed1">00043</a> <span class="preprocessor">#define LCD_RS PA4 </span>
<a name="l00044"></a><a class="code" href="lc7981_8h.html#a26089a10ddd59a0dc7283c19ccc02533">00044</a> <span class="preprocessor">#define LCD_RW PA2 </span>
<a name="l00045"></a><a class="code" href="lc7981_8h.html#a1640ffbc0d8ec0f7edb04a2b93918072">00045</a> <span class="preprocessor">#define LCD_EN PA0 </span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor"></span>
<a name="l00048"></a>00048
<a name="l00049"></a><a class="code" href="lc7981_8h.html#a25e9d818788f36ed74d7c4579f87f2a6">00049</a> <span class="preprocessor">#define LCD_DATA PORTD </span>
<a name="l00050"></a><a class="code" href="lc7981_8h.html#abd18e47e71697a28fd0ca765cefc7411">00050</a> <span class="preprocessor">#define LCD_DATA_PIN PIND </span>
<a name="l00051"></a><a class="code" href="lc7981_8h.html#a0c114e723aa4c162c415fb6d4d963dd7">00051</a> <span class="preprocessor">#define LCD_DATA_DDR DDRD </span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a>00053 <span class="preprocessor"></span><span class="comment">// Macros for (un)setting the control pins</span>
<a name="l00054"></a><a class="code" href="lc7981_8h.html#a795b48274d3f80bc744a707b67fd93e9">00054</a> <span class="preprocessor">#define lcd_rs_high() (LCD_CTRL |= (1 &lt;&lt; LCD_RS)) </span>
<a name="l00055"></a><a class="code" href="lc7981_8h.html#a6edb13d59460246fb4cc32ada1c9f4a8">00055</a> <span class="preprocessor">#define lcd_rs_low() (LCD_CTRL &amp;= ~(1 &lt;&lt; LCD_RS)) </span>
<a name="l00056"></a>00056 <span class="preprocessor"></span>
<a name="l00057"></a><a class="code" href="lc7981_8h.html#ad0ce3cd9b481370ad4de36eff08440c8">00057</a> <span class="preprocessor"></span><span class="preprocessor">#define lcd_rw_high() (LCD_CTRL |= (1 &lt;&lt; LCD_RW)) </span>
<a name="l00058"></a><a class="code" href="lc7981_8h.html#a7f5ebe0ca71b1298a7d3423850cc82b1">00058</a> <span class="preprocessor">#define lcd_rw_low() (LCD_CTRL &amp;= ~(1 &lt;&lt; LCD_RW)) </span>
<a name="l00059"></a>00059 <span class="preprocessor"></span>
<a name="l00060"></a><a class="code" href="lc7981_8h.html#ae14be306d3620577abc8613d40401b04">00060</a> <span class="preprocessor"></span><span class="preprocessor">#define lcd_en_high() (LCD_CTRL |= (1 &lt;&lt; LCD_EN)) </span>
<a name="l00061"></a><a class="code" href="lc7981_8h.html#ad8dcdb36a9410fd96b2c936b7c9355dd">00061</a> <span class="preprocessor">#define lcd_en_low() (LCD_CTRL &amp;= ~(1 &lt;&lt; LCD_EN)) </span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>
<a name="l00063"></a>00063 <span class="preprocessor"></span>
<a name="l00064"></a><a class="code" href="lc7981_8h.html#a90a69d37f5c80f3ded970acf2dacf4c0">00064</a> <span class="preprocessor">#define LCD_TEXT 0 </span>
<a name="l00065"></a><a class="code" href="lc7981_8h.html#a720ef60606ac38ca3a5ab96a9c2b8168">00065</a> <span class="preprocessor">#define LCD_TEXT_LINES 10 </span>
<a name="l00066"></a><a class="code" href="lc7981_8h.html#a82f0a630f3c41b5233f2ceb07c7dd736">00066</a> <span class="preprocessor">#define LCD_TEXT_COLUMNS 26 </span>
<a name="l00067"></a>00067 <span class="preprocessor"></span>
<a name="l00068"></a><a class="code" href="lc7981_8h.html#adfaedf8da8e73d39a98d709b519a3117">00068</a> <span class="preprocessor"></span><span class="preprocessor">#define LCD_GRAPHIC 1 </span>
<a name="l00069"></a><a class="code" href="lc7981_8h.html#a51e83be6f6929f2a29d5467cd937dfc6">00069</a> <span class="preprocessor">#define LCD_GRAPHIC_WIDTH 160 </span>
<a name="l00070"></a><a class="code" href="lc7981_8h.html#a70265c4f840ef78872243e91c923af2f">00070</a> <span class="preprocessor">#define LCD_GRAPHIC_HEIGHT 80 </span>
<a name="l00071"></a><a class="code" href="lc7981_8h.html#aeb2d212a26da4a5a4d3231b2773023e5">00071</a> <span class="preprocessor">#define PIXEL_ON 1 </span>
<a name="l00072"></a><a class="code" href="lc7981_8h.html#acda2f1b1cf6310700d0d91643c40e068">00072</a> <span class="preprocessor">#define PIXEL_OFF 0 </span>
<a name="l00073"></a>00073 <span class="preprocessor"></span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a9b18aca098d68e55bd7dd4b83f4f36e9" title="lcd_init set the to default values.">lcd_init</a>(uint8_t mode);
<a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a35c08b1fa742e650f4873939707b893b" title="Clears the display by setting the whole memory to 0.">lcd_clear</a>(<span class="keywordtype">void</span>);
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a30251238a49999658455fdb0233757fb" title="Outputs text in at the current cursor position.">lcd_write_text</a>(<span class="keywordtype">char</span> *txt);
<a name="l00078"></a>00078 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#adbf47a5efdf02367ded1ebf8f9edb5fe" title="Set the display cursor to a specific location.">lcd_gotoxy</a>(uint8_t x, uint8_t y);
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a735111507ed83172f58d5af2953e31c6" title="set or unset a pixel at the specified location">lcd_plot_pixel</a>(uint8_t x, uint8_t y, uint8_t <span class="keyword">set</span>);
<a name="l00081"></a>00081 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#aa89be137ee35d3fd7e88782aafb0efdf" title="This function will plot a bitmap with the upper left corner to the given coordinates...">lcd_plot_bitmap</a>(uint8_t x, uint8_t y, PGM_P bitmap, uint8_t w, uint8_t h);
<a name="l00082"></a>00082 <span class="comment">//void lcd_plot_bitmap(uint8_t x, uint8_t y, PGM_P bitmap, uint8_t w, uint8_t h);</span>
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a2615737020b222e49a4d9c8d08a54f43" title="Plots a single character in graphicmode.">lcd_plot_char</a>(uint8_t x, uint8_t y_off, uint8_t c, uint8_t fw, uint8_t fh, PGM_P font);
<a name="l00085"></a>00085 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a71a77094675e2850e8a4b442fb6a366e" title="Plots a text using lcd_plot_char.">lcd_plot_text</a>(uint8_t x, uint8_t y_off, <span class="keyword">const</span> <span class="keywordtype">char</span> *text, uint8_t fw, uint8_t fh, PGM_P font);
<a name="l00086"></a>00086 <span class="keywordtype">void</span> <a class="code" href="lc7981_8c.html#a0af06316c8d3d3a57b1ddcf949d85a8c" title="Plots a text using lcd_plot_char.">lcd_plot_pgmtext</a>(uint8_t x, uint8_t y_off, PGM_P text, uint8_t fw, uint8_t fh, PGM_P font);
<a name="l00087"></a>00087
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="lc7981_8h.html#ae6e048011d567dd2859901544ebf7051" title="Generates the strobe signal for writing data.">lcd_strobe</a>(<span class="keywordtype">void</span>);
<a name="l00090"></a>00090 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(uint8_t cmd, uint8_t data);
<a name="l00091"></a>00091 <span class="keyword">static</span> <span class="keyword">inline</span> uint8_t <a class="code" href="lc7981_8h.html#a2753ae63b5b2e212d5dc101749b76249" title="Reads a byte from the display memory.">lcd_read_byte</a>(uint16_t pos);
<a name="l00092"></a>00092
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="comment">// Static inline functions, that can be used in the library and in the main programm</span>
<a name="l00095"></a>00095
<a name="l00096"></a>00096
<a name="l00101"></a><a class="code" href="lc7981_8h.html#ae6e048011d567dd2859901544ebf7051">00101</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="lc7981_8h.html#ae6e048011d567dd2859901544ebf7051" title="Generates the strobe signal for writing data.">lcd_strobe</a>(<span class="keywordtype">void</span>) {
<a name="l00102"></a>00102 <a class="code" href="lc7981_8h.html#ae14be306d3620577abc8613d40401b04" title="Set the strobe pin high.">lcd_en_high</a>();
<a name="l00103"></a>00103 _delay_us(1);
<a name="l00104"></a>00104 <a class="code" href="lc7981_8h.html#ad8dcdb36a9410fd96b2c936b7c9355dd" title="Set the strobe pin low.">lcd_en_low</a>();
<a name="l00105"></a>00105
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107
<a name="l00108"></a>00108
<a name="l00115"></a><a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1">00115</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(uint8_t cmd, uint8_t data) {
<a name="l00116"></a>00116 _delay_us(30);
<a name="l00117"></a>00117 <a class="code" href="lc7981_8h.html#a7f5ebe0ca71b1298a7d3423850cc82b1" title="Set the Register-Select pin low.">lcd_rw_low</a>();
<a name="l00118"></a>00118 <a class="code" href="lc7981_8h.html#a795b48274d3f80bc744a707b67fd93e9" title="Set the Register-Select pin high.">lcd_rs_high</a>();
<a name="l00119"></a>00119 <a class="code" href="lc7981_8h.html#a25e9d818788f36ed74d7c4579f87f2a6" title="Port used for data.">LCD_DATA</a> = cmd;
<a name="l00120"></a>00120 _delay_us(1);
<a name="l00121"></a>00121 <a class="code" href="lc7981_8h.html#ae6e048011d567dd2859901544ebf7051" title="Generates the strobe signal for writing data.">lcd_strobe</a>();
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <a class="code" href="lc7981_8h.html#a6edb13d59460246fb4cc32ada1c9f4a8" title="Set the Register-Select pin low.">lcd_rs_low</a>();
<a name="l00124"></a>00124 <a class="code" href="lc7981_8h.html#a25e9d818788f36ed74d7c4579f87f2a6" title="Port used for data.">LCD_DATA</a> = data;
<a name="l00125"></a>00125 _delay_us(1);
<a name="l00126"></a>00126 <a class="code" href="lc7981_8h.html#ae6e048011d567dd2859901544ebf7051" title="Generates the strobe signal for writing data.">lcd_strobe</a>();
<a name="l00127"></a>00127
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129
<a name="l00137"></a><a class="code" href="lc7981_8h.html#a2753ae63b5b2e212d5dc101749b76249">00137</a> <span class="keyword">static</span> <span class="keyword">inline</span> uint8_t <a class="code" href="lc7981_8h.html#a2753ae63b5b2e212d5dc101749b76249" title="Reads a byte from the display memory.">lcd_read_byte</a>(uint16_t pos) {
<a name="l00138"></a>00138 uint8_t i,data;
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(0x0A,(uint8_t) pos );
<a name="l00141"></a>00141 <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(0x0B,(uint8_t) (pos &gt;&gt; 8));
<a name="l00142"></a>00142
<a name="l00143"></a>00143 <span class="keywordflow">for</span>(i = 0; i &lt; 2; i++) {
<a name="l00144"></a>00144 _delay_us(30);
<a name="l00145"></a>00145 <a class="code" href="lc7981_8h.html#a7f5ebe0ca71b1298a7d3423850cc82b1" title="Set the Register-Select pin low.">lcd_rw_low</a>();
<a name="l00146"></a>00146 <a class="code" href="lc7981_8h.html#a795b48274d3f80bc744a707b67fd93e9" title="Set the Register-Select pin high.">lcd_rs_high</a>();
<a name="l00147"></a>00147 <a class="code" href="lc7981_8h.html#a25e9d818788f36ed74d7c4579f87f2a6" title="Port used for data.">LCD_DATA</a> = 0x0D;
<a name="l00148"></a>00148 _delay_us(1);
<a name="l00149"></a>00149 <a class="code" href="lc7981_8h.html#ae14be306d3620577abc8613d40401b04" title="Set the strobe pin high.">lcd_en_high</a>();
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <a class="code" href="lc7981_8h.html#a0c114e723aa4c162c415fb6d4d963dd7" title="Data-Direction-Register for data.">LCD_DATA_DDR</a> = 0x00;
<a name="l00152"></a>00152 <a class="code" href="lc7981_8h.html#a6edb13d59460246fb4cc32ada1c9f4a8" title="Set the Register-Select pin low.">lcd_rs_low</a>();
<a name="l00153"></a>00153 <a class="code" href="lc7981_8h.html#ad0ce3cd9b481370ad4de36eff08440c8" title="Set the Read-Write-Select pin high.">lcd_rw_high</a>();
<a name="l00154"></a>00154 _delay_us(1);
<a name="l00155"></a>00155 data = (uint8_t) <a class="code" href="lc7981_8h.html#abd18e47e71697a28fd0ca765cefc7411" title="Port used for reading the data.">LCD_DATA_PIN</a>;
<a name="l00156"></a>00156 <a class="code" href="lc7981_8h.html#ad8dcdb36a9410fd96b2c936b7c9355dd" title="Set the strobe pin low.">lcd_en_low</a>();
<a name="l00157"></a>00157 <a class="code" href="lc7981_8h.html#a0c114e723aa4c162c415fb6d4d963dd7" title="Data-Direction-Register for data.">LCD_DATA_DDR</a> = 0xFF;
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159 <span class="keywordflow">return</span> data;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a><a class="code" href="lc7981_8h.html#a9f832e526c77af56c35ff22032d934e7">00162</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="lc7981_8h.html#a9f832e526c77af56c35ff22032d934e7">lcd_write_byte</a>(uint16_t pos,uint8_t byte) {
<a name="l00163"></a>00163
<a name="l00164"></a>00164 <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(0x0A,(uint8_t) pos );
<a name="l00165"></a>00165 <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(0x0B,(uint8_t) (pos &gt;&gt; 8));
<a name="l00166"></a>00166 <a class="code" href="lc7981_8h.html#a31db85f1f48f4802c24218bc165ea4e1" title="Writes a command and a data byte to the lcd.">lcd_write_command</a>(0x0C,byte);
<a name="l00167"></a>00167
<a name="l00168"></a>00168
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170
<a name="l00171"></a>00171
<a name="l00172"></a>00172
<a name="l00173"></a>00173
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="preprocessor">#endif </span><span class="comment">/* LC7981_H_ */</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 27 Jun 2010 for glcd by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>