Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * HIMAX HX8347 LCD controllers driver |
||
4 | ***************************************************************************** |
||
5 | * FileName: HX8347.h |
||
6 | * Dependencies: p24Fxxxx.h or plib.h |
||
7 | * Processor: PIC24, PIC32 |
||
8 | * Compiler: MPLAB C30, MPLAB C32 |
||
9 | * Linker: MPLAB LINK30, MPLAB LINK32 |
||
10 | * Company: Microchip Technology Incorporated |
||
11 | * |
||
12 | * Software License Agreement |
||
13 | * |
||
14 | * Copyright © 2009 Microchip Technology Inc. All rights reserved. |
||
15 | * Microchip licenses to you the right to use, modify, copy and distribute |
||
16 | * Software only when embedded on a Microchip microcontroller or digital |
||
17 | * signal controller, which is integrated into your product or third party |
||
18 | * product (pursuant to the sublicense terms in the accompanying license |
||
19 | * agreement). |
||
20 | * |
||
21 | * You should refer to the license agreement accompanying this Software |
||
22 | * for additional information regarding your rights and obligations. |
||
23 | * |
||
24 | * SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY |
||
25 | * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
26 | * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR |
||
27 | * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR |
||
28 | * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, |
||
29 | * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT |
||
30 | * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, |
||
31 | * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
32 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY |
||
33 | * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), |
||
34 | * OR OTHER SIMILAR COSTS. |
||
35 | * |
||
36 | * Author Date Comment |
||
37 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
38 | * Anton Alkhimenok 05/26/09 |
||
39 | *****************************************************************************/ |
||
40 | #ifndef _HX8347_H |
||
41 | #define _HX8347_H |
||
42 | |||
43 | #ifdef __PIC32MX |
||
44 | #include <plib.h> |
||
45 | #define PMDIN1 PMDIN |
||
46 | #else |
||
47 | #ifdef __PIC24F__ |
||
48 | #include <p24Fxxxx.h> |
||
49 | #else |
||
50 | #error CONTROLLER IS NOT SUPPORTED |
||
51 | #endif |
||
52 | #endif |
||
53 | #include "GraphicsConfig.h" |
||
54 | #include "GenericTypeDefs.h" |
||
55 | |||
56 | /********************************************************************* |
||
57 | * Overview: Additional hardware-accelerated functions can be implemented |
||
58 | * in the driver. These definitions exclude the PutPixel()-based |
||
59 | * functions in the primitives layer (Primitive.c file) from compilation. |
||
60 | *********************************************************************/ |
||
61 | |||
62 | // Define this to implement Font related functions in the driver. |
||
63 | //#define USE_DRV_FONT |
||
64 | // Define this to implement Line function in the driver. |
||
65 | //#define USE_DRV_LINE |
||
66 | // Define this to implement Circle function in the driver. |
||
67 | //#define USE_DRV_CIRCLE |
||
68 | // Define this to implement FillCircle function in the driver. |
||
69 | //#define USE_DRV_FILLCIRCLE |
||
70 | // Define this to implement Bar function in the driver. |
||
71 | #define USE_DRV_BAR |
||
72 | |||
73 | // Define this to implement ClearDevice function in the driver. |
||
74 | #define USE_DRV_CLEARDEVICE |
||
75 | |||
76 | // Define this to implement PutImage function in the driver. |
||
77 | #define USE_DRV_PUTIMAGE |
||
78 | |||
79 | #ifndef DISP_HOR_RESOLUTION |
||
80 | #error DISP_HOR_RESOLUTION must be defined in HardwareProfile.h |
||
81 | #endif |
||
82 | #ifndef DISP_VER_RESOLUTION |
||
83 | #error DISP_VER_RESOLUTION must be defined in HardwareProfile.h |
||
84 | #endif |
||
85 | #ifndef COLOR_DEPTH |
||
86 | #error COLOR_DEPTH must be defined in HardwareProfile.h |
||
87 | #endif |
||
88 | #ifndef DISP_ORIENTATION |
||
89 | #error DISP_ORIENTATION must be defined in HardwareProfile.h |
||
90 | #endif |
||
91 | |||
92 | /********************************************************************* |
||
93 | * Overview: Horizontal and vertical screen size. |
||
94 | *********************************************************************/ |
||
95 | #if (DISP_HOR_RESOLUTION != 240) |
||
96 | #error This driver doesn't supports this resolution. Horisontal resolution must be 240 pixels. |
||
97 | #endif |
||
98 | #if (DISP_VER_RESOLUTION != 320) |
||
99 | #error This driver doesn't supports this resolution. Vertical resolution must be 320 pixels. |
||
100 | #endif |
||
101 | |||
102 | /********************************************************************* |
||
103 | * Overview: Display orientation. |
||
104 | *********************************************************************/ |
||
105 | #if (DISP_ORIENTATION != 0) && (DISP_ORIENTATION != 90) |
||
106 | #error This driver doesn't support this orientation. |
||
107 | #endif |
||
108 | |||
109 | /********************************************************************* |
||
110 | * Overview: Color depth. |
||
111 | *********************************************************************/ |
||
112 | #if (COLOR_DEPTH != 16) |
||
113 | #error This driver doesn't support this color depth. It should be 16. |
||
114 | #endif |
||
115 | |||
116 | /********************************************************************* |
||
117 | * Overview: Clipping region control codes to be used with SetClip(...) |
||
118 | * function. |
||
119 | *********************************************************************/ |
||
120 | #define CLIP_DISABLE 0 // Disables clipping. |
||
121 | #define CLIP_ENABLE 1 // Enables clipping. |
||
122 | |||
123 | /********************************************************************* |
||
124 | * Overview: Some basic colors definitions. |
||
125 | *********************************************************************/ |
||
126 | #define BLACK RGB565CONVERT(0, 0, 0) |
||
127 | #define BRIGHTBLUE RGB565CONVERT(0, 0, 255) |
||
128 | #define BRIGHTGREEN RGB565CONVERT(0, 255, 0) |
||
129 | #define BRIGHTCYAN RGB565CONVERT(0, 255, 255) |
||
130 | #define BRIGHTRED RGB565CONVERT(255, 0, 0) |
||
131 | #define BRIGHTMAGENTA RGB565CONVERT(255, 0, 255) |
||
132 | #define BRIGHTYELLOW RGB565CONVERT(255, 255, 0) |
||
133 | #define BLUE RGB565CONVERT(0, 0, 128) |
||
134 | #define GREEN RGB565CONVERT(0, 128, 0) |
||
135 | #define CYAN RGB565CONVERT(0, 128, 128) |
||
136 | #define RED RGB565CONVERT(128, 0, 0) |
||
137 | #define MAGENTA RGB565CONVERT(128, 0, 128) |
||
138 | #define BROWN RGB565CONVERT(255, 128, 0) |
||
139 | #define LIGHTGRAY RGB565CONVERT(128, 128, 128) |
||
140 | #define DARKGRAY RGB565CONVERT(64, 64, 64) |
||
141 | #define LIGHTBLUE RGB565CONVERT(128, 128, 255) |
||
142 | #define LIGHTGREEN RGB565CONVERT(128, 255, 128) |
||
143 | #define LIGHTCYAN RGB565CONVERT(128, 255, 255) |
||
144 | #define LIGHTRED RGB565CONVERT(255, 128, 128) |
||
145 | #define LIGHTMAGENTA RGB565CONVERT(255, 128, 255) |
||
146 | #define YELLOW RGB565CONVERT(255, 255, 128) |
||
147 | #define WHITE RGB565CONVERT(255, 255, 255) |
||
148 | #define GRAY0 RGB565CONVERT(224, 224, 224) |
||
149 | #define GRAY1 RGB565CONVERT(192, 192, 192) |
||
150 | #define GRAY2 RGB565CONVERT(160, 160, 160) |
||
151 | #define GRAY3 RGB565CONVERT(128, 128, 128) |
||
152 | #define GRAY4 RGB565CONVERT(96, 96, 96) |
||
153 | #define GRAY5 RGB565CONVERT(64, 64, 64) |
||
154 | #define GRAY6 RGB565CONVERT(32, 32, 32) |
||
155 | |||
156 | // Color |
||
157 | extern WORD _color; |
||
158 | |||
159 | /********************************************************************* |
||
160 | * Overview: Clipping region control and border settings. |
||
161 | * |
||
162 | *********************************************************************/ |
||
163 | |||
164 | // Clipping region enable control |
||
165 | extern SHORT _clipRgn; |
||
166 | |||
167 | // Left clipping region border |
||
168 | extern SHORT _clipLeft; |
||
169 | |||
170 | // Top clipping region border |
||
171 | extern SHORT _clipTop; |
||
172 | |||
173 | // Right clipping region border |
||
174 | extern SHORT _clipRight; |
||
175 | |||
176 | // Bottom clipping region border |
||
177 | extern SHORT _clipBottom; |
||
178 | |||
179 | |||
180 | /********************************************************************* |
||
181 | * Function: void ResetDevice() |
||
182 | * |
||
183 | * Overview: Initializes LCD module. |
||
184 | * |
||
185 | * PreCondition: none |
||
186 | * |
||
187 | * Input: none |
||
188 | * |
||
189 | * Output: none |
||
190 | * |
||
191 | * Side Effects: none |
||
192 | * |
||
193 | ********************************************************************/ |
||
194 | void ResetDevice(void); |
||
195 | |||
196 | /********************************************************************* |
||
197 | * Macros: GetMaxX() |
||
198 | * |
||
199 | * Overview: Returns maximum horizontal coordinate. |
||
200 | * |
||
201 | * PreCondition: none |
||
202 | * |
||
203 | * Input: none |
||
204 | * |
||
205 | * Output: Maximum horizontal coordinate. |
||
206 | * |
||
207 | * Example: |
||
208 | * <CODE> |
||
209 | * |
||
210 | * // Create a window that will occupy the whole screen. |
||
211 | * WndCreate(0xFF, // ID |
||
212 | * 0,0, |
||
213 | * GetMaxX(),GetMaxY(), // dimension |
||
214 | * WND_DRAW, // will be dislayed after creation |
||
215 | * (void*)&mchpIcon, // use icon used |
||
216 | * pText, // set to text pointed to by pText |
||
217 | * NULL); // use default scheme |
||
218 | * |
||
219 | * </CODE> |
||
220 | * |
||
221 | * Side Effects: none |
||
222 | * |
||
223 | ********************************************************************/ |
||
224 | #if (DISP_ORIENTATION == 90) |
||
225 | #define GetMaxX() (DISP_VER_RESOLUTION - 1) |
||
226 | #elif (DISP_ORIENTATION == 0) |
||
227 | #define GetMaxX() (DISP_HOR_RESOLUTION - 1) |
||
228 | #endif |
||
229 | |||
230 | /********************************************************************* |
||
231 | * Macros: GetMaxY() |
||
232 | * |
||
233 | * Overview: Returns maximum vertical coordinate. |
||
234 | * |
||
235 | * PreCondition: none |
||
236 | * |
||
237 | * Input: none |
||
238 | * |
||
239 | * Output: Maximum vertical coordinate. |
||
240 | * |
||
241 | * Example: (see GetMaxX()) example. |
||
242 | * |
||
243 | * Side Effects: none |
||
244 | * |
||
245 | ********************************************************************/ |
||
246 | #if (DISP_ORIENTATION == 90) |
||
247 | #define GetMaxY() (DISP_HOR_RESOLUTION - 1) |
||
248 | #elif (DISP_ORIENTATION == 0) |
||
249 | #define GetMaxY() (DISP_VER_RESOLUTION - 1) |
||
250 | #endif |
||
251 | |||
252 | /********************************************************************* |
||
253 | * Macros: SetColor(color) |
||
254 | * |
||
255 | * Overview: Sets current drawing color. |
||
256 | * |
||
257 | * PreCondition: none |
||
258 | * |
||
259 | * Input: color - Color coded in 5:6:5 RGB format. |
||
260 | * |
||
261 | * Output: none |
||
262 | * |
||
263 | * Side Effects: none |
||
264 | * |
||
265 | ********************************************************************/ |
||
266 | #define SetColor(color) _color = color; |
||
267 | |||
268 | /********************************************************************* |
||
269 | * Macros: GetColor() |
||
270 | * |
||
271 | * Overview: Returns current drawing color. |
||
272 | * |
||
273 | * PreCondition: none |
||
274 | * |
||
275 | * Input: none |
||
276 | * |
||
277 | * Output: Color coded in 5:6:5 RGB format. |
||
278 | * |
||
279 | * Side Effects: none |
||
280 | * |
||
281 | ********************************************************************/ |
||
282 | #define GetColor() _color |
||
283 | |||
284 | /********************************************************************* |
||
285 | * Macros: SetActivePage(page) |
||
286 | * |
||
287 | * Overview: Sets active graphic page. |
||
288 | * |
||
289 | * PreCondition: none |
||
290 | * |
||
291 | * Input: page - Graphic page number. |
||
292 | * |
||
293 | * Output: none |
||
294 | * |
||
295 | * Side Effects: none |
||
296 | * |
||
297 | ********************************************************************/ |
||
298 | #define SetActivePage(page) |
||
299 | |||
300 | /********************************************************************* |
||
301 | * Macros: SetVisualPage(page) |
||
302 | * |
||
303 | * Overview: Sets graphic page to display. |
||
304 | * |
||
305 | * PreCondition: none |
||
306 | * |
||
307 | * Input: page - Graphic page number |
||
308 | * |
||
309 | * Output: none |
||
310 | * |
||
311 | * Side Effects: none |
||
312 | * |
||
313 | ********************************************************************/ |
||
314 | #define SetVisualPage(page) |
||
315 | |||
316 | /********************************************************************* |
||
317 | * Function: void PutPixel(SHORT x, SHORT y) |
||
318 | * |
||
319 | * Overview: Puts pixel with the given x,y coordinate position. |
||
320 | * |
||
321 | * PreCondition: none |
||
322 | * |
||
323 | * Input: x - x position of the pixel. |
||
324 | * y - y position of the pixel. |
||
325 | * |
||
326 | * Output: none |
||
327 | * |
||
328 | * Side Effects: none |
||
329 | * |
||
330 | ********************************************************************/ |
||
331 | void PutPixel(SHORT x, SHORT y); |
||
332 | |||
333 | /********************************************************************* |
||
334 | * Function: WORD GetPixel(SHORT x, SHORT y) |
||
335 | * |
||
336 | * Overview: Returns pixel color at the given x,y coordinate position. |
||
337 | * |
||
338 | * PreCondition: none |
||
339 | * |
||
340 | * Input: x - x position of the pixel. |
||
341 | * y - y position of the pixel. |
||
342 | * |
||
343 | * Output: pixel color |
||
344 | * |
||
345 | * Side Effects: none |
||
346 | * |
||
347 | ********************************************************************/ |
||
348 | WORD GetPixel(SHORT x, SHORT y); |
||
349 | |||
350 | /********************************************************************* |
||
351 | * Macros: SetClipRgn(left, top, right, bottom) |
||
352 | * |
||
353 | * Overview: Sets clipping region. |
||
354 | * |
||
355 | * PreCondition: none |
||
356 | * |
||
357 | * Input: left - Defines the left clipping region border. |
||
358 | * top - Defines the top clipping region border. |
||
359 | * right - Defines the right clipping region border. |
||
360 | * bottom - Defines the bottom clipping region border. |
||
361 | * |
||
362 | * Output: none |
||
363 | * |
||
364 | * Side Effects: none |
||
365 | * |
||
366 | ********************************************************************/ |
||
367 | #define SetClipRgn(left, top, right, bottom) \ |
||
368 | _clipLeft = left; \ |
||
369 | _clipTop = top; \ |
||
370 | _clipRight = right; \ |
||
371 | _clipBottom = bottom; |
||
372 | |||
373 | /********************************************************************* |
||
374 | * Macros: GetClipLeft() |
||
375 | * |
||
376 | * Overview: Returns left clipping border. |
||
377 | * |
||
378 | * PreCondition: none |
||
379 | * |
||
380 | * Input: none |
||
381 | * |
||
382 | * Output: Left clipping border. |
||
383 | * |
||
384 | * Side Effects: none |
||
385 | * |
||
386 | ********************************************************************/ |
||
387 | #define GetClipLeft() _clipLeft |
||
388 | |||
389 | /********************************************************************* |
||
390 | * Macros: GetClipRight() |
||
391 | * |
||
392 | * Overview: Returns right clipping border. |
||
393 | * |
||
394 | * PreCondition: none |
||
395 | * |
||
396 | * Input: none |
||
397 | * |
||
398 | * Output: Right clipping border. |
||
399 | * |
||
400 | * Side Effects: none |
||
401 | * |
||
402 | ********************************************************************/ |
||
403 | #define GetClipRight() _clipRight |
||
404 | |||
405 | /********************************************************************* |
||
406 | * Macros: GetClipTop() |
||
407 | * |
||
408 | * Overview: Returns top clipping border. |
||
409 | * |
||
410 | * PreCondition: none |
||
411 | * |
||
412 | * Input: none |
||
413 | * |
||
414 | * Output: Top clipping border. |
||
415 | * |
||
416 | * Side Effects: none |
||
417 | * |
||
418 | ********************************************************************/ |
||
419 | #define GetClipTop() _clipTop |
||
420 | |||
421 | /********************************************************************* |
||
422 | * Macros: GetClipBottom() |
||
423 | * |
||
424 | * Overview: Returns bottom clipping border. |
||
425 | * |
||
426 | * PreCondition: none |
||
427 | * |
||
428 | * Input: none |
||
429 | * |
||
430 | * Output: Bottom clipping border. |
||
431 | * |
||
432 | * Side Effects: none |
||
433 | * |
||
434 | ********************************************************************/ |
||
435 | #define GetClipBottom() _clipBottom |
||
436 | |||
437 | /********************************************************************* |
||
438 | * Macros: SetClip(control) |
||
439 | * |
||
440 | * Overview: Enables/disables clipping. |
||
441 | * |
||
442 | * PreCondition: none |
||
443 | * |
||
444 | * Input: control - Enables or disables the clipping. |
||
445 | * - 0: Disable clipping |
||
446 | * - 1: Enable clipping |
||
447 | * |
||
448 | * Output: none |
||
449 | * |
||
450 | * Side Effects: none |
||
451 | * |
||
452 | ********************************************************************/ |
||
453 | #define SetClip(control) _clipRgn = control; |
||
454 | |||
455 | /********************************************************************* |
||
456 | * Macros: IsDeviceBusy() |
||
457 | * |
||
458 | * Overview: Returns non-zero if LCD controller is busy |
||
459 | * (previous drawing operation is not completed). |
||
460 | * |
||
461 | * PreCondition: none |
||
462 | * |
||
463 | * Input: none |
||
464 | * |
||
465 | * Output: Busy status. |
||
466 | * |
||
467 | * Side Effects: none |
||
468 | * |
||
469 | ********************************************************************/ |
||
470 | #define IsDeviceBusy() 0 |
||
471 | |||
472 | /********************************************************************* |
||
473 | * Macros: SetPalette(colorNum, color) |
||
474 | * |
||
475 | * Overview: Sets palette register. |
||
476 | * |
||
477 | * PreCondition: none |
||
478 | * |
||
479 | * Input: colorNum - Register number. |
||
480 | * color - Color. |
||
481 | * |
||
482 | * Output: none |
||
483 | * |
||
484 | * Side Effects: none |
||
485 | * |
||
486 | ********************************************************************/ |
||
487 | #define SetPalette(colorNum, color) |
||
488 | |||
489 | /********************************************************************* |
||
490 | * Function: void DelayMs(WORD time) |
||
491 | * |
||
492 | * Overview: Delays execution on time specified in milliseconds. |
||
493 | * The delay is correct only for 16MIPS. |
||
494 | * |
||
495 | * PreCondition: none |
||
496 | * |
||
497 | * Input: time - Delay in milliseconds. |
||
498 | * |
||
499 | * Output: none |
||
500 | * |
||
501 | * Side Effects: none |
||
502 | * |
||
503 | ********************************************************************/ |
||
504 | void DelayMs(WORD time); |
||
505 | #endif // _HX8347_H |
Powered by WebSVN v2.8.3