?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>Procyon AVRlib: glcd.c Source File</title>
4 <link href="dox.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.4.2 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
8 <h1>glcd.c</h1><a href="glcd_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file glcd.c \brief Graphic LCD API functions. */</span>
9 00002 <span class="comment">//*****************************************************************************</span>
10 00003 <span class="comment">//</span>
11 00004 <span class="comment">// File Name : 'glcd.c'</span>
12 00005 <span class="comment">// Title : Graphic LCD API functions</span>
13 00006 <span class="comment">// Author : Pascal Stang - Copyright (C) 2002</span>
14 00007 <span class="comment">// Date : 5/30/2002</span>
15 00008 <span class="comment">// Revised : 5/30/2002</span>
16 00009 <span class="comment">// Version : 0.5</span>
17 00010 <span class="comment">// Target MCU : Atmel AVR</span>
18 00011 <span class="comment">// Editor Tabs : 4</span>
19 00012 <span class="comment">//</span>
20 00013 <span class="comment">// NOTE: This code is currently below version 1.0, and therefore is considered</span>
21 00014 <span class="comment">// to be lacking in some functionality or documentation, or may not be fully</span>
22 00015 <span class="comment">// tested. Nonetheless, you can expect most functions to work.</span>
23 00016 <span class="comment">//</span>
24 00017 <span class="comment">// This code is distributed under the GNU Public License</span>
25 00018 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>
26 00019 <span class="comment">//</span>
27 00020 <span class="comment">//*****************************************************************************</span>
28 00021
29 00022 <span class="preprocessor">#ifndef WIN32</span>
30 00023 <span class="preprocessor"></span><span class="comment">// AVR specific includes</span>
31 00024 <span class="preprocessor"> #include &lt;avr/io.h&gt;</span>
32 00025 <span class="preprocessor"> #include &lt;avr/pgmspace.h&gt;</span>
33 00026 <span class="preprocessor">#endif</span>
34 00027 <span class="preprocessor"></span>
35 00028 <span class="preprocessor">#include "<a class="code" href="glcd_8h.html">glcd.h</a>"</span>
36 00029
37 00030 <span class="comment">// include hardware support</span>
38 00031 <span class="preprocessor">#include "<a class="code" href="ks0108_8h.html">ks0108.h</a>"</span>
39 00032 <span class="comment">// include fonts</span>
40 00033 <span class="preprocessor">#include "<a class="code" href="font5x7_8h.html">font5x7.h</a>"</span>
41 00034 <span class="preprocessor">#include "<a class="code" href="fontgr_8h.html">fontgr.h</a>"</span>
42 00035
43 00036 <span class="comment">// graphic routines</span>
44 00037
45 00038 <span class="comment">// set dot</span>
46 <a name="l00039"></a><a class="code" href="glcd_8h.html#a10">00039</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(u08 x, u08 y)
47 00040 {
48 00041 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> temp;
49 00042
50 00043 <a class="code" href="ks0108_8c.html#a15">glcdSetAddress</a>(x, y/8);
51 00044 temp = glcdDataRead(); <span class="comment">// dummy read</span>
52 00045 temp = glcdDataRead(); <span class="comment">// read back current value</span>
53 00046 <a class="code" href="ks0108_8c.html#a15">glcdSetAddress</a>(x, y/8);
54 00047 glcdDataWrite(temp | (1 &lt;&lt; (y % 8)));
55 00048
56 00049 <a class="code" href="ks0108_8c.html#a14">glcdStartLine</a>(0);
57 00050 }
58 00051
59 00052 <span class="comment">// clear dot</span>
60 <a name="l00053"></a><a class="code" href="glcd_8h.html#a11">00053</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a1">glcdClearDot</a>(u08 x, u08 y)
61 00054 {
62 00055 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> temp;
63 00056
64 00057 <a class="code" href="ks0108_8c.html#a15">glcdSetAddress</a>(x, y/8);
65 00058 temp = glcdDataRead(); <span class="comment">// dummy read</span>
66 00059 temp = glcdDataRead(); <span class="comment">// read back current value</span>
67 00060 <a class="code" href="ks0108_8c.html#a15">glcdSetAddress</a>(x, y/8);
68 00061 glcdDataWrite(temp &amp; ~(1 &lt;&lt; (y % 8)));
69 00062
70 00063 <a class="code" href="ks0108_8c.html#a14">glcdStartLine</a>(0);
71 00064 }
72 00065
73 00066 <span class="comment">// draw line</span>
74 <a name="l00067"></a><a class="code" href="glcd_8h.html#a12">00067</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a2">glcdLine</a>(u08 x1, u08 y1, u08 x2, u08 y2)
75 00068 {
76 00069 };
77 00070
78 00071 <span class="comment">// draw rectangle</span>
79 <a name="l00072"></a><a class="code" href="glcd_8h.html#a13">00072</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a3">glcdRectangle</a>(u08 x, u08 y, u08 a, u08 b)
80 00073 {
81 00074 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> j;
82 00075
83 00076 <span class="keywordflow">for</span> (j = 0; j &lt; a; j++) {
84 00077 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(x, y + j);
85 00078 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(x + b - 1, y + j);
86 00079 }
87 00080 <span class="keywordflow">for</span> (j = 0; j &lt; b; j++) {
88 00081 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(x + j, y);
89 00082 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(x + j, y + a - 1);
90 00083 }
91 00084 }
92 00085
93 00086 <span class="comment">// draw circle</span>
94 <a name="l00087"></a><a class="code" href="glcd_8h.html#a14">00087</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a4">glcdCircle</a>(u08 xcenter, u08 ycenter, u08 radius)
95 00088 {
96 00089 <span class="keywordtype">int</span> tswitch, y, x = 0;
97 00090 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> d;
98 00091
99 00092 d = ycenter - xcenter;
100 00093 y = radius;
101 00094 tswitch = 3 - 2 * radius;
102 00095 <span class="keywordflow">while</span> (x &lt;= y) {
103 00096 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(xcenter + x, ycenter + y); <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(xcenter + x, ycenter - y);
104 00097 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(xcenter - x, ycenter + y); <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(xcenter - x, ycenter - y);
105 00098 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(ycenter + y - d, ycenter + x); <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(ycenter + y - d, ycenter - x);
106 00099 <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(ycenter - y - d, ycenter + x); <a class="code" href="glcd_8c.html#a0">glcdSetDot</a>(ycenter - y - d, ycenter - x);
107 00100
108 00101 <span class="keywordflow">if</span> (tswitch &lt; 0) tswitch += (4 * x + 6);
109 00102 <span class="keywordflow">else</span> {
110 00103 tswitch += (4 * (x - y) + 10);
111 00104 y--;
112 00105 }
113 00106 x++;
114 00107 }
115 00108 }
116 00109
117 00110 <span class="comment">// text routines</span>
118 00111
119 00112 <span class="comment">// write a character at the current position</span>
120 <a name="l00113"></a><a class="code" href="glcd_8h.html#a15">00113</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a5">glcdWriteChar</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c)
121 00114 {
122 00115 u08 i = 0;
123 00116
124 00117 <span class="keywordflow">for</span>(i=0; i&lt;5; i++)
125 00118 {
126 00119 glcdDataWrite(pgm_read_byte(&amp;Font5x7[((c - 0x20) * 5) + i]));
127 00120 }
128 00121
129 00122 <span class="comment">// write a spacer line</span>
130 00123 glcdDataWrite(0x00);
131 00124 <span class="comment">// unless we're at the end of the display</span>
132 00125 <span class="comment">//if(xx == 128)</span>
133 00126 <span class="comment">// xx = 0;</span>
134 00127 <span class="comment">//else </span>
135 00128 <span class="comment">// glcdWriteData(0x00);</span>
136 00129
137 00130 <span class="comment">//cbi(GLCD_Control, GLCD_CS1);</span>
138 00131 <span class="comment">//cbi(GLCD_Control, GLCD_CS2);</span>
139 00132 <a class="code" href="ks0108_8c.html#a14">glcdStartLine</a>(0);
140 00133 }
141 00134
142 <a name="l00135"></a><a class="code" href="glcd_8h.html#a16">00135</a> <span class="keywordtype">void</span> <a class="code" href="glcd_8c.html#a6">glcdWriteCharGr</a>(u08 grCharIdx)
143 00136 {
144 00137 u08 idx;
145 00138 u08 grLength;
146 00139 u08 grStartIdx = 0;
147 00140
148 00141 <span class="comment">// get starting index of graphic bitmap</span>
149 00142 <span class="keywordflow">for</span>(idx=0; idx&lt;grCharIdx; idx++)
150 00143 {
151 00144 <span class="comment">// add this graphic's length to the startIdx</span>
152 00145 <span class="comment">// to get the startIdx of the next one</span>
153 00146 grStartIdx += pgm_read_byte(FontGr+grStartIdx);
154 00147 }
155 00148 grLength = pgm_read_byte(FontGr+grStartIdx);
156 00149
157 00150 <span class="comment">// write the lines of the desired graphic to the display</span>
158 00151 <span class="keywordflow">for</span>(idx=0; idx&lt;grLength; idx++)
159 00152 {
160 00153 <span class="comment">// write the line</span>
161 00154 glcdDataWrite(pgm_read_byte(FontGr+(grStartIdx+1)+idx));
162 00155 }
163 00156 }
164 00157
165 00158 <span class="keywordtype">void</span> glcdPutStr(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *data)
166 00159 {
167 00160 <span class="keywordflow">while</span> (*data) {
168 00161 <a class="code" href="glcd_8c.html#a5">glcdWriteChar</a>(*data);
169 00162 data++;
170 00163 }
171 00164 }
172 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by&nbsp;
173 <a href="http://www.doxygen.org/index.html">
174 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
175 </body>
176 </html>
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3