Landtiger (LPC1768) graphics LCD demo.

Dependencies:   mbed

Committer:
wim
Date:
Tue Nov 06 21:39:33 2012 +0000
Revision:
2:43ede88fb5a3
Parent:
0:a8090b59eb05
Child:
3:2dccfa0121de
cpp version and graphics test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:a8090b59eb05 1 /******************************************************************************/
wim 0:a8090b59eb05 2 /* GLCD.h: Graphic LCD function prototypes and defines */
wim 0:a8090b59eb05 3 /******************************************************************************/
wim 0:a8090b59eb05 4 /* This file is part of the uVision/ARM development tools. */
wim 0:a8090b59eb05 5 /* Copyright (c) 2005-2009 Keil Software. All rights reserved. */
wim 0:a8090b59eb05 6 /* This software may only be used under the terms of a valid, current, */
wim 0:a8090b59eb05 7 /* end user licence from KEIL for a compatible version of KEIL software */
wim 0:a8090b59eb05 8 /* development tools. Nothing else gives you the right to use this software. */
wim 0:a8090b59eb05 9 /******************************************************************************/
wim 0:a8090b59eb05 10
wim 0:a8090b59eb05 11 #ifndef _GLCD_H
wim 0:a8090b59eb05 12 #define _GLCD_H
wim 0:a8090b59eb05 13
wim 0:a8090b59eb05 14 /*------------------------------------------------------------------------------
wim 0:a8090b59eb05 15 Color coding
wim 0:a8090b59eb05 16 GLCD is coded: 15..11 red, 10..5 green, 4..0 blue (unsigned short) GLCD_R5, GLCD_G6, GLCD_B5
wim 0:a8090b59eb05 17 original coding: 17..12 red, 11..6 green, 5..0 blue ORG_R6, ORG_G6, ORG_B6
wim 0:a8090b59eb05 18
wim 0:a8090b59eb05 19 ORG_R1..5 = GLCD_R0..4, ORG_R0 = GLCD_R4
wim 0:a8090b59eb05 20 ORG_G0..5 = GLCD_G0..5,
wim 0:a8090b59eb05 21 ORG_B1..5 = GLCD_B0..4, ORG_B0 = GLCD_B4
wim 0:a8090b59eb05 22 *----------------------------------------------------------------------------*/
wim 0:a8090b59eb05 23
wim 0:a8090b59eb05 24 /* GLCD RGB color definitions */
wim 0:a8090b59eb05 25 #define Black 0x0000 /* 0, 0, 0 */
wim 0:a8090b59eb05 26 #define Navy 0x000F /* 0, 0, 128 */
wim 0:a8090b59eb05 27 #define DarkGreen 0x03E0 /* 0, 128, 0 */
wim 0:a8090b59eb05 28 #define DarkCyan 0x03EF /* 0, 128, 128 */
wim 0:a8090b59eb05 29 #define Maroon 0x7800 /* 128, 0, 0 */
wim 0:a8090b59eb05 30 #define Purple 0x780F /* 128, 0, 128 */
wim 0:a8090b59eb05 31 #define Olive 0x7BE0 /* 128, 128, 0 */
wim 0:a8090b59eb05 32 #define LightGrey 0xC618 /* 192, 192, 192 */
wim 0:a8090b59eb05 33 #define DarkGrey 0x7BEF /* 128, 128, 128 */
wim 0:a8090b59eb05 34 #define Blue 0x001F /* 0, 0, 255 */
wim 0:a8090b59eb05 35 #define Green 0x07E0 /* 0, 255, 0 */
wim 0:a8090b59eb05 36 #define Cyan 0x07FF /* 0, 255, 255 */
wim 0:a8090b59eb05 37 #define Red 0xF800 /* 255, 0, 0 */
wim 0:a8090b59eb05 38 #define Magenta 0xF81F /* 255, 0, 255 */
wim 0:a8090b59eb05 39 #define Yellow 0xFFE0 /* 255, 255, 0 */
wim 0:a8090b59eb05 40 #define White 0xFFFF /* 255, 255, 255 */
wim 0:a8090b59eb05 41
wim 2:43ede88fb5a3 42 // GLCD Controller IDs
wim 2:43ede88fb5a3 43 #define HX8347A_ID 0x0047
wim 0:a8090b59eb05 44 #define HX8347D_ID 0x0047
wim 0:a8090b59eb05 45 #define ILI9320_ID 0x9320
wim 0:a8090b59eb05 46 #define ILI9325_ID 0x9325
wim 2:43ede88fb5a3 47 #define ILI9325C_ID 0x9325
wim 2:43ede88fb5a3 48 #define ILI9325D_ID 0x9325
wim 2:43ede88fb5a3 49 #define ILI9328_ID 0x9328
wim 0:a8090b59eb05 50 #define ILI9331_ID 0x9331
wim 0:a8090b59eb05 51 #define LGDP4531_ID 0x4531
wim 0:a8090b59eb05 52 #define LGDP4535_ID 0x4535
wim 0:a8090b59eb05 53 #define R61505U_ID1 0x1505
wim 0:a8090b59eb05 54 #define R61505U_ID2 0x0505
wim 0:a8090b59eb05 55 #define SPFD5408B_ID 0x5408
wim 0:a8090b59eb05 56 #define SSD1289_ID 0x8989
wim 0:a8090b59eb05 57 #define SSD1298_ID 0x8999
wim 0:a8090b59eb05 58 #define SSD2119_ID 0x9919
wim 0:a8090b59eb05 59 #define ST7781_ID 0x7783
wim 0:a8090b59eb05 60
wim 0:a8090b59eb05 61
wim 2:43ede88fb5a3 62 #if(0)
wim 0:a8090b59eb05 63 /* GLCD Exported functions */
wim 0:a8090b59eb05 64 extern void GLCD_Init (void);
wim 0:a8090b59eb05 65 extern unsigned short GLCD_DriverCode ();
wim 0:a8090b59eb05 66 extern void GLCD_WindowMax (void);
wim 0:a8090b59eb05 67 extern void GLCD_PutPixel (unsigned int x, unsigned int y);
wim 0:a8090b59eb05 68 extern void GLCD_SetTextColor (unsigned short color);
wim 0:a8090b59eb05 69 extern void GLCD_SetBackColor (unsigned short color);
wim 2:43ede88fb5a3 70 extern void GLCD_clearScreen (unsigned short color);
wim 0:a8090b59eb05 71 extern void GLCD_DrawChar (unsigned int x, unsigned int y, unsigned short *c);
wim 0:a8090b59eb05 72 extern void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char c);
wim 0:a8090b59eb05 73 extern void GLCD_DisplayString (unsigned int ln, unsigned int col, unsigned char *s);
wim 0:a8090b59eb05 74 extern void GLCD_ClearLn (unsigned int ln);
wim 0:a8090b59eb05 75 extern void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
wim 0:a8090b59eb05 76 extern void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap);
wim 0:a8090b59eb05 77 extern void GLCD_Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp);
wim 0:a8090b59eb05 78
wim 0:a8090b59eb05 79 extern void GLCD_drawHLine (int x, int y, int l);
wim 0:a8090b59eb05 80 extern void GLCD_drawVLine (int x, int y, int l);
wim 0:a8090b59eb05 81 extern void GLCD_drawRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 82 #endif
wim 2:43ede88fb5a3 83
wim 2:43ede88fb5a3 84
wim 2:43ede88fb5a3 85 class GLCD {
wim 2:43ede88fb5a3 86 public:
wim 2:43ede88fb5a3 87 GLCD(void);
wim 2:43ede88fb5a3 88 void Init (void);
wim 2:43ede88fb5a3 89 void WindowMax (void);
wim 2:43ede88fb5a3 90 void Window (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 91 void drawPixel (unsigned int x, unsigned int y);
wim 2:43ede88fb5a3 92 void drawPixel (unsigned int x, unsigned int y, unsigned short color);
wim 2:43ede88fb5a3 93 void drawPixel (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b);
wim 2:43ede88fb5a3 94
wim 2:43ede88fb5a3 95 void setColor (unsigned short color);
wim 2:43ede88fb5a3 96 void setColor (uint8_t r, uint8_t g, uint8_t b);
wim 2:43ede88fb5a3 97 void setBackColor (unsigned short color);
wim 2:43ede88fb5a3 98 void setBackColor (uint8_t r, uint8_t g, uint8_t b);
wim 2:43ede88fb5a3 99
wim 2:43ede88fb5a3 100 void clearScreen (unsigned short color);
wim 2:43ede88fb5a3 101
wim 2:43ede88fb5a3 102 void DrawChar (unsigned int x, unsigned int y, unsigned short *c);
wim 2:43ede88fb5a3 103 void DisplayChar (unsigned int ln, unsigned int col, unsigned char c);
wim 2:43ede88fb5a3 104 void DisplayString (unsigned int ln, unsigned int col, unsigned char *s);
wim 2:43ede88fb5a3 105 void ClearLn (unsigned int ln);
wim 2:43ede88fb5a3 106 void Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
wim 2:43ede88fb5a3 107 void Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap);
wim 2:43ede88fb5a3 108 void Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp);
wim 2:43ede88fb5a3 109
wim 2:43ede88fb5a3 110 void drawHLine (int x, int y, int l);
wim 2:43ede88fb5a3 111 void drawVLine (int x, int y, int l);
wim 2:43ede88fb5a3 112 void drawRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 113 void drawLine (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 114 void drawRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 115 void fillRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 116 void fillRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 117 void drawCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 118 void fillCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 119
wim 2:43ede88fb5a3 120 void lcdOff();
wim 2:43ede88fb5a3 121 void lcdOn();
wim 2:43ede88fb5a3 122 void setContrast(char c);
wim 2:43ede88fb5a3 123
wim 2:43ede88fb5a3 124 int getDisplayXSize();
wim 2:43ede88fb5a3 125 int getDisplayYSize();
wim 2:43ede88fb5a3 126 unsigned short getDriverCode ();
wim 2:43ede88fb5a3 127
wim 2:43ede88fb5a3 128 unsigned short _textColor, _backColor;
wim 2:43ede88fb5a3 129
wim 2:43ede88fb5a3 130 private:
wim 2:43ede88fb5a3 131 static __inline unsigned char lcd_send (unsigned short data);
wim 2:43ede88fb5a3 132 static __inline unsigned short lcd_read (void);
wim 2:43ede88fb5a3 133 static __inline void wr_cmd (unsigned char c);
wim 2:43ede88fb5a3 134 static __inline void wr_dat (unsigned short c);
wim 2:43ede88fb5a3 135 static __inline unsigned short rd_dat (void);
wim 2:43ede88fb5a3 136 static __inline void wr_dat_start (void);
wim 2:43ede88fb5a3 137 static __inline void wr_dat_stop (void);
wim 2:43ede88fb5a3 138 static __inline void wr_dat_only (unsigned short c);
wim 2:43ede88fb5a3 139 static __inline void wr_reg (unsigned char reg, unsigned short val);
wim 2:43ede88fb5a3 140 static __inline unsigned short rd_reg (unsigned short reg);
wim 2:43ede88fb5a3 141
wim 2:43ede88fb5a3 142 unsigned short _driverCode;
wim 2:43ede88fb5a3 143 };
wim 0:a8090b59eb05 144
wim 0:a8090b59eb05 145 #endif /* _GLCD_H */