Landtiger (LPC1768) graphics LCD demo.

Dependencies:   mbed

Committer:
wim
Date:
Tue Nov 24 22:33:20 2015 +0000
Revision:
4:cdeea87f25d8
Parent:
3:2dccfa0121de
Demo LandTiger LPC1768 board with SSD1289 LCD

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 3:2dccfa0121de 16 GLCD is coded: 15..11 red, 10..5 green, 4..0 blue (uint16_t) 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 3:2dccfa0121de 62 class GLCD : public Stream {
wim 3:2dccfa0121de 63 //class GLCD {
wim 3:2dccfa0121de 64 public:
wim 3:2dccfa0121de 65 GLCD(void);
wim 3:2dccfa0121de 66 void init (void);
wim 3:2dccfa0121de 67
wim 3:2dccfa0121de 68 // Stream implementation - provides printf() interface
wim 3:2dccfa0121de 69 // You would otherwise be forced to use writeChar()
wim 4:cdeea87f25d8 70 virtual int _putc(int value);
wim 4:cdeea87f25d8 71 virtual int _getc();
wim 3:2dccfa0121de 72
wim 3:2dccfa0121de 73 void setWindowMax (void);
wim 3:2dccfa0121de 74 void setWindow (int x1, int y1, int x2, int y2);
wim 3:2dccfa0121de 75 void drawPixel (unsigned int x, unsigned int y);
wim 3:2dccfa0121de 76 void drawPixel (unsigned int x, unsigned int y, uint16_t color);
wim 3:2dccfa0121de 77 void drawPixel (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b);
wim 3:2dccfa0121de 78
wim 3:2dccfa0121de 79 void setColor (uint16_t color);
wim 3:2dccfa0121de 80 void setColor (uint8_t r, uint8_t g, uint8_t b);
wim 3:2dccfa0121de 81 void setBackColor (uint16_t color);
wim 3:2dccfa0121de 82 void setBackColor (uint8_t r, uint8_t g, uint8_t b);
wim 0:a8090b59eb05 83
wim 4:cdeea87f25d8 84 void cls (uint16_t color);
wim 4:cdeea87f25d8 85 void locate (int16_t ln, uint16_t col) {
wim 4:cdeea87f25d8 86 _ln = ln;
wim 4:cdeea87f25d8 87 _col = col;
wim 4:cdeea87f25d8 88 };
wim 2:43ede88fb5a3 89
wim 3:2dccfa0121de 90 /** @brief Write single character to the display using the 8x8 fontable
wim 3:2dccfa0121de 91 * @brief Start at current cursor location
wim 3:2dccfa0121de 92 * @param char chr character to write
wim 3:2dccfa0121de 93 */
wim 3:2dccfa0121de 94 void writeChar (uint8_t chr);
wim 4:cdeea87f25d8 95
wim 4:cdeea87f25d8 96 /*******************************************************************************
wim 4:cdeea87f25d8 97 * Draw character on given screen position *
wim 4:cdeea87f25d8 98 * Parameter: x: horizontal position *
wim 4:cdeea87f25d8 99 * y: vertical position *
wim 4:cdeea87f25d8 100 * c: pointer to character bitmap *
wim 4:cdeea87f25d8 101 * Return: *
wim 4:cdeea87f25d8 102 *******************************************************************************/
wim 3:2dccfa0121de 103 void DrawChar (unsigned int x, unsigned int y, uint16_t *c);
wim 4:cdeea87f25d8 104
wim 4:cdeea87f25d8 105 /*******************************************************************************
wim 4:cdeea87f25d8 106 * Display character on given line *
wim 4:cdeea87f25d8 107 * Parameter: ln: line number *
wim 4:cdeea87f25d8 108 * col: column number *
wim 4:cdeea87f25d8 109 * c: ascii character *
wim 4:cdeea87f25d8 110 * Return: *
wim 4:cdeea87f25d8 111 *******************************************************************************/
wim 3:2dccfa0121de 112 void DisplayChar (uint16_t ln, uint16_t col, uint8_t c);
wim 4:cdeea87f25d8 113
wim 4:cdeea87f25d8 114 /*******************************************************************************
wim 4:cdeea87f25d8 115 * Disply string on given line *
wim 4:cdeea87f25d8 116 * Parameter: ln: line number *
wim 4:cdeea87f25d8 117 * col: column number *
wim 4:cdeea87f25d8 118 * s: pointer to string *
wim 4:cdeea87f25d8 119 * Return: *
wim 4:cdeea87f25d8 120 *******************************************************************************/
wim 3:2dccfa0121de 121 void DisplayString (uint16_t ln, uint16_t col, uint8_t *s);
wim 3:2dccfa0121de 122 void ClearLn (uint16_t ln);
wim 4:cdeea87f25d8 123
wim 2:43ede88fb5a3 124 void Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
wim 3:2dccfa0121de 125 void Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bitmap);
wim 3:2dccfa0121de 126 void Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bmp);
wim 2:43ede88fb5a3 127
wim 2:43ede88fb5a3 128 void drawHLine (int x, int y, int l);
wim 2:43ede88fb5a3 129 void drawVLine (int x, int y, int l);
wim 2:43ede88fb5a3 130 void drawRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 131 void drawLine (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 132 void drawRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 133 void fillRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 134 void fillRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 135 void drawCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 136 void fillCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 137
wim 2:43ede88fb5a3 138 void lcdOff();
wim 2:43ede88fb5a3 139 void lcdOn();
wim 3:2dccfa0121de 140 void invertDisplay(bool i);
wim 3:2dccfa0121de 141 void setContrast(uint8_t c);
wim 2:43ede88fb5a3 142
wim 2:43ede88fb5a3 143 int getDisplayXSize();
wim 2:43ede88fb5a3 144 int getDisplayYSize();
wim 4:cdeea87f25d8 145 int getRows();
wim 4:cdeea87f25d8 146 int getCols();
wim 4:cdeea87f25d8 147
wim 3:2dccfa0121de 148 uint16_t getDriverCode ();
wim 2:43ede88fb5a3 149
wim 2:43ede88fb5a3 150 private:
wim 3:2dccfa0121de 151 static __inline uint8_t _lcd_send (uint16_t data);
wim 3:2dccfa0121de 152 static __inline uint16_t _lcd_read (void);
wim 3:2dccfa0121de 153 static __inline void _wr_cmd (uint16_t c);
wim 3:2dccfa0121de 154 static __inline void _wr_dat (uint16_t c);
wim 3:2dccfa0121de 155 static __inline uint16_t _rd_dat (void);
wim 3:2dccfa0121de 156 static __inline void _wr_dat_start (void);
wim 3:2dccfa0121de 157 static __inline void _wr_dat_stop (void);
wim 3:2dccfa0121de 158 static __inline void _wr_dat_only (uint16_t c);
wim 3:2dccfa0121de 159 static __inline void _wr_reg (uint16_t reg, uint16_t val);
wim 3:2dccfa0121de 160 static __inline uint16_t _rd_reg (uint16_t reg);
wim 2:43ede88fb5a3 161
wim 3:2dccfa0121de 162 uint16_t _driverCode;
wim 3:2dccfa0121de 163 uint16_t _textColor, _backColor;
wim 3:2dccfa0121de 164 uint16_t _col, _ln;
wim 2:43ede88fb5a3 165 };
wim 0:a8090b59eb05 166
wim 0:a8090b59eb05 167 #endif /* _GLCD_H */