Landtiger (LPC1768) graphics LCD demo.

Dependencies:   Tiger_LCD mbed

Dependents:   Tiger_LCD

See here for more info.

Committer:
wim
Date:
Fri Oct 30 01:26:40 2015 +0000
Revision:
3:2dccfa0121de
Parent:
2:43ede88fb5a3
Child:
4:cdeea87f25d8
Landtiger LCD demo (Mandelbrot). Code snippets merged from several sources.

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 3:2dccfa0121de 70 virtual int _putc(int value) { writeChar(value); return 1;};
wim 3:2dccfa0121de 71 virtual int _getc() { return -1; };
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 3:2dccfa0121de 84 void clearScreen (uint16_t color);
wim 2:43ede88fb5a3 85
wim 2:43ede88fb5a3 86
wim 3:2dccfa0121de 87 /** @brief Write single character to the display using the 8x8 fontable
wim 3:2dccfa0121de 88 * @brief Start at current cursor location
wim 3:2dccfa0121de 89 * @param char chr character to write
wim 3:2dccfa0121de 90 */
wim 3:2dccfa0121de 91 void writeChar (uint8_t chr);
wim 3:2dccfa0121de 92 void DrawChar (unsigned int x, unsigned int y, uint16_t *c);
wim 3:2dccfa0121de 93 void DisplayChar (uint16_t ln, uint16_t col, uint8_t c);
wim 3:2dccfa0121de 94 void DisplayString (uint16_t ln, uint16_t col, uint8_t *s);
wim 3:2dccfa0121de 95 void ClearLn (uint16_t ln);
wim 2:43ede88fb5a3 96 void Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
wim 3:2dccfa0121de 97 void Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bitmap);
wim 3:2dccfa0121de 98 void Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bmp);
wim 2:43ede88fb5a3 99
wim 2:43ede88fb5a3 100 void drawHLine (int x, int y, int l);
wim 2:43ede88fb5a3 101 void drawVLine (int x, int y, int l);
wim 2:43ede88fb5a3 102 void drawRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 103 void drawLine (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 104 void drawRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 105 void fillRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 106 void fillRoundRect (int x1, int y1, int x2, int y2);
wim 2:43ede88fb5a3 107 void drawCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 108 void fillCircle (int x, int y, int radius);
wim 2:43ede88fb5a3 109
wim 2:43ede88fb5a3 110 void lcdOff();
wim 2:43ede88fb5a3 111 void lcdOn();
wim 3:2dccfa0121de 112 void invertDisplay(bool i);
wim 3:2dccfa0121de 113 void setContrast(uint8_t c);
wim 2:43ede88fb5a3 114
wim 2:43ede88fb5a3 115 int getDisplayXSize();
wim 2:43ede88fb5a3 116 int getDisplayYSize();
wim 3:2dccfa0121de 117 uint16_t getDriverCode ();
wim 2:43ede88fb5a3 118
wim 2:43ede88fb5a3 119 private:
wim 3:2dccfa0121de 120 static __inline uint8_t _lcd_send (uint16_t data);
wim 3:2dccfa0121de 121 static __inline uint16_t _lcd_read (void);
wim 3:2dccfa0121de 122 static __inline void _wr_cmd (uint16_t c);
wim 3:2dccfa0121de 123 static __inline void _wr_dat (uint16_t c);
wim 3:2dccfa0121de 124 static __inline uint16_t _rd_dat (void);
wim 3:2dccfa0121de 125 static __inline void _wr_dat_start (void);
wim 3:2dccfa0121de 126 static __inline void _wr_dat_stop (void);
wim 3:2dccfa0121de 127 static __inline void _wr_dat_only (uint16_t c);
wim 3:2dccfa0121de 128 static __inline void _wr_reg (uint16_t reg, uint16_t val);
wim 3:2dccfa0121de 129 static __inline uint16_t _rd_reg (uint16_t reg);
wim 2:43ede88fb5a3 130
wim 3:2dccfa0121de 131 uint16_t _driverCode;
wim 3:2dccfa0121de 132 uint16_t _textColor, _backColor;
wim 3:2dccfa0121de 133 uint16_t _col, _ln;
wim 2:43ede88fb5a3 134 };
wim 0:a8090b59eb05 135
wim 0:a8090b59eb05 136 #endif /* _GLCD_H */