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 3:2dccfa0121de 2 /* GLCD::LPC1700 low-level Graphic LCD (320x240 pixels) for LandTiger */
wim 0:a8090b59eb05 3 /* */
wim 0:a8090b59eb05 4 /******************************************************************************/
wim 0:a8090b59eb05 5 /* This file is modified from the uVision/ARM development tools. */
wim 0:a8090b59eb05 6 /* Copyright (c) 2005-2009 Keil Software. All rights reserved. */
wim 0:a8090b59eb05 7 /* This software may only be used under the terms of a valid, current, */
wim 0:a8090b59eb05 8 /* end user licence from KEIL for a compatible version of KEIL software */
wim 0:a8090b59eb05 9 /* development tools. Nothing else gives you the right to use this software. */
wim 0:a8090b59eb05 10 /******************************************************************************/
wim 0:a8090b59eb05 11
wim 0:a8090b59eb05 12 #include "mbed.h"
wim 0:a8090b59eb05 13 #include "GLCD.h"
wim 2:43ede88fb5a3 14 #include "GLCD_Config.h"
wim 0:a8090b59eb05 15 #include "Font_24x16.h"
wim 0:a8090b59eb05 16
wim 0:a8090b59eb05 17 /*********************** Hardware specific configuration **********************/
wim 0:a8090b59eb05 18
wim 0:a8090b59eb05 19 /* LandTiger 8bit to 16bit LCD Interface
wim 0:a8090b59eb05 20
wim 0:a8090b59eb05 21 PINS:
wim 0:a8090b59eb05 22 - EN = P0.19
wim 0:a8090b59eb05 23 - LE = P0.20
wim 0:a8090b59eb05 24 - DIR = P0.21
wim 0:a8090b59eb05 25 - CS = P0.22
wim 0:a8090b59eb05 26 - RS = P0.23
wim 0:a8090b59eb05 27 - WR = P0.24
wim 0:a8090b59eb05 28 - RD = P0.25
wim 0:a8090b59eb05 29 - DB[0.7] = P2.0...P2.7
wim 0:a8090b59eb05 30 - DB[8.15]= P2.0...P2.7 */
wim 0:a8090b59eb05 31
wim 0:a8090b59eb05 32 #define PIN_EN (1 << 19)
wim 0:a8090b59eb05 33 #define PIN_LE (1 << 20)
wim 0:a8090b59eb05 34 #define PIN_DIR (1 << 21)
wim 0:a8090b59eb05 35 #define PIN_CS (1 << 22)
wim 0:a8090b59eb05 36 #define PIN_RS (1 << 23)
wim 0:a8090b59eb05 37 #define PIN_WR (1 << 24)
wim 0:a8090b59eb05 38 #define PIN_RD (1 << 25)
wim 0:a8090b59eb05 39
wim 0:a8090b59eb05 40 /*------------------------- Speed dependant settings -------------------------*/
wim 0:a8090b59eb05 41
wim 0:a8090b59eb05 42 /* If processor works on high frequency delay has to be increased, it can be
wim 0:a8090b59eb05 43 increased by factor 2^N by this constant */
wim 0:a8090b59eb05 44 #define DELAY_2N 18
wim 0:a8090b59eb05 45
wim 0:a8090b59eb05 46 /*---------------------- Graphic LCD size definitions ------------------------*/
wim 0:a8090b59eb05 47
wim 0:a8090b59eb05 48 #define WIDTH 320 /* Screen Width (in pixels) */
wim 0:a8090b59eb05 49 #define HEIGHT 240 /* Screen Hight (in pixels) */
wim 0:a8090b59eb05 50 #define BPP 16 /* Bits per pixel */
wim 0:a8090b59eb05 51 #define BYPP ((BPP+7)/8) /* Bytes per pixel */
wim 0:a8090b59eb05 52
wim 4:cdeea87f25d8 53 #define ROWS (HEIGHT / CHAR_H) /* Lines per screen */
wim 4:cdeea87f25d8 54 #define COLS (WIDTH / CHAR_W) /* Characters per line */
wim 4:cdeea87f25d8 55
wim 0:a8090b59eb05 56 /*--------------- Graphic LCD interface hardware definitions -----------------*/
wim 0:a8090b59eb05 57
wim 0:a8090b59eb05 58 /* Pin EN setting to 0 or 1 */
wim 0:a8090b59eb05 59 #define LCD_EN(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_EN) : (LPC_GPIO0->FIOCLR = PIN_EN));
wim 0:a8090b59eb05 60 /* Pin LE setting to 0 or 1 */
wim 0:a8090b59eb05 61 #define LCD_LE(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_LE) : (LPC_GPIO0->FIOCLR = PIN_LE));
wim 0:a8090b59eb05 62 /* Pin DIR setting to 0 or 1 */
wim 0:a8090b59eb05 63 #define LCD_DIR(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_DIR) : (LPC_GPIO0->FIOCLR = PIN_DIR));
wim 0:a8090b59eb05 64 /* Pin CS setting to 0 or 1 */
wim 0:a8090b59eb05 65 #define LCD_CS(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_CS) : (LPC_GPIO0->FIOCLR = PIN_CS));
wim 0:a8090b59eb05 66 /* Pin RS setting to 0 or 1 */
wim 0:a8090b59eb05 67 #define LCD_RS(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_RS) : (LPC_GPIO0->FIOCLR = PIN_RS));
wim 0:a8090b59eb05 68 /* Pin WR setting to 0 or 1 */
wim 0:a8090b59eb05 69 #define LCD_WR(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_WR) : (LPC_GPIO0->FIOCLR = PIN_WR));
wim 0:a8090b59eb05 70 /* Pin RD setting to 0 or 1 */
wim 0:a8090b59eb05 71 #define LCD_RD(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_RD) : (LPC_GPIO0->FIOCLR = PIN_RD));
wim 0:a8090b59eb05 72
wim 0:a8090b59eb05 73
wim 0:a8090b59eb05 74 /************************ Local auxiliary functions ***************************/
wim 0:a8090b59eb05 75
wim 3:2dccfa0121de 76 #define MAX_POLY_CORNERS 200
wim 3:2dccfa0121de 77 #define POLY_Y(Z) ((int32_t)((Points + Z)->X))
wim 3:2dccfa0121de 78 #define POLY_X(Z) ((int32_t)((Points + Z)->Y))
wim 3:2dccfa0121de 79 #define ABS(X) ((X) > 0 ? (X) : -(X))
wim 3:2dccfa0121de 80
wim 2:43ede88fb5a3 81 #define swap(type, i, j) {type t = i; i = j; j = t;}
wim 2:43ede88fb5a3 82
wim 2:43ede88fb5a3 83 // rrrrrggggggbbbbb
wim 2:43ede88fb5a3 84 #define RGB24toRGB16(r,g,b) ((r & 0xF8)<<8) | ((g & 0xFC)<<3) | ((b & 0xF8)>>3)
wim 2:43ede88fb5a3 85
wim 2:43ede88fb5a3 86
wim 0:a8090b59eb05 87 /*******************************************************************************
wim 0:a8090b59eb05 88 * Delay in while loop cycles *
wim 0:a8090b59eb05 89 * Parameter: cnt: number of while cycles to delay *
wim 0:a8090b59eb05 90 * Return: *
wim 0:a8090b59eb05 91 *******************************************************************************/
wim 0:a8090b59eb05 92
wim 2:43ede88fb5a3 93 static __inline void delay (int cnt) {
wim 0:a8090b59eb05 94
wim 0:a8090b59eb05 95 cnt <<= DELAY_2N;
wim 0:a8090b59eb05 96 while (cnt--);
wim 0:a8090b59eb05 97 }
wim 0:a8090b59eb05 98
wim 2:43ede88fb5a3 99 static __inline __asm void wait()
wim 0:a8090b59eb05 100 {
wim 0:a8090b59eb05 101 nop
wim 0:a8090b59eb05 102 BX lr
wim 0:a8090b59eb05 103 }
wim 0:a8090b59eb05 104
wim 2:43ede88fb5a3 105 static __inline void wait_delay(int count)
wim 0:a8090b59eb05 106 {
wim 0:a8090b59eb05 107 while(count--);
wim 0:a8090b59eb05 108 }
wim 0:a8090b59eb05 109
wim 2:43ede88fb5a3 110
wim 2:43ede88fb5a3 111 GLCD::GLCD() {
wim 3:2dccfa0121de 112 init();
wim 2:43ede88fb5a3 113 }
wim 2:43ede88fb5a3 114
wim 2:43ede88fb5a3 115
wim 0:a8090b59eb05 116 /*******************************************************************************
wim 0:a8090b59eb05 117 * Send 1 short to LCD *
wim 0:a8090b59eb05 118 * Parameter: data: data to be sent *
wim 0:a8090b59eb05 119 * Return: *
wim 0:a8090b59eb05 120 *******************************************************************************/
wim 0:a8090b59eb05 121
wim 3:2dccfa0121de 122 uint8_t GLCD::_lcd_send (uint16_t data) {
wim 0:a8090b59eb05 123
wim 0:a8090b59eb05 124 LPC_GPIO2->FIODIR |= 0x000000ff; //P2.0...P2.7 Output
wim 0:a8090b59eb05 125 LCD_DIR(1) //Interface A->B
wim 0:a8090b59eb05 126 LCD_EN(0) //Enable 2A->2B
wim 0:a8090b59eb05 127 LPC_GPIO2->FIOPIN = data; //Write D0..D7
wim 0:a8090b59eb05 128 LCD_LE(1)
wim 0:a8090b59eb05 129 LCD_LE(0) //latch D0..D7
wim 0:a8090b59eb05 130 LPC_GPIO2->FIOPIN = data >> 8; //Write D8..D15
wim 0:a8090b59eb05 131 return(1);
wim 0:a8090b59eb05 132 }
wim 0:a8090b59eb05 133
wim 0:a8090b59eb05 134
wim 0:a8090b59eb05 135 /*******************************************************************************
wim 0:a8090b59eb05 136 * read 1 short from LCD *
wim 0:a8090b59eb05 137 * Parameter: *
wim 0:a8090b59eb05 138 * Return: short data from LCD *
wim 0:a8090b59eb05 139 *******************************************************************************/
wim 0:a8090b59eb05 140
wim 3:2dccfa0121de 141 uint16_t GLCD::_lcd_read (void) {
wim 3:2dccfa0121de 142 uint16_t id;
wim 0:a8090b59eb05 143 LPC_GPIO2->FIODIR &= 0xffffff00; //P2.0...P2.7 Input
wim 0:a8090b59eb05 144 LCD_DIR(0) //Interface B->A
wim 0:a8090b59eb05 145 LCD_EN(0) //Enable 2B->2A
wim 0:a8090b59eb05 146 wait_delay(80); //delay some times
wim 0:a8090b59eb05 147 id = LPC_GPIO2->FIOPIN & 0x00ff; //Read D8..D15
wim 0:a8090b59eb05 148 LCD_EN(1) //Enable 1B->1A
wim 0:a8090b59eb05 149 wait_delay(80); //delay some times
wim 0:a8090b59eb05 150 id = (id << 8) | (LPC_GPIO2->FIOPIN & 0x00ff); //Read D0..D7
wim 0:a8090b59eb05 151 LCD_DIR(1)
wim 0:a8090b59eb05 152 return(id);
wim 0:a8090b59eb05 153 }
wim 0:a8090b59eb05 154
wim 0:a8090b59eb05 155 /*******************************************************************************
wim 0:a8090b59eb05 156 * Write command to LCD controller *
wim 0:a8090b59eb05 157 * Parameter: c: command to be written *
wim 0:a8090b59eb05 158 * Return: *
wim 0:a8090b59eb05 159 *******************************************************************************/
wim 0:a8090b59eb05 160
wim 3:2dccfa0121de 161 void GLCD::_wr_cmd (uint16_t c) {
wim 0:a8090b59eb05 162
wim 0:a8090b59eb05 163 LCD_RS(0)
wim 0:a8090b59eb05 164 LCD_RD(1)
wim 3:2dccfa0121de 165 _lcd_send(c);
wim 0:a8090b59eb05 166 LCD_WR(0)
wim 0:a8090b59eb05 167 wait();
wim 0:a8090b59eb05 168 LCD_WR(1)
wim 0:a8090b59eb05 169 }
wim 0:a8090b59eb05 170
wim 0:a8090b59eb05 171
wim 0:a8090b59eb05 172 /*******************************************************************************
wim 0:a8090b59eb05 173 * Write data to LCD controller *
wim 0:a8090b59eb05 174 * Parameter: c: data to be written *
wim 0:a8090b59eb05 175 * Return: *
wim 0:a8090b59eb05 176 *******************************************************************************/
wim 0:a8090b59eb05 177
wim 3:2dccfa0121de 178 void GLCD::_wr_dat (uint16_t c) {
wim 0:a8090b59eb05 179
wim 0:a8090b59eb05 180 LCD_RS(1)
wim 0:a8090b59eb05 181 LCD_RD(1)
wim 3:2dccfa0121de 182 _lcd_send(c);
wim 0:a8090b59eb05 183 LCD_WR(0)
wim 0:a8090b59eb05 184 wait();
wim 0:a8090b59eb05 185 LCD_WR(1)
wim 0:a8090b59eb05 186 }
wim 0:a8090b59eb05 187
wim 0:a8090b59eb05 188 /*******************************************************************************
wim 0:a8090b59eb05 189 * Read data from LCD controller *
wim 0:a8090b59eb05 190 * Parameter: *
wim 0:a8090b59eb05 191 * Return: read data *
wim 0:a8090b59eb05 192 *******************************************************************************/
wim 0:a8090b59eb05 193
wim 3:2dccfa0121de 194 uint16_t GLCD::_rd_dat (void) {
wim 3:2dccfa0121de 195 uint16_t val = 0;
wim 0:a8090b59eb05 196
wim 0:a8090b59eb05 197 LCD_RS(1)
wim 0:a8090b59eb05 198 LCD_WR(1)
wim 0:a8090b59eb05 199 LCD_RD(0)
wim 3:2dccfa0121de 200 val = _lcd_read();
wim 0:a8090b59eb05 201 LCD_RD(1)
wim 0:a8090b59eb05 202 return val;
wim 0:a8090b59eb05 203 }
wim 0:a8090b59eb05 204
wim 0:a8090b59eb05 205 /*******************************************************************************
wim 0:a8090b59eb05 206 * Start of data writing to LCD controller *
wim 0:a8090b59eb05 207 * Parameter: *
wim 0:a8090b59eb05 208 * Return: *
wim 0:a8090b59eb05 209 *******************************************************************************/
wim 0:a8090b59eb05 210
wim 3:2dccfa0121de 211 void GLCD::_wr_dat_start (void) {
wim 0:a8090b59eb05 212
wim 0:a8090b59eb05 213 LCD_CS(0)
wim 0:a8090b59eb05 214 LCD_RS(1)
wim 0:a8090b59eb05 215 }
wim 0:a8090b59eb05 216
wim 0:a8090b59eb05 217
wim 0:a8090b59eb05 218 /*******************************************************************************
wim 0:a8090b59eb05 219 * Stop of data writing to LCD controller *
wim 0:a8090b59eb05 220 * Parameter: *
wim 0:a8090b59eb05 221 * Return: *
wim 0:a8090b59eb05 222 *******************************************************************************/
wim 0:a8090b59eb05 223
wim 3:2dccfa0121de 224 void GLCD::_wr_dat_stop (void) {
wim 0:a8090b59eb05 225
wim 0:a8090b59eb05 226 LCD_CS(1)
wim 0:a8090b59eb05 227 }
wim 0:a8090b59eb05 228
wim 0:a8090b59eb05 229
wim 0:a8090b59eb05 230 /*******************************************************************************
wim 0:a8090b59eb05 231 * Data writing to LCD controller *
wim 0:a8090b59eb05 232 * Parameter: c: data to be written *
wim 0:a8090b59eb05 233 * Return: *
wim 0:a8090b59eb05 234 *******************************************************************************/
wim 0:a8090b59eb05 235
wim 3:2dccfa0121de 236 void GLCD::_wr_dat_only (uint16_t c) {
wim 0:a8090b59eb05 237
wim 3:2dccfa0121de 238 _lcd_send(c);
wim 0:a8090b59eb05 239 LCD_WR(0)
wim 0:a8090b59eb05 240 wait();
wim 0:a8090b59eb05 241 LCD_WR(1)
wim 0:a8090b59eb05 242 }
wim 0:a8090b59eb05 243
wim 0:a8090b59eb05 244
wim 0:a8090b59eb05 245 /*******************************************************************************
wim 0:a8090b59eb05 246 * Write to LCD register *
wim 0:a8090b59eb05 247 * Parameter: reg: register to be read *
wim 0:a8090b59eb05 248 * val: value to write to register *
wim 0:a8090b59eb05 249 *******************************************************************************/
wim 0:a8090b59eb05 250
wim 3:2dccfa0121de 251 void GLCD::_wr_reg (uint16_t reg, uint16_t val) {
wim 0:a8090b59eb05 252
wim 0:a8090b59eb05 253 LCD_CS(0)
wim 3:2dccfa0121de 254 _wr_cmd(reg);
wim 3:2dccfa0121de 255 _wr_dat(val);
wim 0:a8090b59eb05 256 LCD_CS(1)
wim 0:a8090b59eb05 257 }
wim 0:a8090b59eb05 258
wim 0:a8090b59eb05 259
wim 0:a8090b59eb05 260 /*******************************************************************************
wim 0:a8090b59eb05 261 * Read from LCD register *
wim 0:a8090b59eb05 262 * Parameter: reg: register to be read *
wim 0:a8090b59eb05 263 * Return: value read from register *
wim 0:a8090b59eb05 264 *******************************************************************************/
wim 0:a8090b59eb05 265
wim 3:2dccfa0121de 266 uint16_t GLCD::_rd_reg (uint16_t reg) {
wim 3:2dccfa0121de 267 uint16_t val = 0;
wim 0:a8090b59eb05 268
wim 0:a8090b59eb05 269 LCD_CS(0)
wim 3:2dccfa0121de 270 _wr_cmd(reg);
wim 3:2dccfa0121de 271 val = _rd_dat();
wim 0:a8090b59eb05 272 LCD_CS(1)
wim 0:a8090b59eb05 273 return (val);
wim 0:a8090b59eb05 274 }
wim 0:a8090b59eb05 275
wim 0:a8090b59eb05 276
wim 0:a8090b59eb05 277 /************************ Exported functions **********************************/
wim 0:a8090b59eb05 278
wim 0:a8090b59eb05 279 /*******************************************************************************
wim 0:a8090b59eb05 280 * Initialize the Graphic LCD controller *
wim 0:a8090b59eb05 281 * Parameter: *
wim 0:a8090b59eb05 282 * Return: *
wim 0:a8090b59eb05 283 *******************************************************************************/
wim 0:a8090b59eb05 284
wim 3:2dccfa0121de 285 void GLCD::init (void) {
wim 0:a8090b59eb05 286
wim 0:a8090b59eb05 287 /* Configure the LCD Control pins */
wim 0:a8090b59eb05 288 LPC_GPIO0->FIODIR |= 0x03f80000;
wim 0:a8090b59eb05 289 LPC_GPIO0->FIOSET = 0x03f80000;
wim 0:a8090b59eb05 290
wim 0:a8090b59eb05 291 delay(5); /* Delay 50 ms */
wim 0:a8090b59eb05 292
wim 3:2dccfa0121de 293 _driverCode = _rd_reg(0x00);
wim 0:a8090b59eb05 294
wim 2:43ede88fb5a3 295 switch (_driverCode) {
wim 0:a8090b59eb05 296
wim 0:a8090b59eb05 297 case LGDP4531_ID: { //2.8" TFT LCD Module, DriverIC is LGDP4531
wim 0:a8090b59eb05 298
wim 2:43ede88fb5a3 299 #ifndef DISABLE_LGDP4531
wim 3:2dccfa0121de 300 _wr_reg(0x00,0x0001);
wim 3:2dccfa0121de 301 _wr_reg(0x10,0x0628);
wim 3:2dccfa0121de 302 _wr_reg(0x12,0x0006);
wim 3:2dccfa0121de 303 _wr_reg(0x13,0x0A32);
wim 3:2dccfa0121de 304 _wr_reg(0x11,0x0040);
wim 3:2dccfa0121de 305 _wr_reg(0x15,0x0050);
wim 3:2dccfa0121de 306 _wr_reg(0x12,0x0016);
wim 0:a8090b59eb05 307 delay(15);
wim 3:2dccfa0121de 308 _wr_reg(0x10,0x5660);
wim 0:a8090b59eb05 309 delay(15);
wim 3:2dccfa0121de 310 _wr_reg(0x13,0x2A4E);
wim 3:2dccfa0121de 311 _wr_reg(0x01,0x0100);
wim 3:2dccfa0121de 312 _wr_reg(0x02,0x0300);
wim 0:a8090b59eb05 313
wim 3:2dccfa0121de 314 _wr_reg(0x03,0x1030);
wim 0:a8090b59eb05 315
wim 3:2dccfa0121de 316 _wr_reg(0x08,0x0202);
wim 3:2dccfa0121de 317 _wr_reg(0x0A,0x0000);
wim 3:2dccfa0121de 318 _wr_reg(0x30,0x0000);
wim 3:2dccfa0121de 319 _wr_reg(0x31,0x0402);
wim 3:2dccfa0121de 320 _wr_reg(0x32,0x0106);
wim 3:2dccfa0121de 321 _wr_reg(0x33,0x0700);
wim 3:2dccfa0121de 322 _wr_reg(0x34,0x0104);
wim 3:2dccfa0121de 323 _wr_reg(0x35,0x0301);
wim 3:2dccfa0121de 324 _wr_reg(0x36,0x0707);
wim 3:2dccfa0121de 325 _wr_reg(0x37,0x0305);
wim 3:2dccfa0121de 326 _wr_reg(0x38,0x0208);
wim 3:2dccfa0121de 327 _wr_reg(0x39,0x0F0B);
wim 0:a8090b59eb05 328 delay(15);
wim 3:2dccfa0121de 329 _wr_reg(0x41,0x0002);
wim 3:2dccfa0121de 330 _wr_reg(0x60,0x2700);
wim 3:2dccfa0121de 331 _wr_reg(0x61,0x0001);
wim 3:2dccfa0121de 332 _wr_reg(0x90,0x0119);
wim 3:2dccfa0121de 333 _wr_reg(0x92,0x010A);
wim 3:2dccfa0121de 334 _wr_reg(0x93,0x0004);
wim 3:2dccfa0121de 335 _wr_reg(0xA0,0x0100);
wim 0:a8090b59eb05 336 delay(15);
wim 3:2dccfa0121de 337 _wr_reg(0xA0,0x0000);
wim 0:a8090b59eb05 338 delay(20);
wim 2:43ede88fb5a3 339 #endif
wim 0:a8090b59eb05 340 break;
wim 0:a8090b59eb05 341 }
wim 0:a8090b59eb05 342
wim 0:a8090b59eb05 343 case ILI9328_ID:
wim 0:a8090b59eb05 344 case ILI9325_ID: { //2.8" TFT LCD Module, DriverIC is ILI9325
wim 0:a8090b59eb05 345
wim 2:43ede88fb5a3 346 #ifndef DISABLE_ILI9325
wim 3:2dccfa0121de 347 _wr_reg(0x00e7,0x0010);
wim 3:2dccfa0121de 348 _wr_reg(0x0000,0x0001); //start internal osc
wim 3:2dccfa0121de 349 _wr_reg(0x0001,0x0100);
wim 3:2dccfa0121de 350 _wr_reg(0x0002,0x0700); //power on sequence
wim 3:2dccfa0121de 351 _wr_reg(0x0003,(1<<12)|(1<<5)|(1<<4) ); //65K
wim 3:2dccfa0121de 352 _wr_reg(0x0004,0x0000);
wim 3:2dccfa0121de 353 _wr_reg(0x0008,0x0207);
wim 3:2dccfa0121de 354 _wr_reg(0x0009,0x0000);
wim 3:2dccfa0121de 355 _wr_reg(0x000a,0x0000); //display setting
wim 3:2dccfa0121de 356 _wr_reg(0x000c,0x0001); //display setting
wim 3:2dccfa0121de 357 _wr_reg(0x000d,0x0000); //0f3c
wim 3:2dccfa0121de 358 _wr_reg(0x000f,0x0000);
wim 0:a8090b59eb05 359 //Power On sequence //
wim 3:2dccfa0121de 360 _wr_reg(0x0010,0x0000);
wim 3:2dccfa0121de 361 _wr_reg(0x0011,0x0007);
wim 3:2dccfa0121de 362 _wr_reg(0x0012,0x0000);
wim 3:2dccfa0121de 363 _wr_reg(0x0013,0x0000);
wim 0:a8090b59eb05 364 delay(15);
wim 3:2dccfa0121de 365 _wr_reg(0x0010,0x1590);
wim 3:2dccfa0121de 366 _wr_reg(0x0011,0x0227);
wim 0:a8090b59eb05 367 delay(15);
wim 3:2dccfa0121de 368 _wr_reg(0x0012,0x009c);
wim 0:a8090b59eb05 369 delay(15);
wim 3:2dccfa0121de 370 _wr_reg(0x0013,0x1900);
wim 3:2dccfa0121de 371 _wr_reg(0x0029,0x0023);
wim 3:2dccfa0121de 372 _wr_reg(0x002b,0x000e);
wim 0:a8090b59eb05 373 delay(15);
wim 3:2dccfa0121de 374 _wr_reg(0x0020,0x0000);
wim 3:2dccfa0121de 375 _wr_reg(0x0021,0x0000);
wim 0:a8090b59eb05 376 ///////////////////////////////////////////////////////
wim 0:a8090b59eb05 377 delay(15);
wim 3:2dccfa0121de 378 _wr_reg(0x0030,0x0007);
wim 3:2dccfa0121de 379 _wr_reg(0x0031,0x0707);
wim 3:2dccfa0121de 380 _wr_reg(0x0032,0x0006);
wim 3:2dccfa0121de 381 _wr_reg(0x0035,0x0704);
wim 3:2dccfa0121de 382 _wr_reg(0x0036,0x1f04);
wim 3:2dccfa0121de 383 _wr_reg(0x0037,0x0004);
wim 3:2dccfa0121de 384 _wr_reg(0x0038,0x0000);
wim 3:2dccfa0121de 385 _wr_reg(0x0039,0x0706);
wim 3:2dccfa0121de 386 _wr_reg(0x003c,0x0701);
wim 3:2dccfa0121de 387 _wr_reg(0x003d,0x000f);
wim 0:a8090b59eb05 388 delay(15);
wim 3:2dccfa0121de 389 _wr_reg(0x0050,0x0000);
wim 3:2dccfa0121de 390 _wr_reg(0x0051,0x00ef);
wim 3:2dccfa0121de 391 _wr_reg(0x0052,0x0000);
wim 3:2dccfa0121de 392 _wr_reg(0x0053,0x013f);
wim 3:2dccfa0121de 393 _wr_reg(0x0060,0xa700);
wim 3:2dccfa0121de 394 _wr_reg(0x0061,0x0001);
wim 3:2dccfa0121de 395 _wr_reg(0x006a,0x0000);
wim 3:2dccfa0121de 396 _wr_reg(0x0080,0x0000);
wim 3:2dccfa0121de 397 _wr_reg(0x0081,0x0000);
wim 3:2dccfa0121de 398 _wr_reg(0x0082,0x0000);
wim 3:2dccfa0121de 399 _wr_reg(0x0083,0x0000);
wim 3:2dccfa0121de 400 _wr_reg(0x0084,0x0000);
wim 3:2dccfa0121de 401 _wr_reg(0x0085,0x0000);
wim 0:a8090b59eb05 402
wim 3:2dccfa0121de 403 _wr_reg(0x0090,0x0010);
wim 3:2dccfa0121de 404 _wr_reg(0x0092,0x0000);
wim 3:2dccfa0121de 405 _wr_reg(0x0093,0x0003);
wim 3:2dccfa0121de 406 _wr_reg(0x0095,0x0110);
wim 3:2dccfa0121de 407 _wr_reg(0x0097,0x0000);
wim 3:2dccfa0121de 408 _wr_reg(0x0098,0x0000);
wim 0:a8090b59eb05 409 //display on sequence
wim 3:2dccfa0121de 410 _wr_reg(0x0007,0x0133);
wim 3:2dccfa0121de 411 _wr_reg(0x0020,0x0000);
wim 3:2dccfa0121de 412 _wr_reg(0x0021,0x0000);
wim 2:43ede88fb5a3 413 #endif
wim 0:a8090b59eb05 414 break;
wim 0:a8090b59eb05 415 }
wim 0:a8090b59eb05 416
wim 0:a8090b59eb05 417 case ILI9320_ID: { //3.2" TFT LCD Module,DriverIC is ILI9320
wim 2:43ede88fb5a3 418
wim 2:43ede88fb5a3 419 #ifndef DISABLE_ILI9320
wim 0:a8090b59eb05 420 /* Start Initial Sequence --------------------------------------------------*/
wim 3:2dccfa0121de 421 _wr_reg(0xE5, 0x8000); /* Set the internal vcore voltage */
wim 3:2dccfa0121de 422 _wr_reg(0x00, 0x0001); /* Start internal OSC */
wim 3:2dccfa0121de 423 _wr_reg(0x01, 0x0100); /* Set SS and SM bit */
wim 3:2dccfa0121de 424 _wr_reg(0x02, 0x0700); /* Set 1 line inversion */
wim 3:2dccfa0121de 425 _wr_reg(0x03, 0x1030); /* Set GRAM write direction and BGR=1 */
wim 3:2dccfa0121de 426 _wr_reg(0x04, 0x0000); /* Resize register */
wim 3:2dccfa0121de 427 _wr_reg(0x08, 0x0202); /* 2 lines each, back and front porch */
wim 3:2dccfa0121de 428 _wr_reg(0x09, 0x0000); /* Set non-disp area refresh cyc ISC */
wim 3:2dccfa0121de 429 _wr_reg(0x0A, 0x0000); /* FMARK function */
wim 3:2dccfa0121de 430 _wr_reg(0x0C, 0x0000); /* RGB interface setting */
wim 3:2dccfa0121de 431 _wr_reg(0x0D, 0x0000); /* Frame marker Position */
wim 3:2dccfa0121de 432 _wr_reg(0x0F, 0x0000); /* RGB interface polarity */
wim 0:a8090b59eb05 433
wim 0:a8090b59eb05 434 /* Power On sequence -------------------------------------------------------*/
wim 3:2dccfa0121de 435 _wr_reg(0x10, 0x0000); /* Reset Power Control 1 */
wim 3:2dccfa0121de 436 _wr_reg(0x11, 0x0000); /* Reset Power Control 2 */
wim 3:2dccfa0121de 437 _wr_reg(0x12, 0x0000); /* Reset Power Control 3 */
wim 3:2dccfa0121de 438 _wr_reg(0x13, 0x0000); /* Reset Power Control 4 */
wim 0:a8090b59eb05 439 delay(20); /* Discharge cap power voltage (200ms)*/
wim 3:2dccfa0121de 440 _wr_reg(0x10, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
wim 3:2dccfa0121de 441 _wr_reg(0x11, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */
wim 0:a8090b59eb05 442 delay(5); /* Delay 50 ms */
wim 3:2dccfa0121de 443 _wr_reg(0x12, 0x0139); /* VREG1OUT voltage */
wim 0:a8090b59eb05 444 delay(5); /* Delay 50 ms */
wim 3:2dccfa0121de 445 _wr_reg(0x13, 0x1D00); /* VDV[4:0] for VCOM amplitude */
wim 3:2dccfa0121de 446 _wr_reg(0x29, 0x0013); /* VCM[4:0] for VCOMH */
wim 0:a8090b59eb05 447 delay(5); /* Delay 50 ms */
wim 3:2dccfa0121de 448 _wr_reg(0x20, 0x0000); /* GRAM horizontal Address */
wim 3:2dccfa0121de 449 _wr_reg(0x21, 0x0000); /* GRAM Vertical Address */
wim 0:a8090b59eb05 450
wim 0:a8090b59eb05 451 /* Adjust the Gamma Curve --------------------------------------------------*/
wim 3:2dccfa0121de 452 _wr_reg(0x30, 0x0006);
wim 3:2dccfa0121de 453 _wr_reg(0x31, 0x0101);
wim 3:2dccfa0121de 454 _wr_reg(0x32, 0x0003);
wim 3:2dccfa0121de 455 _wr_reg(0x35, 0x0106);
wim 3:2dccfa0121de 456 _wr_reg(0x36, 0x0B02);
wim 3:2dccfa0121de 457 _wr_reg(0x37, 0x0302);
wim 3:2dccfa0121de 458 _wr_reg(0x38, 0x0707);
wim 3:2dccfa0121de 459 _wr_reg(0x39, 0x0007);
wim 3:2dccfa0121de 460 _wr_reg(0x3C, 0x0600);
wim 3:2dccfa0121de 461 _wr_reg(0x3D, 0x020B);
wim 0:a8090b59eb05 462
wim 0:a8090b59eb05 463 /* Set GRAM area -----------------------------------------------------------*/
wim 3:2dccfa0121de 464 _wr_reg(0x50, 0x0000); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 465 _wr_reg(0x51, (HEIGHT-1)); /* Horizontal GRAM End Address */
wim 3:2dccfa0121de 466 _wr_reg(0x52, 0x0000); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 467 _wr_reg(0x53, (WIDTH-1)); /* Vertical GRAM End Address */
wim 3:2dccfa0121de 468 _wr_reg(0x60, 0x2700); /* Gate Scan Line */
wim 3:2dccfa0121de 469 _wr_reg(0x61, 0x0001); /* NDL,VLE, REV */
wim 3:2dccfa0121de 470 _wr_reg(0x6A, 0x0000); /* Set scrolling line */
wim 0:a8090b59eb05 471
wim 0:a8090b59eb05 472 /* Partial Display Control -------------------------------------------------*/
wim 3:2dccfa0121de 473 _wr_reg(0x80, 0x0000);
wim 3:2dccfa0121de 474 _wr_reg(0x81, 0x0000);
wim 3:2dccfa0121de 475 _wr_reg(0x82, 0x0000);
wim 3:2dccfa0121de 476 _wr_reg(0x83, 0x0000);
wim 3:2dccfa0121de 477 _wr_reg(0x84, 0x0000);
wim 3:2dccfa0121de 478 _wr_reg(0x85, 0x0000);
wim 0:a8090b59eb05 479
wim 0:a8090b59eb05 480 /* Panel Control -----------------------------------------------------------*/
wim 3:2dccfa0121de 481 _wr_reg(0x90, 0x0010);
wim 3:2dccfa0121de 482 _wr_reg(0x92, 0x0000);
wim 3:2dccfa0121de 483 _wr_reg(0x93, 0x0003);
wim 3:2dccfa0121de 484 _wr_reg(0x95, 0x0110);
wim 3:2dccfa0121de 485 _wr_reg(0x97, 0x0000);
wim 3:2dccfa0121de 486 _wr_reg(0x98, 0x0000);
wim 2:43ede88fb5a3 487 #endif
wim 0:a8090b59eb05 488
wim 0:a8090b59eb05 489 break;
wim 0:a8090b59eb05 490 }
wim 0:a8090b59eb05 491
wim 0:a8090b59eb05 492 case ILI9331_ID: {
wim 2:43ede88fb5a3 493
wim 2:43ede88fb5a3 494 #ifndef DISABLE_ILI9331
wim 3:2dccfa0121de 495 _wr_reg(0x00E7, 0x1014);
wim 3:2dccfa0121de 496 _wr_reg(0x0001, 0x0100); /* set SS and SM bit */
wim 3:2dccfa0121de 497 _wr_reg(0x0002, 0x0200); /* set 1 line inversion */
wim 3:2dccfa0121de 498 _wr_reg(0x0003, 0x1030); /* set GRAM write direction and BGR=1 */
wim 3:2dccfa0121de 499 _wr_reg(0x0008, 0x0202); /* set the back porch and front porch */
wim 3:2dccfa0121de 500 _wr_reg(0x0009, 0x0000); /* set non-display area refresh cycle ISC[3:0] */
wim 3:2dccfa0121de 501 _wr_reg(0x000A, 0x0000); /* FMARK function */
wim 3:2dccfa0121de 502 _wr_reg(0x000C, 0x0000); /* RGB interface setting */
wim 3:2dccfa0121de 503 _wr_reg(0x000D, 0x0000); /* Frame marker Position */
wim 3:2dccfa0121de 504 _wr_reg(0x000F, 0x0000); /* RGB interface polarity */
wim 0:a8090b59eb05 505 /* Power On sequence */
wim 3:2dccfa0121de 506 _wr_reg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB   */
wim 3:2dccfa0121de 507 _wr_reg(0x0011, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
wim 3:2dccfa0121de 508 _wr_reg(0x0012, 0x0000); /* VREG1OUT voltage   */
wim 3:2dccfa0121de 509 _wr_reg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
wim 0:a8090b59eb05 510 delay(200); /* delay 200 ms */
wim 3:2dccfa0121de 511 _wr_reg(0x0010, 0x1690); /* SAP, BT[3:0], AP, DSTB, SLP, STB   */
wim 3:2dccfa0121de 512 _wr_reg(0x0011, 0x0227); /* DC1[2:0], DC0[2:0], VC[2:0] */
wim 0:a8090b59eb05 513 delay(50); /* delay 50 ms */
wim 3:2dccfa0121de 514 _wr_reg(0x0012, 0x000C); /* Internal reference voltage= Vci   */
wim 0:a8090b59eb05 515 delay(50); /* delay 50 ms */
wim 3:2dccfa0121de 516 _wr_reg(0x0013, 0x0800); /* Set VDV[4:0] for VCOM amplitude */
wim 3:2dccfa0121de 517 _wr_reg(0x0029, 0x0011); /* Set VCM[5:0] for VCOMH */
wim 3:2dccfa0121de 518 _wr_reg(0x002B, 0x000B); /* Set Frame Rate */
wim 0:a8090b59eb05 519 delay(50); /* delay 50 ms */
wim 3:2dccfa0121de 520 _wr_reg(0x0020, 0x0000); /* GRAM horizontal Address */
wim 3:2dccfa0121de 521 _wr_reg(0x0021, 0x0000); /* GRAM Vertical Address */
wim 0:a8090b59eb05 522 /* Adjust the Gamma Curve */
wim 3:2dccfa0121de 523 _wr_reg(0x0030, 0x0000);
wim 3:2dccfa0121de 524 _wr_reg(0x0031, 0x0106);
wim 3:2dccfa0121de 525 _wr_reg(0x0032, 0x0000);
wim 3:2dccfa0121de 526 _wr_reg(0x0035, 0x0204);
wim 3:2dccfa0121de 527 _wr_reg(0x0036, 0x160A);
wim 3:2dccfa0121de 528 _wr_reg(0x0037, 0x0707);
wim 3:2dccfa0121de 529 _wr_reg(0x0038, 0x0106);
wim 3:2dccfa0121de 530 _wr_reg(0x0039, 0x0707);
wim 3:2dccfa0121de 531 _wr_reg(0x003C, 0x0402);
wim 3:2dccfa0121de 532 _wr_reg(0x003D, 0x0C0F);
wim 0:a8090b59eb05 533 /* Set GRAM area */
wim 3:2dccfa0121de 534 _wr_reg(0x0050, 0x0000); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 535 _wr_reg(0x0051, 0x00EF); /* Horizontal GRAM End Address */
wim 3:2dccfa0121de 536 _wr_reg(0x0052, 0x0000); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 537 _wr_reg(0x0053, 0x013F); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 538 _wr_reg(0x0060, 0x2700); /* Gate Scan Line */
wim 3:2dccfa0121de 539 _wr_reg(0x0061, 0x0001); /*  NDL,VLE, REV */
wim 3:2dccfa0121de 540 _wr_reg(0x006A, 0x0000); /* set scrolling line */
wim 0:a8090b59eb05 541 /* Partial Display Control */
wim 3:2dccfa0121de 542 _wr_reg(0x0080, 0x0000);
wim 3:2dccfa0121de 543 _wr_reg(0x0081, 0x0000);
wim 3:2dccfa0121de 544 _wr_reg(0x0082, 0x0000);
wim 3:2dccfa0121de 545 _wr_reg(0x0083, 0x0000);
wim 3:2dccfa0121de 546 _wr_reg(0x0084, 0x0000);
wim 3:2dccfa0121de 547 _wr_reg(0x0085, 0x0000);
wim 0:a8090b59eb05 548 /* Panel Control */
wim 3:2dccfa0121de 549 _wr_reg(0x0090, 0x0010);
wim 3:2dccfa0121de 550 _wr_reg(0x0092, 0x0600);
wim 3:2dccfa0121de 551 _wr_reg(0x0007,0x0021);
wim 0:a8090b59eb05 552 delay(50); /* delay 50 ms */
wim 3:2dccfa0121de 553 _wr_reg(0x0007,0x0061);
wim 0:a8090b59eb05 554 delay(50); /* delay 50 ms */
wim 3:2dccfa0121de 555 _wr_reg(0x0007,0x0133); /* 262K color and display ON */
wim 2:43ede88fb5a3 556 #endif
wim 0:a8090b59eb05 557 break;
wim 0:a8090b59eb05 558 }
wim 0:a8090b59eb05 559
wim 0:a8090b59eb05 560 case SSD1289_ID: { //3.2" TFT LCD Module,DriverIC is SSD1289
wim 2:43ede88fb5a3 561
wim 2:43ede88fb5a3 562 #ifndef DISABLE_SSD1289_ID
wim 3:2dccfa0121de 563 _wr_reg(0x0007,0x0233); delay(5); //0x0233 Set this first or init fails !
wim 1:ea0f7b1c5daf 564
wim 3:2dccfa0121de 565 _wr_reg(0x0000,0x0001); delay(5); // osc en
wim 0:a8090b59eb05 566
wim 3:2dccfa0121de 567 _wr_reg(0x0003,0xA8A4); delay(5); // powercontrol 1 0xA8A4
wim 3:2dccfa0121de 568 _wr_reg(0x000C,0x0000); delay(5); // powercontrol 2
wim 3:2dccfa0121de 569 _wr_reg(0x000D,0x080C); delay(5); // powercontrol 3
wim 3:2dccfa0121de 570 _wr_reg(0x000E,0x2B00); delay(5); // powercontrol 4
wim 3:2dccfa0121de 571 _wr_reg(0x001E,0x00B0); delay(5); // powercontrol 5
wim 0:a8090b59eb05 572
wim 3:2dccfa0121de 573 //orig _wr_reg(0x0001,0x2b3F); delay(5); // 0x2b3f Mux=320, BGR, RL=0, TB=1
wim 3:2dccfa0121de 574 _wr_reg(0x0001,0x6B3F); delay(5); // 0x6B3F Mux=320, BGR, RL=1, TB=1
wim 3:2dccfa0121de 575 // _wr_reg(0x0001,0x293F); delay(5); // 0x293f Mux=320, BGR, RL=0, TB=0
wim 0:a8090b59eb05 576
wim 0:a8090b59eb05 577
wim 3:2dccfa0121de 578 _wr_reg(0x0002,0x0600); delay(5); // Driver AC mode
wim 3:2dccfa0121de 579 _wr_reg(0x0010,0x0000); delay(5); // Exit Sleep
wim 0:a8090b59eb05 580
wim 3:2dccfa0121de 581 _wr_reg(0x0011,0x6078); delay(5); // Entry mode 0x6078 = 65k colors, Hor and Vert Addr Incr, AM=1 vert writing dir
wim 3:2dccfa0121de 582 // _wr_reg(0x0011,0x4030); delay(5); // Entry mode 0x4030 = 262k colors, Hor and Vert Addr Incr. AM=0 hor writing dir
wim 0:a8090b59eb05 583
wim 3:2dccfa0121de 584 _wr_reg(0x0005,0x0000); delay(5); // Compare Regs (default)
wim 3:2dccfa0121de 585 _wr_reg(0x0006,0x0000); delay(5);
wim 0:a8090b59eb05 586
wim 3:2dccfa0121de 587 _wr_reg(0x0016,0xEF1C); delay(5); // Hor Porch (default)
wim 3:2dccfa0121de 588 _wr_reg(0x0017,0x0003); delay(5); // Ver Porch (default 0103)
wim 3:2dccfa0121de 589 _wr_reg(0x0007,0x0233); delay(5); //0x0233
wim 3:2dccfa0121de 590 _wr_reg(0x000B,0x0000); delay(5); // Frame cycle control default 5308)
wim 0:a8090b59eb05 591
wim 3:2dccfa0121de 592 _wr_reg(0x000F,0x0000); delay(5); // Gate scan start position
wim 0:a8090b59eb05 593
wim 3:2dccfa0121de 594 _wr_reg(0x0041,0x0000); delay(5); // Vert Scroll control
wim 3:2dccfa0121de 595 _wr_reg(0x0042,0x0000); delay(5);
wim 0:a8090b59eb05 596
wim 3:2dccfa0121de 597 _wr_reg(0x0048,0x0000); delay(5); // First screen pos (default)
wim 3:2dccfa0121de 598 _wr_reg(0x0049,0x013F); delay(5);
wim 0:a8090b59eb05 599
wim 3:2dccfa0121de 600 _wr_reg(0x004A,0x0000); delay(5); // Second screen pos
wim 3:2dccfa0121de 601 _wr_reg(0x004B,0x0000); delay(5);
wim 0:a8090b59eb05 602
wim 3:2dccfa0121de 603 _wr_reg(0x0044,0xEF00); delay(5); // Hor addr pos
wim 3:2dccfa0121de 604 _wr_reg(0x0045,0x0000); delay(5); // Vert Addr pos
wim 3:2dccfa0121de 605 _wr_reg(0x0046,0x013F); delay(5);
wim 0:a8090b59eb05 606
wim 3:2dccfa0121de 607 _wr_reg(0x0030,0x0707); delay(5); // Gamma
wim 3:2dccfa0121de 608 _wr_reg(0x0031,0x0204); delay(5);
wim 3:2dccfa0121de 609 _wr_reg(0x0032,0x0204); delay(5);
wim 3:2dccfa0121de 610 _wr_reg(0x0033,0x0502); delay(5);
wim 3:2dccfa0121de 611 _wr_reg(0x0034,0x0507); delay(5);
wim 3:2dccfa0121de 612 _wr_reg(0x0035,0x0204); delay(5);
wim 3:2dccfa0121de 613 _wr_reg(0x0036,0x0204); delay(5);
wim 3:2dccfa0121de 614 _wr_reg(0x0037,0x0502); delay(5);
wim 3:2dccfa0121de 615 _wr_reg(0x003A,0x0302); delay(5);
wim 3:2dccfa0121de 616 _wr_reg(0x003B,0x0302); delay(5);
wim 0:a8090b59eb05 617
wim 3:2dccfa0121de 618 _wr_reg(0x0023,0x0000); delay(5); // Write data mask (default)
wim 3:2dccfa0121de 619 _wr_reg(0x0024,0x0000); delay(5);
wim 0:a8090b59eb05 620
wim 3:2dccfa0121de 621 _wr_reg(0x0025,0x8000); delay(5); // Frame freq 65 Hz
wim 3:2dccfa0121de 622 _wr_reg(0x004e,0); // Start x
wim 3:2dccfa0121de 623 _wr_reg(0x004f,0); // Start y
wim 2:43ede88fb5a3 624 #endif
wim 0:a8090b59eb05 625 break;
wim 0:a8090b59eb05 626 }
wim 0:a8090b59eb05 627
wim 0:a8090b59eb05 628
wim 0:a8090b59eb05 629 case SSD1298_ID: {
wim 2:43ede88fb5a3 630
wim 2:43ede88fb5a3 631 #ifndef DISABLE_SSD1298_ID
wim 3:2dccfa0121de 632 _wr_reg(0x0028,0x0006);
wim 3:2dccfa0121de 633 _wr_reg(0x0000,0x0001);
wim 3:2dccfa0121de 634 _wr_reg(0x0003,0xaea4); /* power control 1---line frequency and VHG,VGL voltage */
wim 3:2dccfa0121de 635 _wr_reg(0x000c,0x0004); /* power control 2---VCIX2 output voltage */
wim 3:2dccfa0121de 636 _wr_reg(0x000d,0x000c); /* power control 3---Vlcd63 voltage */
wim 3:2dccfa0121de 637 _wr_reg(0x000e,0x2800); /* power control 4---VCOMA voltage VCOML=VCOMH*0.9475-VCOMA */
wim 3:2dccfa0121de 638 _wr_reg(0x001e,0x00b5); /* POWER CONTROL 5---VCOMH voltage */
wim 3:2dccfa0121de 639 _wr_reg(0x0001,0x3b3f);
wim 3:2dccfa0121de 640 _wr_reg(0x0002,0x0600);
wim 3:2dccfa0121de 641 _wr_reg(0x0010,0x0000);
wim 3:2dccfa0121de 642 _wr_reg(0x0011,0x6830);
wim 3:2dccfa0121de 643 _wr_reg(0x0005,0x0000);
wim 3:2dccfa0121de 644 _wr_reg(0x0006,0x0000);
wim 3:2dccfa0121de 645 _wr_reg(0x0016,0xef1c);
wim 3:2dccfa0121de 646 _wr_reg(0x0007,0x0033); /* Display control 1 */
wim 0:a8090b59eb05 647 /* when GON=1 and DTE=0,all gate outputs become VGL */
wim 0:a8090b59eb05 648 /* when GON=1 and DTE=0,all gate outputs become VGH */
wim 0:a8090b59eb05 649 /* non-selected gate wires become VGL */
wim 3:2dccfa0121de 650 _wr_reg(0x000b,0x0000);
wim 3:2dccfa0121de 651 _wr_reg(0x000f,0x0000);
wim 3:2dccfa0121de 652 _wr_reg(0x0041,0x0000);
wim 3:2dccfa0121de 653 _wr_reg(0x0042,0x0000);
wim 3:2dccfa0121de 654 _wr_reg(0x0048,0x0000);
wim 3:2dccfa0121de 655 _wr_reg(0x0049,0x013f);
wim 3:2dccfa0121de 656 _wr_reg(0x004a,0x0000);
wim 3:2dccfa0121de 657 _wr_reg(0x004b,0x0000);
wim 3:2dccfa0121de 658 _wr_reg(0x0044,0xef00); /* Horizontal RAM start and end address */
wim 3:2dccfa0121de 659 _wr_reg(0x0045,0x0000); /* Vretical RAM start address */
wim 3:2dccfa0121de 660 _wr_reg(0x0046,0x013f); /* Vretical RAM end address */
wim 3:2dccfa0121de 661 _wr_reg(0x004e,0x0000); /* set GDDRAM x address counter */
wim 3:2dccfa0121de 662 _wr_reg(0x004f,0x0000); /* set GDDRAM y address counter */
wim 0:a8090b59eb05 663 /* y control */
wim 3:2dccfa0121de 664 _wr_reg(0x0030,0x0707);
wim 3:2dccfa0121de 665 _wr_reg(0x0031,0x0202);
wim 3:2dccfa0121de 666 _wr_reg(0x0032,0x0204);
wim 3:2dccfa0121de 667 _wr_reg(0x0033,0x0502);
wim 3:2dccfa0121de 668 _wr_reg(0x0034,0x0507);
wim 3:2dccfa0121de 669 _wr_reg(0x0035,0x0204);
wim 3:2dccfa0121de 670 _wr_reg(0x0036,0x0204);
wim 3:2dccfa0121de 671 _wr_reg(0x0037,0x0502);
wim 3:2dccfa0121de 672 _wr_reg(0x003a,0x0302);
wim 3:2dccfa0121de 673 _wr_reg(0x003b,0x0302);
wim 3:2dccfa0121de 674 _wr_reg(0x0023,0x0000);
wim 3:2dccfa0121de 675 _wr_reg(0x0024,0x0000);
wim 3:2dccfa0121de 676 _wr_reg(0x0025,0x8000);
wim 3:2dccfa0121de 677 _wr_reg(0x0026,0x7000);
wim 3:2dccfa0121de 678 _wr_reg(0x0020,0xb0eb);
wim 3:2dccfa0121de 679 _wr_reg(0x0027,0x007c);
wim 2:43ede88fb5a3 680 #endif
wim 0:a8090b59eb05 681 break;
wim 0:a8090b59eb05 682 }
wim 0:a8090b59eb05 683
wim 0:a8090b59eb05 684 case SSD2119_ID: {
wim 2:43ede88fb5a3 685
wim 2:43ede88fb5a3 686 #ifndef DISABLE_SSD2119_ID
wim 0:a8090b59eb05 687 /* POWER ON & RESET DISPLAY OFF */
wim 3:2dccfa0121de 688 _wr_reg(0x28,0x0006);
wim 3:2dccfa0121de 689 _wr_reg(0x00,0x0001);
wim 3:2dccfa0121de 690 _wr_reg(0x10,0x0000);
wim 3:2dccfa0121de 691 _wr_reg(0x01,0x72ef);
wim 3:2dccfa0121de 692 _wr_reg(0x02,0x0600);
wim 3:2dccfa0121de 693 _wr_reg(0x03,0x6a38);
wim 3:2dccfa0121de 694 _wr_reg(0x11,0x6874);
wim 3:2dccfa0121de 695 _wr_reg(0x0f,0x0000); /* RAM WRITE DATA MASK */
wim 3:2dccfa0121de 696 _wr_reg(0x0b,0x5308); /* RAM WRITE DATA MASK */
wim 3:2dccfa0121de 697 _wr_reg(0x0c,0x0003);
wim 3:2dccfa0121de 698 _wr_reg(0x0d,0x000a);
wim 3:2dccfa0121de 699 _wr_reg(0x0e,0x2e00);
wim 3:2dccfa0121de 700 _wr_reg(0x1e,0x00be);
wim 3:2dccfa0121de 701 _wr_reg(0x25,0x8000);
wim 3:2dccfa0121de 702 _wr_reg(0x26,0x7800);
wim 3:2dccfa0121de 703 _wr_reg(0x27,0x0078);
wim 3:2dccfa0121de 704 _wr_reg(0x4e,0x0000);
wim 3:2dccfa0121de 705 _wr_reg(0x4f,0x0000);
wim 3:2dccfa0121de 706 _wr_reg(0x12,0x08d9);
wim 0:a8090b59eb05 707 /* Adjust the Gamma Curve */
wim 3:2dccfa0121de 708 _wr_reg(0x30,0x0000);
wim 3:2dccfa0121de 709 _wr_reg(0x31,0x0104);
wim 3:2dccfa0121de 710 _wr_reg(0x32,0x0100);
wim 3:2dccfa0121de 711 _wr_reg(0x33,0x0305);
wim 3:2dccfa0121de 712 _wr_reg(0x34,0x0505);
wim 3:2dccfa0121de 713 _wr_reg(0x35,0x0305);
wim 3:2dccfa0121de 714 _wr_reg(0x36,0x0707);
wim 3:2dccfa0121de 715 _wr_reg(0x37,0x0300);
wim 3:2dccfa0121de 716 _wr_reg(0x3a,0x1200);
wim 3:2dccfa0121de 717 _wr_reg(0x3b,0x0800);
wim 3:2dccfa0121de 718 _wr_reg(0x07,0x0033);
wim 2:43ede88fb5a3 719 #endif
wim 0:a8090b59eb05 720 break;
wim 0:a8090b59eb05 721 }
wim 0:a8090b59eb05 722
wim 0:a8090b59eb05 723
wim 0:a8090b59eb05 724
wim 0:a8090b59eb05 725 #if(0)
wim 0:a8090b59eb05 726
wim 0:a8090b59eb05 727 // Note: unprintable char hidden as space and as nl !!!
wim 0:a8090b59eb05 728  case R61505U_ID1:
wim 0:a8090b59eb05 729  case R61505U_ID2:  {
wim 0:a8090b59eb05 730
wim 2:43ede88fb5a3 731 #ifndef DISABLE_R61505U
wim 0:a8090b59eb05 732       /* second release on 3/5  ,luminance is acceptable,water wave appear during camera preview */
wim 3:2dccfa0121de 733        _wr_reg(0x0007,0x0000);
wim 0:a8090b59eb05 734        delay(50);  /* delay 50 ms */      
wim 3:2dccfa0121de 735        _wr_reg(0x0012,0x011C);    /* why need to set several times?   */
wim 3:2dccfa0121de 736        _wr_reg(0x00A4,0x0001);    /* NVM */
wim 3:2dccfa0121de 737        _wr_reg(0x0008,0x000F);
wim 3:2dccfa0121de 738        _wr_reg(0x000A,0x0008);
wim 3:2dccfa0121de 739        _wr_reg(0x000D,0x0008);
wim 0:a8090b59eb05 740        /* GAMMA CONTROL */
wim 3:2dccfa0121de 741        _wr_reg(0x0030,0x0707);
wim 3:2dccfa0121de 742        _wr_reg(0x0031,0x0007);
wim 3:2dccfa0121de 743        _wr_reg(0x0032,0x0603);
wim 3:2dccfa0121de 744        _wr_reg(0x0033,0x0700);
wim 3:2dccfa0121de 745        _wr_reg(0x0034,0x0202);
wim 3:2dccfa0121de 746        _wr_reg(0x0035,0x0002);
wim 3:2dccfa0121de 747        _wr_reg(0x0036,0x1F0F);
wim 3:2dccfa0121de 748        _wr_reg(0x0037,0x0707);
wim 3:2dccfa0121de 749        _wr_reg(0x0038,0x0000);
wim 3:2dccfa0121de 750        _wr_reg(0x0039,0x0000);
wim 3:2dccfa0121de 751        _wr_reg(0x003A,0x0707);
wim 3:2dccfa0121de 752        _wr_reg(0x003B,0x0000);
wim 3:2dccfa0121de 753        _wr_reg(0x003C,0x0007);
wim 3:2dccfa0121de 754        _wr_reg(0x003D,0x0000);
wim 0:a8090b59eb05 755        delay(50);  /* delay 50 ms */      
wim 3:2dccfa0121de 756        _wr_reg(0x0007,0x0001);
wim 3:2dccfa0121de 757        _wr_reg(0x0017,0x0001);    /* Power supply startup enable */
wim 0:a8090b59eb05 758        delay(50);  /* delay 50 ms */      
wim 0:a8090b59eb05 759        /* power control */
wim 3:2dccfa0121de 760        _wr_reg(0x0010,0x17A0);
wim 3:2dccfa0121de 761        _wr_reg(0x0011,0x0217); /* reference voltage VC[2:0]   Vciout = 1.00*Vcivl */
wim 3:2dccfa0121de 762        _wr_reg(0x0012,0x011E); /* Vreg1out = Vcilvl*1.80   is it the same as Vgama1out ?   */
wim 3:2dccfa0121de 763        _wr_reg(0x0013,0x0F00); /* VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl */
wim 3:2dccfa0121de 764        _wr_reg(0x002A,0x0000);
wim 3:2dccfa0121de 765        _wr_reg(0x0029,0x000A); /* Vcomh = VCM1[4:0]*Vreg1out    gate source voltage?? */
wim 3:2dccfa0121de 766        _wr_reg(0x0012,0x013E); /* power supply on */
wim 0:a8090b59eb05 767        /* Coordinates Control */
wim 3:2dccfa0121de 768        _wr_reg(0x0050,0x0000);
wim 3:2dccfa0121de 769        _wr_reg(0x0051,0x00EF);
wim 3:2dccfa0121de 770        _wr_reg(0x0052,0x0000);
wim 3:2dccfa0121de 771        _wr_reg(0x0053,0x013F);
wim 0:a8090b59eb05 772        /* Pannel Image Control */
wim 3:2dccfa0121de 773        _wr_reg(0x0060,0x2700);
wim 3:2dccfa0121de 774        _wr_reg(0x0061,0x0001);
wim 3:2dccfa0121de 775        _wr_reg(0x006A,0x0000);
wim 3:2dccfa0121de 776        _wr_reg(0x0080,0x0000);
wim 0:a8090b59eb05 777        /* Partial Image Control */
wim 3:2dccfa0121de 778        _wr_reg(0x0081,0x0000);
wim 3:2dccfa0121de 779        _wr_reg(0x0082,0x0000);
wim 3:2dccfa0121de 780        _wr_reg(0x0083,0x0000);
wim 3:2dccfa0121de 781        _wr_reg(0x0084,0x0000);
wim 3:2dccfa0121de 782        _wr_reg(0x0085,0x0000);
wim 0:a8090b59eb05 783        /* Panel Interface Control */
wim 3:2dccfa0121de 784        _wr_reg(0x0090,0x0013);      /* frenqucy */   
wim 3:2dccfa0121de 785        _wr_reg(0x0092,0x0300);
wim 3:2dccfa0121de 786        _wr_reg(0x0093,0x0005);
wim 3:2dccfa0121de 787        _wr_reg(0x0095,0x0000);
wim 3:2dccfa0121de 788        _wr_reg(0x0097,0x0000);
wim 3:2dccfa0121de 789        _wr_reg(0x0098,0x0000);
wim 0:a8090b59eb05 790
wim 3:2dccfa0121de 791        _wr_reg(0x0001,0x0100);
wim 3:2dccfa0121de 792        _wr_reg(0x0002,0x0700);
wim 3:2dccfa0121de 793        _wr_reg(0x0003,0x1030);
wim 3:2dccfa0121de 794        _wr_reg(0x0004,0x0000);
wim 3:2dccfa0121de 795        _wr_reg(0x000C,0x0000);
wim 3:2dccfa0121de 796        _wr_reg(0x000F,0x0000);
wim 3:2dccfa0121de 797        _wr_reg(0x0020,0x0000);
wim 3:2dccfa0121de 798        _wr_reg(0x0021,0x0000);
wim 3:2dccfa0121de 799        _wr_reg(0x0007,0x0021);
wim 0:a8090b59eb05 800        delay(200);  /* delay 200 ms */      
wim 3:2dccfa0121de 801        _wr_reg(0x0007,0x0061);
wim 0:a8090b59eb05 802        delay(200);  /* delay 200 ms */      
wim 3:2dccfa0121de 803        _wr_reg(0x0007,0x0173);
wim 2:43ede88fb5a3 804 #endif
wim 0:a8090b59eb05 805 break;
wim 0:a8090b59eb05 806    } 
wim 0:a8090b59eb05 807
wim 0:a8090b59eb05 808  case SPFD5408B_ID: {
wim 2:43ede88fb5a3 809
wim 2:43ede88fb5a3 810 #ifndef DISABLE_SPFD5408B
wim 3:2dccfa0121de 811       _wr_reg(0x0001,0x0100);     /* Driver Output Contral Register */
wim 3:2dccfa0121de 812       _wr_reg(0x0002,0x0700);      /* LCD Driving Waveform Contral */
wim 3:2dccfa0121de 813       _wr_reg(0x0003,0x1030);     /* Entry ModeÉèÖÃ */
wim 0:a8090b59eb05 814       
wim 3:2dccfa0121de 815       _wr_reg(0x0004,0x0000);     /* Scalling Control register */
wim 3:2dccfa0121de 816       _wr_reg(0x0008,0x0207);     /* Display Control 2 */
wim 3:2dccfa0121de 817       _wr_reg(0x0009,0x0000);     /* Display Control 3 */
wim 3:2dccfa0121de 818       _wr_reg(0x000A,0x0000);     /* Frame Cycle Control */
wim 3:2dccfa0121de 819       _wr_reg(0x000C,0x0000);     /* External Display Interface Control 1 */
wim 3:2dccfa0121de 820       _wr_reg(0x000D,0x0000);      /* Frame Maker Position */
wim 3:2dccfa0121de 821       _wr_reg(0x000F,0x0000);     /* External Display Interface Control 2 */
wim 0:a8090b59eb05 822       delay(50);
wim 3:2dccfa0121de 823       _wr_reg(0x0007,0x0101);     /* Display Control */
wim 0:a8090b59eb05 824       delay(50);
wim 3:2dccfa0121de 825       _wr_reg(0x0010,0x16B0);      /* Power Control 1 */
wim 3:2dccfa0121de 826       _wr_reg(0x0011,0x0001);      /* Power Control 2 */
wim 3:2dccfa0121de 827       _wr_reg(0x0017,0x0001);      /* Power Control 3 */
wim 3:2dccfa0121de 828       _wr_reg(0x0012,0x0138);      /* Power Control 4 */
wim 3:2dccfa0121de 829       _wr_reg(0x0013,0x0800);      /* Power Control 5 */
wim 3:2dccfa0121de 830       _wr_reg(0x0029,0x0009);     /* NVM read data 2 */
wim 3:2dccfa0121de 831       _wr_reg(0x002a,0x0009);     /* NVM read data 3 */
wim 3:2dccfa0121de 832       _wr_reg(0x00a4,0x0000); 
wim 3:2dccfa0121de 833       _wr_reg(0x0050,0x0000);     /* ÉèÖòÙ×÷´°¿ÚµÄXÖῪʼÁÐ */
wim 3:2dccfa0121de 834       _wr_reg(0x0051,0x00EF);     /* ÉèÖòÙ×÷´°¿ÚµÄXÖá½áÊøÁÐ */
wim 3:2dccfa0121de 835       _wr_reg(0x0052,0x0000);     /* ÉèÖòÙ×÷´°¿ÚµÄYÖῪʼÐÐ */
wim 3:2dccfa0121de 836       _wr_reg(0x0053,0x013F);     /* ÉèÖòÙ×÷´°¿ÚµÄYÖá½áÊøÐÐ */
wim 0:a8090b59eb05 837          
wim 3:2dccfa0121de 838       _wr_reg(0x0060,0x2700);     /* Driver Output Control */
wim 0:a8090b59eb05 839                                 /* ÉèÖÃÆÁÄ»µÄµãÊýÒÔ¼°É¨ÃèµÄÆðʼÐÐ */
wim 3:2dccfa0121de 840       _wr_reg(0x0061,0x0003);     /* Driver Output Control */
wim 3:2dccfa0121de 841       _wr_reg(0x006A,0x0000);     /* Vertical Scroll Control */
wim 0:a8090b59eb05 842       
wim 3:2dccfa0121de 843       _wr_reg(0x0080,0x0000);     /* Display Position ¨C Partial Display 1 */
wim 3:2dccfa0121de 844       _wr_reg(0x0081,0x0000);     /* RAM Address Start ¨C Partial Display 1 */
wim 3:2dccfa0121de 845       _wr_reg(0x0082,0x0000);     /* RAM address End - Partial Display 1 */
wim 3:2dccfa0121de 846       _wr_reg(0x0083,0x0000);     /* Display Position ¨C Partial Display 2 */
wim 3:2dccfa0121de 847       _wr_reg(0x0084,0x0000);     /* RAM Address Start ¨C Partial Display 2 */
wim 3:2dccfa0121de 848       _wr_reg(0x0085,0x0000);     /* RAM address End ¨C Partail Display2 */
wim 3:2dccfa0121de 849       _wr_reg(0x0090,0x0013);     /* Frame Cycle Control */
wim 3:2dccfa0121de 850       _wr_reg(0x0092,0x0000);      /* Panel Interface Control 2 */
wim 3:2dccfa0121de 851       _wr_reg(0x0093,0x0003);     /* Panel Interface control 3 */
wim 3:2dccfa0121de 852       _wr_reg(0x0095,0x0110);     /* Frame Cycle Control */
wim 3:2dccfa0121de 853       _wr_reg(0x0007,0x0173);
wim 2:43ede88fb5a3 854 #endif
wim 0:a8090b59eb05 855 break;
wim 0:a8090b59eb05 856    }
wim 0:a8090b59eb05 857
wim 0:a8090b59eb05 858   case LGDP4531_ID: {
wim 2:43ede88fb5a3 859
wim 2:43ede88fb5a3 860 #ifndef DISABLE_LGDP4531
wim 0:a8090b59eb05 861       /* Setup display */
wim 3:2dccfa0121de 862       _wr_reg(0x00,0x0001);
wim 3:2dccfa0121de 863       _wr_reg(0x10,0x0628);
wim 3:2dccfa0121de 864       _wr_reg(0x12,0x0006);
wim 3:2dccfa0121de 865       _wr_reg(0x13,0x0A32);
wim 3:2dccfa0121de 866       _wr_reg(0x11,0x0040);
wim 3:2dccfa0121de 867       _wr_reg(0x15,0x0050);
wim 3:2dccfa0121de 868       _wr_reg(0x12,0x0016);
wim 0:a8090b59eb05 869       delay(50);
wim 3:2dccfa0121de 870       _wr_reg(0x10,0x5660);
wim 0:a8090b59eb05 871       delay(50);
wim 3:2dccfa0121de 872       _wr_reg(0x13,0x2A4E);
wim 3:2dccfa0121de 873       _wr_reg(0x01,0x0100);
wim 3:2dccfa0121de 874       _wr_reg(0x02,0x0300);   
wim 3:2dccfa0121de 875       _wr_reg(0x03,0x1030);      
wim 3:2dccfa0121de 876       _wr_reg(0x08,0x0202);
wim 3:2dccfa0121de 877       _wr_reg(0x0A,0x0000);
wim 3:2dccfa0121de 878       _wr_reg(0x30,0x0000);
wim 3:2dccfa0121de 879       _wr_reg(0x31,0x0402);
wim 3:2dccfa0121de 880       _wr_reg(0x32,0x0106);
wim 3:2dccfa0121de 881       _wr_reg(0x33,0x0700);
wim 3:2dccfa0121de 882       _wr_reg(0x34,0x0104);
wim 3:2dccfa0121de 883       _wr_reg(0x35,0x0301);
wim 3:2dccfa0121de 884       _wr_reg(0x36,0x0707);
wim 3:2dccfa0121de 885       _wr_reg(0x37,0x0305);
wim 3:2dccfa0121de 886       _wr_reg(0x38,0x0208);
wim 3:2dccfa0121de 887       _wr_reg(0x39,0x0F0B);
wim 0:a8090b59eb05 888       delay(50);
wim 3:2dccfa0121de 889       _wr_reg(0x41,0x0002);
wim 3:2dccfa0121de 890       _wr_reg(0x60,0x2700);
wim 3:2dccfa0121de 891       _wr_reg(0x61,0x0001);
wim 3:2dccfa0121de 892       _wr_reg(0x90,0x0119);
wim 3:2dccfa0121de 893       _wr_reg(0x92,0x010A);
wim 3:2dccfa0121de 894       _wr_reg(0x93,0x0004);
wim 3:2dccfa0121de 895       _wr_reg(0xA0,0x0100);
wim 0:a8090b59eb05 896       delay(50);
wim 3:2dccfa0121de 897       _wr_reg(0x07,0x0133);
wim 0:a8090b59eb05 898       delay(50);
wim 3:2dccfa0121de 899       _wr_reg(0xA0,0x0000);
wim 2:43ede88fb5a3 900 #endif
wim 0:a8090b59eb05 901 break;
wim 0:a8090b59eb05 902    }
wim 0:a8090b59eb05 903
wim 0:a8090b59eb05 904   case LGDP4535_ID: {   
wim 2:43ede88fb5a3 905
wim 2:43ede88fb5a3 906 #ifndef DISABLE_LGDP4535
wim 3:2dccfa0121de 907       _wr_reg(0x15, 0x0030);     /* Set the internal vcore voltage */                                             
wim 3:2dccfa0121de 908       _wr_reg(0x9A, 0x0010);     /* Start internal OSC */
wim 3:2dccfa0121de 909       _wr_reg(0x11, 0x0020);        /* set SS and SM bit */
wim 3:2dccfa0121de 910       _wr_reg(0x10, 0x3428);        /* set 1 line inversion */
wim 3:2dccfa0121de 911       _wr_reg(0x12, 0x0002);        /* set GRAM write direction and BGR=1 */
wim 3:2dccfa0121de 912       _wr_reg(0x13, 0x1038);        /* Resize register */
wim 0:a8090b59eb05 913       delay(40);
wim 3:2dccfa0121de 914       _wr_reg(0x12, 0x0012);        /* set the back porch and front porch */
wim 0:a8090b59eb05 915       delay(40);
wim 3:2dccfa0121de 916       _wr_reg(0x10, 0x3420);        /* set non-display area refresh cycle ISC[3:0] */
wim 3:2dccfa0121de 917       _wr_reg(0x13, 0x3045);        /* FMARK function */
wim 0:a8090b59eb05 918       delay(70);
wim 3:2dccfa0121de 919       _wr_reg(0x30, 0x0000);      /* RGB interface setting */
wim 3:2dccfa0121de 920       _wr_reg(0x31, 0x0402);        /* Frame marker Position */
wim 3:2dccfa0121de 921       _wr_reg(0x32, 0x0307);      /* RGB interface polarity */
wim 3:2dccfa0121de 922       _wr_reg(0x33, 0x0304);      /* SAP, BT[3:0], AP, DSTB, SLP, STB */
wim 3:2dccfa0121de 923       _wr_reg(0x34, 0x0004);      /* DC1[2:0], DC0[2:0], VC[2:0] */
wim 3:2dccfa0121de 924       _wr_reg(0x35, 0x0401);      /* VREG1OUT voltage */
wim 3:2dccfa0121de 925       _wr_reg(0x36, 0x0707);      /* VDV[4:0] for VCOM amplitude */
wim 3:2dccfa0121de 926       _wr_reg(0x37, 0x0305);      /* SAP, BT[3:0], AP, DSTB, SLP, STB */
wim 3:2dccfa0121de 927       _wr_reg(0x38, 0x0610);      /* DC1[2:0], DC0[2:0], VC[2:0] */
wim 3:2dccfa0121de 928       _wr_reg(0x39, 0x0610);      /* VREG1OUT voltage */
wim 3:2dccfa0121de 929       _wr_reg(0x01, 0x0100);      /* VDV[4:0] for VCOM amplitude */
wim 3:2dccfa0121de 930       _wr_reg(0x02, 0x0300);      /* VCM[4:0] for VCOMH */
wim 3:2dccfa0121de 931       _wr_reg(0x03, 0x1030);      /* GRAM horizontal Address */
wim 3:2dccfa0121de 932       _wr_reg(0x08, 0x0808);      /* GRAM Vertical Address */
wim 3:2dccfa0121de 933       _wr_reg(0x0A, 0x0008);      
wim 3:2dccfa0121de 934       _wr_reg(0x60, 0x2700);        /* Gate Scan Line */
wim 3:2dccfa0121de 935       _wr_reg(0x61, 0x0001);        /* NDL,VLE, REV */
wim 3:2dccfa0121de 936       _wr_reg(0x90, 0x013E);
wim 3:2dccfa0121de 937       _wr_reg(0x92, 0x0100);
wim 3:2dccfa0121de 938       _wr_reg(0x93, 0x0100);
wim 3:2dccfa0121de 939       _wr_reg(0xA0, 0x3000);
wim 3:2dccfa0121de 940       _wr_reg(0xA3, 0x0010);
wim 3:2dccfa0121de 941       _wr_reg(0x07, 0x0001);
wim 3:2dccfa0121de 942       _wr_reg(0x07, 0x0021);
wim 3:2dccfa0121de 943       _wr_reg(0x07, 0x0023);
wim 3:2dccfa0121de 944       _wr_reg(0x07, 0x0033);
wim 3:2dccfa0121de 945       _wr_reg(0x07, 0x0133);
wim 2:43ede88fb5a3 946 #endif
wim 0:a8090b59eb05 947 break;
wim 0:a8090b59eb05 948    }
wim 0:a8090b59eb05 949
wim 0:a8090b59eb05 950   case HX8347D_ID: {
wim 2:43ede88fb5a3 951
wim 2:43ede88fb5a3 952 #ifndef DISABLE_HX8347D
wim 0:a8090b59eb05 953       /* Start Initial Sequence */
wim 3:2dccfa0121de 954       _wr_reg(0xEA,0x00);                         
wim 3:2dccfa0121de 955       _wr_reg(0xEB,0x20);                                                     
wim 3:2dccfa0121de 956       _wr_reg(0xEC,0x0C);                                                   
wim 3:2dccfa0121de 957       _wr_reg(0xED,0xC4);                                                   
wim 3:2dccfa0121de 958       _wr_reg(0xE8,0x40);                                                     
wim 3:2dccfa0121de 959       _wr_reg(0xE9,0x38);                                                   
wim 3:2dccfa0121de 960       _wr_reg(0xF1,0x01);                                                   
wim 3:2dccfa0121de 961       _wr_reg(0xF2,0x10);                                                   
wim 3:2dccfa0121de 962       _wr_reg(0x27,0xA3);                                                   
wim 0:a8090b59eb05 963       /* GAMMA SETTING */
wim 3:2dccfa0121de 964       _wr_reg(0x40,0x01);                           
wim 3:2dccfa0121de 965       _wr_reg(0x41,0x00);                                                   
wim 3:2dccfa0121de 966       _wr_reg(0x42,0x00);                                                   
wim 3:2dccfa0121de 967       _wr_reg(0x43,0x10);                                                   
wim 3:2dccfa0121de 968       _wr_reg(0x44,0x0E);                                                   
wim 3:2dccfa0121de 969       _wr_reg(0x45,0x24);                                                 
wim 3:2dccfa0121de 970       _wr_reg(0x46,0x04);                                                 
wim 3:2dccfa0121de 971       _wr_reg(0x47,0x50);                                                   
wim 3:2dccfa0121de 972       _wr_reg(0x48,0x02);                                                   
wim 3:2dccfa0121de 973       _wr_reg(0x49,0x13);                                                 
wim 3:2dccfa0121de 974       _wr_reg(0x4A,0x19);                                                 
wim 3:2dccfa0121de 975       _wr_reg(0x4B,0x19);                                                 
wim 3:2dccfa0121de 976       _wr_reg(0x4C,0x16);                                                 
wim 3:2dccfa0121de 977       _wr_reg(0x50,0x1B);                                                   
wim 3:2dccfa0121de 978       _wr_reg(0x51,0x31);                                                   
wim 3:2dccfa0121de 979       _wr_reg(0x52,0x2F);                                                     
wim 3:2dccfa0121de 980       _wr_reg(0x53,0x3F);                                                   
wim 3:2dccfa0121de 981       _wr_reg(0x54,0x3F);                                                     
wim 3:2dccfa0121de 982       _wr_reg(0x55,0x3E);                                                     
wim 3:2dccfa0121de 983       _wr_reg(0x56,0x2F);                                                   
wim 3:2dccfa0121de 984       _wr_reg(0x57,0x7B);                                                     
wim 3:2dccfa0121de 985       _wr_reg(0x58,0x09);                                                 
wim 3:2dccfa0121de 986       _wr_reg(0x59,0x06);                                                 
wim 3:2dccfa0121de 987       _wr_reg(0x5A,0x06);                                                   
wim 3:2dccfa0121de 988       _wr_reg(0x5B,0x0C);                                                   
wim 3:2dccfa0121de 989       _wr_reg(0x5C,0x1D);                                                   
wim 3:2dccfa0121de 990       _wr_reg(0x5D,0xCC);                                                   
wim 0:a8090b59eb05 991       /* Power Voltage Setting */
wim 3:2dccfa0121de 992       _wr_reg(0x1B,0x18);                                                   
wim 3:2dccfa0121de 993       _wr_reg(0x1A,0x01);                                                   
wim 3:2dccfa0121de 994       _wr_reg(0x24,0x15);                                                   
wim 3:2dccfa0121de 995       _wr_reg(0x25,0x50);                                                   
wim 3:2dccfa0121de 996       _wr_reg(0x23,0x8B);                                                   
wim 3:2dccfa0121de 997       _wr_reg(0x18,0x36);                           
wim 3:2dccfa0121de 998       _wr_reg(0x19,0x01);                                                   
wim 3:2dccfa0121de 999       _wr_reg(0x01,0x00);                                                   
wim 3:2dccfa0121de 1000       _wr_reg(0x1F,0x88);                                                   
wim 0:a8090b59eb05 1001       delay(50);
wim 3:2dccfa0121de 1002       _wr_reg(0x1F,0x80);                                                 
wim 0:a8090b59eb05 1003       delay(50);
wim 3:2dccfa0121de 1004       _wr_reg(0x1F,0x90);                                                   
wim 0:a8090b59eb05 1005       delay(50);
wim 3:2dccfa0121de 1006       _wr_reg(0x1F,0xD0);                                                   
wim 0:a8090b59eb05 1007       delay(50);
wim 3:2dccfa0121de 1008       _wr_reg(0x17,0x05);                                                   
wim 3:2dccfa0121de 1009       _wr_reg(0x36,0x00);                                                   
wim 3:2dccfa0121de 1010       _wr_reg(0x28,0x38);                                                 
wim 0:a8090b59eb05 1011       delay(50);
wim 3:2dccfa0121de 1012       _wr_reg(0x28,0x3C); 
wim 2:43ede88fb5a3 1013 #endif
wim 0:a8090b59eb05 1014 break;
wim 0:a8090b59eb05 1015    }
wim 0:a8090b59eb05 1016
wim 0:a8090b59eb05 1017   case ST7781_ID: {
wim 2:43ede88fb5a3 1018
wim 2:43ede88fb5a3 1019 #ifndef DISABLE_ST7781
wim 0:a8090b59eb05 1020       /* Start Initial Sequence */
wim 3:2dccfa0121de 1021       _wr_reg(0x00FF,0x0001);
wim 3:2dccfa0121de 1022       _wr_reg(0x00F3,0x0008);
wim 3:2dccfa0121de 1023       _wr_reg(0x0001,0x0100);
wim 3:2dccfa0121de 1024       _wr_reg(0x0002,0x0700);
wim 3:2dccfa0121de 1025       _wr_reg(0x0003,0x1030); 
wim 3:2dccfa0121de 1026       _wr_reg(0x0008,0x0302);
wim 3:2dccfa0121de 1027       _wr_reg(0x0008,0x0207);
wim 3:2dccfa0121de 1028       _wr_reg(0x0009,0x0000);
wim 3:2dccfa0121de 1029       _wr_reg(0x000A,0x0000);
wim 3:2dccfa0121de 1030       _wr_reg(0x0010,0x0000); 
wim 3:2dccfa0121de 1031       _wr_reg(0x0011,0x0005);
wim 3:2dccfa0121de 1032       _wr_reg(0x0012,0x0000);
wim 3:2dccfa0121de 1033       _wr_reg(0x0013,0x0000);
wim 0:a8090b59eb05 1034       delay(50);
wim 3:2dccfa0121de 1035       _wr_reg(0x0010,0x12B0);
wim 0:a8090b59eb05 1036       delay(50);
wim 3:2dccfa0121de 1037       _wr_reg(0x0011,0x0007);
wim 0:a8090b59eb05 1038       delay(50);
wim 3:2dccfa0121de 1039       _wr_reg(0x0012,0x008B);
wim 0:a8090b59eb05 1040       delay(50);   
wim 3:2dccfa0121de 1041       _wr_reg(0x0013,0x1700);
wim 0:a8090b59eb05 1042       delay(50);   
wim 3:2dccfa0121de 1043       _wr_reg(0x0029,0x0022);      
wim 3:2dccfa0121de 1044       _wr_reg(0x0030,0x0000);
wim 3:2dccfa0121de 1045       _wr_reg(0x0031,0x0707);
wim 3:2dccfa0121de 1046       _wr_reg(0x0032,0x0505);
wim 3:2dccfa0121de 1047       _wr_reg(0x0035,0x0107);
wim 3:2dccfa0121de 1048       _wr_reg(0x0036,0x0008);
wim 3:2dccfa0121de 1049       _wr_reg(0x0037,0x0000);
wim 3:2dccfa0121de 1050       _wr_reg(0x0038,0x0202);
wim 3:2dccfa0121de 1051       _wr_reg(0x0039,0x0106);
wim 3:2dccfa0121de 1052       _wr_reg(0x003C,0x0202);
wim 3:2dccfa0121de 1053       _wr_reg(0x003D,0x0408);
wim 0:a8090b59eb05 1054       delay(50);            
wim 3:2dccfa0121de 1055       _wr_reg(0x0050,0x0000);      
wim 3:2dccfa0121de 1056       _wr_reg(0x0051,0x00EF);      
wim 3:2dccfa0121de 1057       _wr_reg(0x0052,0x0000);      
wim 3:2dccfa0121de 1058       _wr_reg(0x0053,0x013F);      
wim 3:2dccfa0121de 1059       _wr_reg(0x0060,0xA700);      
wim 3:2dccfa0121de 1060       _wr_reg(0x0061,0x0001);
wim 3:2dccfa0121de 1061       _wr_reg(0x0090,0x0033);            
wim 3:2dccfa0121de 1062       _wr_reg(0x002B,0x000B);      
wim 3:2dccfa0121de 1063       _wr_reg(0x0007,0x0133);
wim 2:43ede88fb5a3 1064 #endif
wim 0:a8090b59eb05 1065 break;
wim 0:a8090b59eb05 1066    }
wim 0:a8090b59eb05 1067 #endif
wim 0:a8090b59eb05 1068
wim 0:a8090b59eb05 1069 default: {
wim 0:a8090b59eb05 1070 /* special ID */
wim 3:2dccfa0121de 1071 _driverCode = _rd_reg(0x67);
wim 2:43ede88fb5a3 1072
wim 2:43ede88fb5a3 1073 if (_driverCode == HX8347A_ID) {
wim 2:43ede88fb5a3 1074
wim 2:43ede88fb5a3 1075 #ifndef DISABLE_HX8347A
wim 3:2dccfa0121de 1076 _wr_reg(0x0042,0x0008);
wim 0:a8090b59eb05 1077 /* Gamma setting */
wim 3:2dccfa0121de 1078 _wr_reg(0x0046,0x00B4);
wim 3:2dccfa0121de 1079 _wr_reg(0x0047,0x0043);
wim 3:2dccfa0121de 1080 _wr_reg(0x0048,0x0013);
wim 3:2dccfa0121de 1081 _wr_reg(0x0049,0x0047);
wim 3:2dccfa0121de 1082 _wr_reg(0x004A,0x0014);
wim 3:2dccfa0121de 1083 _wr_reg(0x004B,0x0036);
wim 3:2dccfa0121de 1084 _wr_reg(0x004C,0x0003);
wim 3:2dccfa0121de 1085 _wr_reg(0x004D,0x0046);
wim 3:2dccfa0121de 1086 _wr_reg(0x004E,0x0005);
wim 3:2dccfa0121de 1087 _wr_reg(0x004F,0x0010);
wim 3:2dccfa0121de 1088 _wr_reg(0x0050,0x0008);
wim 3:2dccfa0121de 1089 _wr_reg(0x0051,0x000a);
wim 0:a8090b59eb05 1090 /* Window Setting */
wim 3:2dccfa0121de 1091 _wr_reg(0x0002,0x0000);
wim 3:2dccfa0121de 1092 _wr_reg(0x0003,0x0000);
wim 3:2dccfa0121de 1093 _wr_reg(0x0004,0x0000);
wim 3:2dccfa0121de 1094 _wr_reg(0x0005,0x00EF);
wim 3:2dccfa0121de 1095 _wr_reg(0x0006,0x0000);
wim 3:2dccfa0121de 1096 _wr_reg(0x0007,0x0000);
wim 3:2dccfa0121de 1097 _wr_reg(0x0008,0x0001);
wim 3:2dccfa0121de 1098 _wr_reg(0x0009,0x003F);
wim 0:a8090b59eb05 1099 delay(10);
wim 3:2dccfa0121de 1100 _wr_reg(0x0001,0x0006);
wim 3:2dccfa0121de 1101 _wr_reg(0x0016,0x00C8);
wim 3:2dccfa0121de 1102 _wr_reg(0x0023,0x0095);
wim 3:2dccfa0121de 1103 _wr_reg(0x0024,0x0095);
wim 3:2dccfa0121de 1104 _wr_reg(0x0025,0x00FF);
wim 3:2dccfa0121de 1105 _wr_reg(0x0027,0x0002);
wim 3:2dccfa0121de 1106 _wr_reg(0x0028,0x0002);
wim 3:2dccfa0121de 1107 _wr_reg(0x0029,0x0002);
wim 3:2dccfa0121de 1108 _wr_reg(0x002A,0x0002);
wim 3:2dccfa0121de 1109 _wr_reg(0x002C,0x0002);
wim 3:2dccfa0121de 1110 _wr_reg(0x002D,0x0002);
wim 3:2dccfa0121de 1111 _wr_reg(0x003A,0x0001);
wim 3:2dccfa0121de 1112 _wr_reg(0x003B,0x0001);
wim 3:2dccfa0121de 1113 _wr_reg(0x003C,0x00F0);
wim 3:2dccfa0121de 1114 _wr_reg(0x003D,0x0000);
wim 0:a8090b59eb05 1115 delay(20);
wim 3:2dccfa0121de 1116 _wr_reg(0x0035,0x0038);
wim 3:2dccfa0121de 1117 _wr_reg(0x0036,0x0078);
wim 3:2dccfa0121de 1118 _wr_reg(0x003E,0x0038);
wim 3:2dccfa0121de 1119 _wr_reg(0x0040,0x000F);
wim 3:2dccfa0121de 1120 _wr_reg(0x0041,0x00F0);
wim 3:2dccfa0121de 1121 _wr_reg(0x0038,0x0000);
wim 0:a8090b59eb05 1122 /* Power Setting */
wim 3:2dccfa0121de 1123 _wr_reg(0x0019,0x0049);
wim 3:2dccfa0121de 1124 _wr_reg(0x0093,0x000A);
wim 0:a8090b59eb05 1125 delay(10);
wim 3:2dccfa0121de 1126 _wr_reg(0x0020,0x0020);
wim 3:2dccfa0121de 1127 _wr_reg(0x001D,0x0003);
wim 3:2dccfa0121de 1128 _wr_reg(0x001E,0x0000);
wim 3:2dccfa0121de 1129 _wr_reg(0x001F,0x0009);
wim 3:2dccfa0121de 1130 _wr_reg(0x0044,0x0053);
wim 3:2dccfa0121de 1131 _wr_reg(0x0045,0x0010);
wim 0:a8090b59eb05 1132 delay(10);
wim 3:2dccfa0121de 1133 _wr_reg(0x001C,0x0004);
wim 0:a8090b59eb05 1134 delay(20);
wim 3:2dccfa0121de 1135 _wr_reg(0x0043,0x0080);
wim 0:a8090b59eb05 1136 delay(5);
wim 3:2dccfa0121de 1137 _wr_reg(0x001B,0x000a);
wim 0:a8090b59eb05 1138 delay(40);
wim 3:2dccfa0121de 1139 _wr_reg(0x001B,0x0012);
wim 0:a8090b59eb05 1140 delay(40);
wim 0:a8090b59eb05 1141 /* Display On Setting */
wim 3:2dccfa0121de 1142 _wr_reg(0x0090,0x007F);
wim 3:2dccfa0121de 1143 _wr_reg(0x0026,0x0004);
wim 0:a8090b59eb05 1144 delay(40);
wim 3:2dccfa0121de 1145 _wr_reg(0x0026,0x0024);
wim 3:2dccfa0121de 1146 _wr_reg(0x0026,0x002C);
wim 0:a8090b59eb05 1147 delay(40);
wim 3:2dccfa0121de 1148 _wr_reg(0x0070,0x0008);
wim 3:2dccfa0121de 1149 _wr_reg(0x0026,0x003C);
wim 3:2dccfa0121de 1150 _wr_reg(0x0057,0x0002);
wim 3:2dccfa0121de 1151 _wr_reg(0x0055,0x0000);
wim 3:2dccfa0121de 1152 _wr_reg(0x0057,0x0000);
wim 2:43ede88fb5a3 1153 #endif
wim 0:a8090b59eb05 1154 } // if
wim 2:43ede88fb5a3 1155
wim 0:a8090b59eb05 1156 break;
wim 0:a8090b59eb05 1157 } // default case
wim 0:a8090b59eb05 1158
wim 0:a8090b59eb05 1159 } // end switch
wim 0:a8090b59eb05 1160
wim 2:43ede88fb5a3 1161 _textColor = Black;
wim 2:43ede88fb5a3 1162 _backColor = White;
wim 0:a8090b59eb05 1163 }
wim 0:a8090b59eb05 1164
wim 0:a8090b59eb05 1165
wim 2:43ede88fb5a3 1166 int GLCD::getDisplayXSize()
wim 2:43ede88fb5a3 1167 {
wim 4:cdeea87f25d8 1168 return WIDTH;
wim 2:43ede88fb5a3 1169 }
wim 0:a8090b59eb05 1170
wim 2:43ede88fb5a3 1171 int GLCD::getDisplayYSize()
wim 2:43ede88fb5a3 1172 {
wim 4:cdeea87f25d8 1173 return HEIGHT;
wim 4:cdeea87f25d8 1174 }
wim 4:cdeea87f25d8 1175
wim 4:cdeea87f25d8 1176 int GLCD::getRows()
wim 4:cdeea87f25d8 1177 {
wim 4:cdeea87f25d8 1178 return ROWS;
wim 4:cdeea87f25d8 1179 }
wim 4:cdeea87f25d8 1180
wim 4:cdeea87f25d8 1181 int GLCD::getCols()
wim 4:cdeea87f25d8 1182 {
wim 4:cdeea87f25d8 1183 return COLS;
wim 2:43ede88fb5a3 1184 }
wim 0:a8090b59eb05 1185
wim 0:a8090b59eb05 1186
wim 0:a8090b59eb05 1187 /*******************************************************************************
wim 0:a8090b59eb05 1188 * Get LCD Controller ID *
wim 0:a8090b59eb05 1189 * Parameter: *
wim 0:a8090b59eb05 1190 * Return: short Controller ID *
wim 0:a8090b59eb05 1191 *******************************************************************************/
wim 3:2dccfa0121de 1192 uint16_t GLCD::getDriverCode () {
wim 0:a8090b59eb05 1193
wim 2:43ede88fb5a3 1194 return (_driverCode);
wim 0:a8090b59eb05 1195 }
wim 0:a8090b59eb05 1196
wim 0:a8090b59eb05 1197
wim 0:a8090b59eb05 1198 /*******************************************************************************
wim 0:a8090b59eb05 1199 * Set draw window region to whole screen *
wim 0:a8090b59eb05 1200 * Parameter: *
wim 0:a8090b59eb05 1201 * Return: *
wim 0:a8090b59eb05 1202 *******************************************************************************/
wim 0:a8090b59eb05 1203
wim 3:2dccfa0121de 1204 void GLCD::setWindowMax (void) {
wim 0:a8090b59eb05 1205
wim 2:43ede88fb5a3 1206 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1207 {
wim 3:2dccfa0121de 1208 _wr_reg(0x44, 0); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1209 _wr_reg(0x44, 0 |((HEIGHT-1)<<8)); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1210 _wr_reg(0x45, 0); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1211 _wr_reg(0x46, WIDTH-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1212 }
wim 0:a8090b59eb05 1213 else
wim 0:a8090b59eb05 1214 {
wim 3:2dccfa0121de 1215 _wr_reg(0x50, 0); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1216 _wr_reg(0x51, HEIGHT-1); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1217 _wr_reg(0x52, 0); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1218 _wr_reg(0x53, WIDTH-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1219 }
wim 0:a8090b59eb05 1220 }
wim 0:a8090b59eb05 1221
wim 0:a8090b59eb05 1222 /*******************************************************************************
wim 0:a8090b59eb05 1223 * Set draw window region *
wim 0:a8090b59eb05 1224 * Parameter: *
wim 0:a8090b59eb05 1225 * Return: *
wim 0:a8090b59eb05 1226 *******************************************************************************/
wim 0:a8090b59eb05 1227
wim 3:2dccfa0121de 1228 void GLCD::setWindow (int x1, int y1, int x2, int y2) {
wim 0:a8090b59eb05 1229
wim 2:43ede88fb5a3 1230 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1231 {
wim 3:2dccfa0121de 1232 // _wr_reg(0x44, x1); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1233 // _wr_reg(0x44, 0 | (x2<<8)); /* Horizontal GRAM End Address */
wim 0:a8090b59eb05 1234
wim 2:43ede88fb5a3 1235 //Note x,y flipped for landscape
wim 3:2dccfa0121de 1236 _wr_reg(0x44, ((y2 & 0xFF) <<8) | (y1 & 0xFF)); /* Horizontal GRAM End Address | Start Address */
wim 3:2dccfa0121de 1237 _wr_reg(0x45, x1); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1238 _wr_reg(0x46, x2); /* Vertical GRAM End Address */
wim 0:a8090b59eb05 1239
wim 3:2dccfa0121de 1240 _wr_reg(0x4e, y1); // Init x,y to start of window
wim 3:2dccfa0121de 1241 _wr_reg(0x4f, x1);
wim 0:a8090b59eb05 1242 }
wim 0:a8090b59eb05 1243 else
wim 0:a8090b59eb05 1244 {
wim 3:2dccfa0121de 1245 _wr_reg(0x50, x1); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1246 _wr_reg(0x51, x2); /* Horizontal GRAM End Address */
wim 3:2dccfa0121de 1247 _wr_reg(0x52, y1); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1248 _wr_reg(0x53, y2); /* Vertical GRAM End Address */
wim 0:a8090b59eb05 1249 }
wim 0:a8090b59eb05 1250 }
wim 0:a8090b59eb05 1251
wim 0:a8090b59eb05 1252 /*******************************************************************************
wim 0:a8090b59eb05 1253 * Draw a pixel in foreground color *
wim 0:a8090b59eb05 1254 * Parameter: x: horizontal position *
wim 0:a8090b59eb05 1255 * y: vertical position *
wim 0:a8090b59eb05 1256 * Return: *
wim 0:a8090b59eb05 1257 *******************************************************************************/
wim 0:a8090b59eb05 1258
wim 2:43ede88fb5a3 1259 void GLCD::drawPixel (unsigned int x, unsigned int y) {
wim 0:a8090b59eb05 1260 // Set Cursor
wim 2:43ede88fb5a3 1261 if(_driverCode==SSD1289_ID)
wim 2:43ede88fb5a3 1262 {
wim 3:2dccfa0121de 1263 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1264 // _wr_reg(0x4f, WIDTH-1-x);
wim 3:2dccfa0121de 1265 _wr_reg(0x4f, x);
wim 2:43ede88fb5a3 1266 }
wim 2:43ede88fb5a3 1267 else
wim 2:43ede88fb5a3 1268 {
wim 3:2dccfa0121de 1269 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1270 // _wr_reg(0x21, WIDTH-1-x);
wim 3:2dccfa0121de 1271 _wr_reg(0x21, x);
wim 2:43ede88fb5a3 1272 }
wim 2:43ede88fb5a3 1273 LCD_CS(0)
wim 3:2dccfa0121de 1274 _wr_cmd(0x22);
wim 3:2dccfa0121de 1275 _wr_dat(_textColor);
wim 2:43ede88fb5a3 1276 LCD_CS(1)
wim 2:43ede88fb5a3 1277 }
wim 2:43ede88fb5a3 1278
wim 3:2dccfa0121de 1279 void GLCD::drawPixel (unsigned int x, unsigned int y, uint16_t color)
wim 2:43ede88fb5a3 1280 {
wim 2:43ede88fb5a3 1281 // Set Cursor
wim 2:43ede88fb5a3 1282 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1283 {
wim 3:2dccfa0121de 1284 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1285 // _wr_reg(0x4f, WIDTH-1-x);
wim 3:2dccfa0121de 1286 _wr_reg(0x4f, x);
wim 0:a8090b59eb05 1287 }
wim 0:a8090b59eb05 1288 else
wim 0:a8090b59eb05 1289 {
wim 3:2dccfa0121de 1290 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1291 _wr_reg(0x21, WIDTH-1-x);
wim 0:a8090b59eb05 1292 }
wim 0:a8090b59eb05 1293 LCD_CS(0)
wim 3:2dccfa0121de 1294 _wr_cmd(0x22);
wim 3:2dccfa0121de 1295 _wr_dat(color);
wim 0:a8090b59eb05 1296 LCD_CS(1)
wim 0:a8090b59eb05 1297 }
wim 0:a8090b59eb05 1298
wim 0:a8090b59eb05 1299
wim 2:43ede88fb5a3 1300 void GLCD::drawPixel (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b)
wim 2:43ede88fb5a3 1301 {
wim 3:2dccfa0121de 1302 // uint16_t color = ((r & 0xF8)<<8) | ((g & 0xFC)<<3) | ((b & 0xF8)>>3); // rrrrrggggggbbbbb
wim 3:2dccfa0121de 1303 uint16_t color = RGB24toRGB16(r,g,b);
wim 2:43ede88fb5a3 1304
wim 2:43ede88fb5a3 1305
wim 2:43ede88fb5a3 1306 // Set Cursor
wim 2:43ede88fb5a3 1307 if(_driverCode==SSD1289_ID)
wim 2:43ede88fb5a3 1308 {
wim 3:2dccfa0121de 1309 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1310 // _wr_reg(0x4f, WIDTH-1-x);
wim 3:2dccfa0121de 1311 _wr_reg(0x4f, x);
wim 2:43ede88fb5a3 1312 }
wim 2:43ede88fb5a3 1313 else
wim 2:43ede88fb5a3 1314 {
wim 3:2dccfa0121de 1315 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1316 // _wr_reg(0x21, WIDTH-1-x);
wim 3:2dccfa0121de 1317 _wr_reg(0x21, x);
wim 2:43ede88fb5a3 1318 }
wim 2:43ede88fb5a3 1319 LCD_CS(0)
wim 3:2dccfa0121de 1320 _wr_cmd(0x22);
wim 3:2dccfa0121de 1321 _wr_dat(color);
wim 2:43ede88fb5a3 1322 LCD_CS(1)
wim 2:43ede88fb5a3 1323 }
wim 2:43ede88fb5a3 1324
wim 2:43ede88fb5a3 1325
wim 2:43ede88fb5a3 1326
wim 2:43ede88fb5a3 1327
wim 0:a8090b59eb05 1328 /*******************************************************************************
wim 0:a8090b59eb05 1329 * Set foreground color *
wim 0:a8090b59eb05 1330 * Parameter: color: foreground color *
wim 0:a8090b59eb05 1331 * Return: *
wim 0:a8090b59eb05 1332 *******************************************************************************/
wim 0:a8090b59eb05 1333
wim 3:2dccfa0121de 1334 void GLCD::setColor (uint16_t color) {
wim 2:43ede88fb5a3 1335
wim 2:43ede88fb5a3 1336 _textColor = color;
wim 2:43ede88fb5a3 1337 }
wim 0:a8090b59eb05 1338
wim 2:43ede88fb5a3 1339 void GLCD::setColor (uint8_t r, uint8_t g, uint8_t b) {
wim 3:2dccfa0121de 1340 uint16_t color = RGB24toRGB16(r,g,b);
wim 2:43ede88fb5a3 1341
wim 2:43ede88fb5a3 1342 _textColor = color;
wim 0:a8090b59eb05 1343 }
wim 0:a8090b59eb05 1344
wim 0:a8090b59eb05 1345
wim 2:43ede88fb5a3 1346
wim 2:43ede88fb5a3 1347
wim 2:43ede88fb5a3 1348
wim 0:a8090b59eb05 1349 /*******************************************************************************
wim 0:a8090b59eb05 1350 * Set background color *
wim 0:a8090b59eb05 1351 * Parameter: color: background color *
wim 0:a8090b59eb05 1352 * Return: *
wim 0:a8090b59eb05 1353 *******************************************************************************/
wim 0:a8090b59eb05 1354
wim 3:2dccfa0121de 1355 void GLCD::setBackColor (uint16_t color) {
wim 2:43ede88fb5a3 1356
wim 2:43ede88fb5a3 1357 _backColor = color;
wim 2:43ede88fb5a3 1358 }
wim 0:a8090b59eb05 1359
wim 2:43ede88fb5a3 1360
wim 2:43ede88fb5a3 1361 void GLCD::setBackColor (uint8_t r, uint8_t g, uint8_t b) {
wim 3:2dccfa0121de 1362 uint16_t color = RGB24toRGB16(r,g,b);
wim 2:43ede88fb5a3 1363
wim 2:43ede88fb5a3 1364 _backColor = color;
wim 0:a8090b59eb05 1365 }
wim 0:a8090b59eb05 1366
wim 0:a8090b59eb05 1367
wim 0:a8090b59eb05 1368 /*******************************************************************************
wim 0:a8090b59eb05 1369 * Clear display *
wim 0:a8090b59eb05 1370 * Parameter: color: display clearing color *
wim 0:a8090b59eb05 1371 * Return: *
wim 0:a8090b59eb05 1372 *******************************************************************************/
wim 0:a8090b59eb05 1373
wim 4:cdeea87f25d8 1374 void GLCD::cls (uint16_t color) {
wim 0:a8090b59eb05 1375 unsigned int i;
wim 0:a8090b59eb05 1376
wim 3:2dccfa0121de 1377 setWindowMax();
wim 0:a8090b59eb05 1378
wim 0:a8090b59eb05 1379 // Set Cursor
wim 2:43ede88fb5a3 1380 if (_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1381 {
wim 3:2dccfa0121de 1382 _wr_reg(0x4e, 0);
wim 3:2dccfa0121de 1383 _wr_reg(0x4f, 0);
wim 0:a8090b59eb05 1384 }
wim 0:a8090b59eb05 1385 else
wim 0:a8090b59eb05 1386 {
wim 3:2dccfa0121de 1387 _wr_reg(0x20, 0);
wim 3:2dccfa0121de 1388 _wr_reg(0x21, 0);
wim 0:a8090b59eb05 1389 }
wim 0:a8090b59eb05 1390 LCD_CS(0)
wim 3:2dccfa0121de 1391 _wr_cmd(0x22);
wim 3:2dccfa0121de 1392 _wr_dat_start();
wim 0:a8090b59eb05 1393 for(i = 0; i < (WIDTH*HEIGHT); i++)
wim 3:2dccfa0121de 1394 _wr_dat_only(color);
wim 3:2dccfa0121de 1395 _wr_dat_stop();
wim 4:cdeea87f25d8 1396
wim 4:cdeea87f25d8 1397 _ln = 0;
wim 4:cdeea87f25d8 1398 _col = 0;
wim 0:a8090b59eb05 1399 }
wim 0:a8090b59eb05 1400
wim 0:a8090b59eb05 1401
wim 0:a8090b59eb05 1402 /*******************************************************************************
wim 4:cdeea87f25d8 1403 * Draw character on given screen position *
wim 0:a8090b59eb05 1404 * Parameter: x: horizontal position *
wim 0:a8090b59eb05 1405 * y: vertical position *
wim 0:a8090b59eb05 1406 * c: pointer to character bitmap *
wim 0:a8090b59eb05 1407 * Return: *
wim 0:a8090b59eb05 1408 *******************************************************************************/
wim 0:a8090b59eb05 1409
wim 3:2dccfa0121de 1410 void GLCD::DrawChar (unsigned int x, unsigned int y, uint16_t *c) {
wim 0:a8090b59eb05 1411 int idx = 0, i, j;
wim 0:a8090b59eb05 1412
wim 1:ea0f7b1c5daf 1413 //wh x = WIDTH-x-CHAR_W;
wim 0:a8090b59eb05 1414
wim 2:43ede88fb5a3 1415 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1416 {
wim 3:2dccfa0121de 1417 //wh _wr_reg(0x44, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1418 _wr_reg(0x44, y |((y+CHAR_H-1)<<8)); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1419 _wr_reg(0x45, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1420 _wr_reg(0x46, x+CHAR_W-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1421
wim 3:2dccfa0121de 1422 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1423 _wr_reg(0x4f, x);
wim 0:a8090b59eb05 1424 }
wim 0:a8090b59eb05 1425 else
wim 0:a8090b59eb05 1426 {
wim 3:2dccfa0121de 1427 _wr_reg(0x50, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1428 _wr_reg(0x51, y+CHAR_H-1); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1429 _wr_reg(0x52, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1430 _wr_reg(0x53, x+CHAR_W-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1431
wim 3:2dccfa0121de 1432 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1433 _wr_reg(0x21, x);
wim 0:a8090b59eb05 1434 }
wim 0:a8090b59eb05 1435 LCD_CS(0)
wim 3:2dccfa0121de 1436 _wr_cmd(0x22);
wim 3:2dccfa0121de 1437 _wr_dat_start();
wim 0:a8090b59eb05 1438 for (j = 0; j < CHAR_H; j++) {
wim 1:ea0f7b1c5daf 1439 //wh for (i = CHAR_W-1; i >= 0; i--) {
wim 1:ea0f7b1c5daf 1440 for (i = 0; i < CHAR_W; i++) {
wim 0:a8090b59eb05 1441 if((c[idx] & (1 << i)) == 0x00) {
wim 3:2dccfa0121de 1442 _wr_dat_only(_backColor);
wim 0:a8090b59eb05 1443 } else {
wim 3:2dccfa0121de 1444 _wr_dat_only(_textColor);
wim 0:a8090b59eb05 1445 }
wim 0:a8090b59eb05 1446 }
wim 0:a8090b59eb05 1447 c++;
wim 0:a8090b59eb05 1448 }
wim 3:2dccfa0121de 1449 _wr_dat_stop();
wim 0:a8090b59eb05 1450 }
wim 0:a8090b59eb05 1451
wim 0:a8090b59eb05 1452
wim 0:a8090b59eb05 1453 /*******************************************************************************
wim 0:a8090b59eb05 1454 * Display character on given line *
wim 0:a8090b59eb05 1455 * Parameter: ln: line number *
wim 0:a8090b59eb05 1456 * col: column number *
wim 0:a8090b59eb05 1457 * c: ascii character *
wim 0:a8090b59eb05 1458 * Return: *
wim 0:a8090b59eb05 1459 *******************************************************************************/
wim 0:a8090b59eb05 1460
wim 3:2dccfa0121de 1461 void GLCD::DisplayChar (uint16_t ln, uint16_t col, uint8_t c) {
wim 0:a8090b59eb05 1462
wim 4:cdeea87f25d8 1463 c -= 32; // 32 is ASCII Space
wim 1:ea0f7b1c5daf 1464 // x = column, y = line
wim 3:2dccfa0121de 1465 DrawChar(col * CHAR_W, ln * CHAR_H, (uint16_t *)&Font_24x16[c * CHAR_H]);
wim 1:ea0f7b1c5daf 1466
wim 0:a8090b59eb05 1467 }
wim 0:a8090b59eb05 1468
wim 0:a8090b59eb05 1469
wim 0:a8090b59eb05 1470 /*******************************************************************************
wim 0:a8090b59eb05 1471 * Disply string on given line *
wim 0:a8090b59eb05 1472 * Parameter: ln: line number *
wim 0:a8090b59eb05 1473 * col: column number *
wim 0:a8090b59eb05 1474 * s: pointer to string *
wim 0:a8090b59eb05 1475 * Return: *
wim 0:a8090b59eb05 1476 *******************************************************************************/
wim 0:a8090b59eb05 1477
wim 3:2dccfa0121de 1478 void GLCD::DisplayString (uint16_t ln, uint16_t col, uint8_t *s) {
wim 0:a8090b59eb05 1479
wim 3:2dccfa0121de 1480 setWindowMax();
wim 0:a8090b59eb05 1481 while (*s) {
wim 2:43ede88fb5a3 1482 DisplayChar(ln, col++, *s++);
wim 0:a8090b59eb05 1483 }
wim 0:a8090b59eb05 1484 }
wim 0:a8090b59eb05 1485
wim 0:a8090b59eb05 1486
wim 0:a8090b59eb05 1487 /*******************************************************************************
wim 0:a8090b59eb05 1488 * Clear given line *
wim 0:a8090b59eb05 1489 * Parameter: ln: line number *
wim 0:a8090b59eb05 1490 * Return: *
wim 0:a8090b59eb05 1491 *******************************************************************************/
wim 0:a8090b59eb05 1492
wim 3:2dccfa0121de 1493 void GLCD::ClearLn (uint16_t ln) {
wim 0:a8090b59eb05 1494
wim 3:2dccfa0121de 1495 setWindowMax();
wim 3:2dccfa0121de 1496 DisplayString(ln, 0, (uint8_t*) " ");
wim 0:a8090b59eb05 1497 }
wim 0:a8090b59eb05 1498
wim 0:a8090b59eb05 1499 //SSD1289
wim 0:a8090b59eb05 1500 //static void lcd_SetCursor(unsigned int x,unsigned int y)
wim 0:a8090b59eb05 1501 //{
wim 0:a8090b59eb05 1502 // write_reg(0x004e,x); /* 0-239 */
wim 0:a8090b59eb05 1503 // write_reg(0x004f,y); /* 0-319 */
wim 0:a8090b59eb05 1504 //}
wim 0:a8090b59eb05 1505
wim 0:a8090b59eb05 1506
wim 3:2dccfa0121de 1507
wim 4:cdeea87f25d8 1508 /** @brief Write single character to the display using the fontable
wim 3:2dccfa0121de 1509 * @brief Start at current cursor location
wim 4:cdeea87f25d8 1510 * @param int value character to write
wim 3:2dccfa0121de 1511 */
wim 4:cdeea87f25d8 1512 int GLCD::_putc(int value){
wim 3:2dccfa0121de 1513
wim 4:cdeea87f25d8 1514 if (value == '\n') {
wim 4:cdeea87f25d8 1515 //No Character to write
wim 4:cdeea87f25d8 1516
wim 4:cdeea87f25d8 1517 //Update Cursor
wim 4:cdeea87f25d8 1518 _col = 0;
wim 4:cdeea87f25d8 1519 _ln++;
wim 4:cdeea87f25d8 1520 if (_ln >= ROWS) {
wim 4:cdeea87f25d8 1521 _ln = 0;
wim 4:cdeea87f25d8 1522 }
wim 4:cdeea87f25d8 1523 }
wim 4:cdeea87f25d8 1524 else {
wim 4:cdeea87f25d8 1525 // Character to write
wim 4:cdeea87f25d8 1526 value -= 32; // 32 is ASCII Space
wim 4:cdeea87f25d8 1527 // x = column, y = line
wim 4:cdeea87f25d8 1528 DrawChar(_col * CHAR_W, _ln * CHAR_H, (uint16_t *)&Font_24x16[value * CHAR_H]);
wim 3:2dccfa0121de 1529
wim 4:cdeea87f25d8 1530 //Update Cursor
wim 4:cdeea87f25d8 1531 _col++;
wim 4:cdeea87f25d8 1532 if (_col >= COLS) {
wim 4:cdeea87f25d8 1533 _col = 0;
wim 4:cdeea87f25d8 1534 _ln++;
wim 4:cdeea87f25d8 1535 if (_ln >= ROWS) {
wim 4:cdeea87f25d8 1536 _ln = 0;
wim 4:cdeea87f25d8 1537 }
wim 4:cdeea87f25d8 1538 }
wim 4:cdeea87f25d8 1539 } //if char to write
wim 4:cdeea87f25d8 1540
wim 4:cdeea87f25d8 1541 return value;
wim 3:2dccfa0121de 1542 }
wim 3:2dccfa0121de 1543
wim 4:cdeea87f25d8 1544
wim 4:cdeea87f25d8 1545 int GLCD::_getc() {
wim 4:cdeea87f25d8 1546 return -1;
wim 4:cdeea87f25d8 1547 }
wim 4:cdeea87f25d8 1548
wim 4:cdeea87f25d8 1549
wim 2:43ede88fb5a3 1550 void GLCD::drawHLine(int x, int y, int l)
wim 0:a8090b59eb05 1551 {
wim 0:a8090b59eb05 1552 // char ch, cl;
wim 0:a8090b59eb05 1553
wim 0:a8090b59eb05 1554 // ch=((fcolorr&248)|fcolorg>>5);
wim 0:a8090b59eb05 1555 // cl=((fcolorg&28)<<3|fcolorb>>3);
wim 0:a8090b59eb05 1556
wim 0:a8090b59eb05 1557 // cbi(P_CS, B_CS);
wim 0:a8090b59eb05 1558
wim 3:2dccfa0121de 1559 setWindow (x, y, x+l, y);
wim 0:a8090b59eb05 1560
wim 0:a8090b59eb05 1561 // for (int i=0; i<l+1; i++)
wim 0:a8090b59eb05 1562 // {
wim 0:a8090b59eb05 1563 // LCD_Write_DATA(ch, cl);
wim 0:a8090b59eb05 1564 // }
wim 0:a8090b59eb05 1565
wim 0:a8090b59eb05 1566 LCD_CS(0)
wim 3:2dccfa0121de 1567 _wr_cmd(0x22);
wim 0:a8090b59eb05 1568
wim 3:2dccfa0121de 1569 _wr_dat_start();
wim 0:a8090b59eb05 1570 for (int i=0; i<l; i++)
wim 3:2dccfa0121de 1571 _wr_dat_only(_textColor);
wim 3:2dccfa0121de 1572 _wr_dat_stop();
wim 0:a8090b59eb05 1573
wim 0:a8090b59eb05 1574 // sbi(P_CS, B_CS);
wim 0:a8090b59eb05 1575 // clrXY();
wim 3:2dccfa0121de 1576 setWindowMax();
wim 0:a8090b59eb05 1577 }
wim 0:a8090b59eb05 1578
wim 2:43ede88fb5a3 1579 void GLCD::drawVLine(int x, int y, int l)
wim 0:a8090b59eb05 1580 {
wim 0:a8090b59eb05 1581 // char ch, cl;
wim 0:a8090b59eb05 1582
wim 0:a8090b59eb05 1583 // ch=((fcolorr&248)|fcolorg>>5);
wim 0:a8090b59eb05 1584 // cl=((fcolorg&28)<<3|fcolorb>>3);
wim 0:a8090b59eb05 1585
wim 0:a8090b59eb05 1586 // cbi(P_CS, B_CS);
wim 3:2dccfa0121de 1587 setWindow(x, y, x, y+l);
wim 0:a8090b59eb05 1588 // for (int i=0; i<l; i++)
wim 0:a8090b59eb05 1589 // {
wim 3:2dccfa0121de 1590 // GLCD::_wr_dat(ch, cl);
wim 0:a8090b59eb05 1591 // }
wim 0:a8090b59eb05 1592 LCD_CS(0)
wim 3:2dccfa0121de 1593 _wr_cmd(0x22);
wim 0:a8090b59eb05 1594
wim 3:2dccfa0121de 1595 _wr_dat_start();
wim 0:a8090b59eb05 1596 for (int i=0; i<l; i++)
wim 3:2dccfa0121de 1597 _wr_dat_only(_textColor);
wim 3:2dccfa0121de 1598 _wr_dat_stop();
wim 0:a8090b59eb05 1599
wim 0:a8090b59eb05 1600
wim 0:a8090b59eb05 1601 // sbi(P_CS, B_CS);
wim 0:a8090b59eb05 1602 // clrXY();
wim 3:2dccfa0121de 1603 setWindowMax();
wim 0:a8090b59eb05 1604 }
wim 0:a8090b59eb05 1605
wim 0:a8090b59eb05 1606
wim 2:43ede88fb5a3 1607 void GLCD::drawRect(int x1, int y1, int x2, int y2)
wim 0:a8090b59eb05 1608 {
wim 2:43ede88fb5a3 1609 //int tmp;
wim 0:a8090b59eb05 1610
wim 0:a8090b59eb05 1611 if (x1>x2)
wim 0:a8090b59eb05 1612 {
wim 0:a8090b59eb05 1613 swap(int, x1, x2);
wim 0:a8090b59eb05 1614 }
wim 0:a8090b59eb05 1615 if (y1>y2)
wim 0:a8090b59eb05 1616 {
wim 0:a8090b59eb05 1617 swap(int, y1, y2);
wim 0:a8090b59eb05 1618 }
wim 0:a8090b59eb05 1619
wim 2:43ede88fb5a3 1620 drawHLine(x1, y1, x2-x1);
wim 2:43ede88fb5a3 1621 drawHLine(x1, y2, x2-x1);
wim 2:43ede88fb5a3 1622 drawVLine(x1, y1, y2-y1);
wim 2:43ede88fb5a3 1623 drawVLine(x2, y1, y2-y1);
wim 2:43ede88fb5a3 1624 }
wim 2:43ede88fb5a3 1625
wim 2:43ede88fb5a3 1626
wim 2:43ede88fb5a3 1627 /// Replace by faster Bresenham int
wim 2:43ede88fb5a3 1628 void GLCD::drawLine(int x1, int y1, int x2, int y2)
wim 2:43ede88fb5a3 1629 {
wim 2:43ede88fb5a3 1630 // int tmp;
wim 2:43ede88fb5a3 1631 double delta, tx, ty;
wim 2:43ede88fb5a3 1632 // double m, b, dx, dy;
wim 2:43ede88fb5a3 1633 // char ch, cl;
wim 2:43ede88fb5a3 1634
wim 2:43ede88fb5a3 1635 if (((x2-x1)<0))
wim 2:43ede88fb5a3 1636 {
wim 2:43ede88fb5a3 1637 swap(int, x1, x2);
wim 2:43ede88fb5a3 1638 swap(int, y1, y2);
wim 2:43ede88fb5a3 1639 }
wim 2:43ede88fb5a3 1640 if (((y2-y1)<0))
wim 2:43ede88fb5a3 1641 {
wim 2:43ede88fb5a3 1642 swap(int, x1, x2);
wim 2:43ede88fb5a3 1643 swap(int, y1, y2);
wim 2:43ede88fb5a3 1644 }
wim 2:43ede88fb5a3 1645
wim 2:43ede88fb5a3 1646 if (y1==y2)
wim 2:43ede88fb5a3 1647 {
wim 2:43ede88fb5a3 1648 if (x1>x2)
wim 2:43ede88fb5a3 1649 {
wim 2:43ede88fb5a3 1650 swap(int, x1, x2);
wim 2:43ede88fb5a3 1651 }
wim 2:43ede88fb5a3 1652 drawHLine(x1, y1, x2-x1);
wim 2:43ede88fb5a3 1653 }
wim 2:43ede88fb5a3 1654 else if (x1==x2)
wim 2:43ede88fb5a3 1655 {
wim 2:43ede88fb5a3 1656 if (y1>y2)
wim 2:43ede88fb5a3 1657 {
wim 2:43ede88fb5a3 1658 swap(int, y1, y2);
wim 2:43ede88fb5a3 1659 }
wim 2:43ede88fb5a3 1660 drawVLine(x1, y1, y2-y1);
wim 2:43ede88fb5a3 1661 }
wim 2:43ede88fb5a3 1662 else if (abs(x2-x1)>abs(y2-y1))
wim 2:43ede88fb5a3 1663 {
wim 2:43ede88fb5a3 1664 delta=(double(y2-y1)/double(x2-x1));
wim 2:43ede88fb5a3 1665 ty=double(y1);
wim 2:43ede88fb5a3 1666 if (x1>x2)
wim 2:43ede88fb5a3 1667 {
wim 2:43ede88fb5a3 1668 for (int i=x1; i>=x2; i--)
wim 2:43ede88fb5a3 1669 {
wim 2:43ede88fb5a3 1670 drawPixel(i, int(ty+0.5));
wim 2:43ede88fb5a3 1671 ty=ty-delta;
wim 2:43ede88fb5a3 1672 }
wim 2:43ede88fb5a3 1673 }
wim 2:43ede88fb5a3 1674 else
wim 2:43ede88fb5a3 1675 {
wim 2:43ede88fb5a3 1676 for (int i=x1; i<=x2; i++)
wim 2:43ede88fb5a3 1677 {
wim 2:43ede88fb5a3 1678 drawPixel(i, int(ty+0.5));
wim 2:43ede88fb5a3 1679 ty=ty+delta;
wim 2:43ede88fb5a3 1680 }
wim 2:43ede88fb5a3 1681 }
wim 2:43ede88fb5a3 1682
wim 2:43ede88fb5a3 1683 }
wim 2:43ede88fb5a3 1684 else
wim 2:43ede88fb5a3 1685 {
wim 2:43ede88fb5a3 1686 delta=(float(x2-x1)/float(y2-y1));
wim 2:43ede88fb5a3 1687 tx=float(x1);
wim 2:43ede88fb5a3 1688 if (y1>y2)
wim 2:43ede88fb5a3 1689 {
wim 2:43ede88fb5a3 1690 for (int i=y2+1; i>y1; i--)
wim 2:43ede88fb5a3 1691 {
wim 2:43ede88fb5a3 1692 drawPixel(int(tx+0.5), i);
wim 2:43ede88fb5a3 1693 tx=tx+delta;
wim 2:43ede88fb5a3 1694 }
wim 2:43ede88fb5a3 1695 }
wim 2:43ede88fb5a3 1696 else
wim 2:43ede88fb5a3 1697 {
wim 2:43ede88fb5a3 1698 for (int i=y1; i<y2+1; i++)
wim 2:43ede88fb5a3 1699 {
wim 2:43ede88fb5a3 1700 drawPixel(int(tx+0.5), i);
wim 2:43ede88fb5a3 1701 tx=tx+delta;
wim 2:43ede88fb5a3 1702 }
wim 2:43ede88fb5a3 1703 }
wim 2:43ede88fb5a3 1704 }
wim 2:43ede88fb5a3 1705
wim 3:2dccfa0121de 1706 setWindowMax();
wim 2:43ede88fb5a3 1707 }
wim 2:43ede88fb5a3 1708
wim 2:43ede88fb5a3 1709 void GLCD::drawRoundRect(int x1, int y1, int x2, int y2)
wim 2:43ede88fb5a3 1710 {
wim 2:43ede88fb5a3 1711 // int tmp;
wim 2:43ede88fb5a3 1712
wim 2:43ede88fb5a3 1713 if (x1>x2)
wim 2:43ede88fb5a3 1714 {
wim 2:43ede88fb5a3 1715 swap(int, x1, x2);
wim 2:43ede88fb5a3 1716 }
wim 2:43ede88fb5a3 1717 if (y1>y2)
wim 2:43ede88fb5a3 1718 {
wim 2:43ede88fb5a3 1719 swap(int, y1, y2);
wim 2:43ede88fb5a3 1720 }
wim 2:43ede88fb5a3 1721 if ((x2-x1)>4 && (y2-y1)>4)
wim 2:43ede88fb5a3 1722 {
wim 2:43ede88fb5a3 1723 drawPixel(x1+1,y1+1);
wim 2:43ede88fb5a3 1724 drawPixel(x2-1,y1+1);
wim 2:43ede88fb5a3 1725 drawPixel(x1+1,y2-1);
wim 2:43ede88fb5a3 1726 drawPixel(x2-1,y2-1);
wim 2:43ede88fb5a3 1727 drawHLine(x1+2, y1, x2-x1-4);
wim 2:43ede88fb5a3 1728 drawHLine(x1+2, y2, x2-x1-4);
wim 2:43ede88fb5a3 1729 drawVLine(x1, y1+2, y2-y1-4);
wim 2:43ede88fb5a3 1730 drawVLine(x2, y1+2, y2-y1-4);
wim 2:43ede88fb5a3 1731 }
wim 0:a8090b59eb05 1732 }
wim 0:a8090b59eb05 1733
wim 2:43ede88fb5a3 1734 void GLCD::fillRect(int x1, int y1, int x2, int y2)
wim 2:43ede88fb5a3 1735 {
wim 2:43ede88fb5a3 1736 // int tmp;
wim 2:43ede88fb5a3 1737
wim 2:43ede88fb5a3 1738 if (x1>x2)
wim 2:43ede88fb5a3 1739 {
wim 2:43ede88fb5a3 1740 swap(int, x1, x2);
wim 2:43ede88fb5a3 1741 }
wim 2:43ede88fb5a3 1742 if (y1>y2)
wim 2:43ede88fb5a3 1743 {
wim 2:43ede88fb5a3 1744 swap(int, y1, y2);
wim 2:43ede88fb5a3 1745 }
wim 2:43ede88fb5a3 1746
wim 2:43ede88fb5a3 1747 // if (orient==PORTRAIT)
wim 2:43ede88fb5a3 1748 // {
wim 2:43ede88fb5a3 1749 // for (int i=0; i<((y2-y1)/2)+1; i++)
wim 2:43ede88fb5a3 1750 // {
wim 2:43ede88fb5a3 1751 // drawHLine(x1, y1+i, x2-x1);
wim 2:43ede88fb5a3 1752 // drawHLine(x1, y2-i, x2-x1);
wim 2:43ede88fb5a3 1753 // }
wim 2:43ede88fb5a3 1754 // }
wim 2:43ede88fb5a3 1755 // else
wim 2:43ede88fb5a3 1756 // {
wim 2:43ede88fb5a3 1757 for (int i=0; i<((x2-x1)/2)+1; i++)
wim 2:43ede88fb5a3 1758 {
wim 2:43ede88fb5a3 1759 drawVLine(x1+i, y1, y2-y1);
wim 2:43ede88fb5a3 1760 drawVLine(x2-i, y1, y2-y1);
wim 2:43ede88fb5a3 1761 }
wim 2:43ede88fb5a3 1762 // }
wim 2:43ede88fb5a3 1763 }
wim 2:43ede88fb5a3 1764
wim 2:43ede88fb5a3 1765 void GLCD::fillRoundRect(int x1, int y1, int x2, int y2)
wim 2:43ede88fb5a3 1766 {
wim 2:43ede88fb5a3 1767 // int tmp;
wim 2:43ede88fb5a3 1768
wim 2:43ede88fb5a3 1769 if (x1>x2)
wim 2:43ede88fb5a3 1770 {
wim 2:43ede88fb5a3 1771 swap(int, x1, x2);
wim 2:43ede88fb5a3 1772 }
wim 2:43ede88fb5a3 1773 if (y1>y2)
wim 2:43ede88fb5a3 1774 {
wim 2:43ede88fb5a3 1775 swap(int, y1, y2);
wim 2:43ede88fb5a3 1776 }
wim 2:43ede88fb5a3 1777
wim 2:43ede88fb5a3 1778 if ((x2-x1)>4 && (y2-y1)>4)
wim 2:43ede88fb5a3 1779 {
wim 2:43ede88fb5a3 1780 for (int i=0; i<((y2-y1)/2)+1; i++)
wim 2:43ede88fb5a3 1781 {
wim 2:43ede88fb5a3 1782 switch(i)
wim 2:43ede88fb5a3 1783 {
wim 2:43ede88fb5a3 1784 case 0:
wim 2:43ede88fb5a3 1785 drawHLine(x1+2, y1+i, x2-x1-4);
wim 2:43ede88fb5a3 1786 drawHLine(x1+2, y2-i, x2-x1-4);
wim 2:43ede88fb5a3 1787 break;
wim 2:43ede88fb5a3 1788 case 1:
wim 2:43ede88fb5a3 1789 drawHLine(x1+1, y1+i, x2-x1-2);
wim 2:43ede88fb5a3 1790 drawHLine(x1+1, y2-i, x2-x1-2);
wim 2:43ede88fb5a3 1791 break;
wim 2:43ede88fb5a3 1792 default:
wim 2:43ede88fb5a3 1793 drawHLine(x1, y1+i, x2-x1);
wim 2:43ede88fb5a3 1794 drawHLine(x1, y2-i, x2-x1);
wim 2:43ede88fb5a3 1795 }
wim 2:43ede88fb5a3 1796 }
wim 2:43ede88fb5a3 1797 }
wim 2:43ede88fb5a3 1798 }
wim 2:43ede88fb5a3 1799
wim 2:43ede88fb5a3 1800 void GLCD::drawCircle(int x, int y, int radius)
wim 2:43ede88fb5a3 1801 {
wim 2:43ede88fb5a3 1802 int f = 1 - radius;
wim 2:43ede88fb5a3 1803 int ddF_x = 1;
wim 2:43ede88fb5a3 1804 int ddF_y = -2 * radius;
wim 2:43ede88fb5a3 1805 int x1 = 0;
wim 2:43ede88fb5a3 1806 int y1 = radius;
wim 2:43ede88fb5a3 1807 // char ch, cl;
wim 2:43ede88fb5a3 1808
wim 2:43ede88fb5a3 1809 // ch=((fcolorr&248)|fcolorg>>5);
wim 2:43ede88fb5a3 1810 // cl=((fcolorg&28)<<3|fcolorb>>3);
wim 2:43ede88fb5a3 1811
wim 2:43ede88fb5a3 1812 // cbi(P_CS, B_CS);
wim 2:43ede88fb5a3 1813 drawPixel(x, y + radius);
wim 2:43ede88fb5a3 1814
wim 2:43ede88fb5a3 1815 drawPixel(x, y - radius);
wim 2:43ede88fb5a3 1816
wim 2:43ede88fb5a3 1817 drawPixel(x + radius, y);
wim 2:43ede88fb5a3 1818
wim 2:43ede88fb5a3 1819 drawPixel(x - radius, y);
wim 2:43ede88fb5a3 1820
wim 2:43ede88fb5a3 1821
wim 2:43ede88fb5a3 1822 while(x1 < y1)
wim 2:43ede88fb5a3 1823 {
wim 2:43ede88fb5a3 1824 if(f >= 0)
wim 2:43ede88fb5a3 1825 {
wim 2:43ede88fb5a3 1826 y1--;
wim 2:43ede88fb5a3 1827 ddF_y += 2;
wim 2:43ede88fb5a3 1828 f += ddF_y;
wim 2:43ede88fb5a3 1829 }
wim 2:43ede88fb5a3 1830 x1++;
wim 2:43ede88fb5a3 1831 ddF_x += 2;
wim 2:43ede88fb5a3 1832 f += ddF_x;
wim 2:43ede88fb5a3 1833 drawPixel(x + x1, y + y1);
wim 2:43ede88fb5a3 1834
wim 2:43ede88fb5a3 1835 drawPixel(x - x1, y + y1);
wim 2:43ede88fb5a3 1836
wim 2:43ede88fb5a3 1837 drawPixel(x + x1, y - y1);
wim 2:43ede88fb5a3 1838
wim 2:43ede88fb5a3 1839 drawPixel(x - x1, y - y1);
wim 2:43ede88fb5a3 1840
wim 2:43ede88fb5a3 1841 drawPixel(x + y1, y + x1);
wim 2:43ede88fb5a3 1842
wim 2:43ede88fb5a3 1843 drawPixel(x - y1, y + x1);
wim 2:43ede88fb5a3 1844
wim 2:43ede88fb5a3 1845 drawPixel(x + y1, y - x1);
wim 2:43ede88fb5a3 1846
wim 2:43ede88fb5a3 1847 drawPixel(x - y1, y - x1);
wim 2:43ede88fb5a3 1848
wim 2:43ede88fb5a3 1849 }
wim 2:43ede88fb5a3 1850 // sbi(P_CS, B_CS);
wim 2:43ede88fb5a3 1851 // clrXY();
wim 2:43ede88fb5a3 1852 }
wim 2:43ede88fb5a3 1853
wim 2:43ede88fb5a3 1854 void GLCD::fillCircle(int x, int y, int radius)
wim 2:43ede88fb5a3 1855 {
wim 2:43ede88fb5a3 1856 // cbi(P_CS, B_CS);
wim 2:43ede88fb5a3 1857 for(int y1=-radius; y1<=radius; y1++)
wim 2:43ede88fb5a3 1858 for(int x1=-radius; x1<=radius; x1++)
wim 2:43ede88fb5a3 1859 if(x1*x1+y1*y1 <= radius*radius)
wim 2:43ede88fb5a3 1860 {
wim 2:43ede88fb5a3 1861 drawPixel(x+x1, y+y1);
wim 2:43ede88fb5a3 1862 }
wim 2:43ede88fb5a3 1863 // sbi(P_CS, B_CS);
wim 2:43ede88fb5a3 1864 // clrXY();
wim 2:43ede88fb5a3 1865 }
wim 2:43ede88fb5a3 1866
wim 2:43ede88fb5a3 1867
wim 3:2dccfa0121de 1868 //not yet checked
wim 2:43ede88fb5a3 1869 void GLCD::lcdOff()
wim 2:43ede88fb5a3 1870 {
wim 3:2dccfa0121de 1871 _wr_reg(0x0007, 0x0000);
wim 2:43ede88fb5a3 1872 }
wim 2:43ede88fb5a3 1873
wim 2:43ede88fb5a3 1874 void GLCD::lcdOn()
wim 2:43ede88fb5a3 1875 {
wim 3:2dccfa0121de 1876 _wr_reg(0x0007, 0x0173);
wim 2:43ede88fb5a3 1877 }
wim 2:43ede88fb5a3 1878
wim 3:2dccfa0121de 1879 void GLCD::setContrast(uint8_t c)
wim 2:43ede88fb5a3 1880 {
wim 2:43ede88fb5a3 1881 }
wim 2:43ede88fb5a3 1882
wim 2:43ede88fb5a3 1883
wim 0:a8090b59eb05 1884
wim 0:a8090b59eb05 1885
wim 0:a8090b59eb05 1886
wim 0:a8090b59eb05 1887 /*******************************************************************************
wim 0:a8090b59eb05 1888 * Draw bargraph *
wim 0:a8090b59eb05 1889 * Parameter: x: horizontal position *
wim 0:a8090b59eb05 1890 * y: vertical position *
wim 0:a8090b59eb05 1891 * w: maximum width of bargraph (in pixels) *
wim 0:a8090b59eb05 1892 * val: value of active bargraph (in 1/1024) *
wim 0:a8090b59eb05 1893 * Return: *
wim 0:a8090b59eb05 1894 *******************************************************************************/
wim 0:a8090b59eb05 1895
wim 2:43ede88fb5a3 1896 void GLCD::Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) {
wim 0:a8090b59eb05 1897 int i,j;
wim 0:a8090b59eb05 1898
wim 0:a8090b59eb05 1899 x = WIDTH-x-w;
wim 2:43ede88fb5a3 1900 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1901 {
wim 3:2dccfa0121de 1902 _wr_reg(0x44, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1903 _wr_reg(0x44, y |((y+CHAR_H-1)<<8)); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1904 _wr_reg(0x45, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1905 _wr_reg(0x46, x+w-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1906 }
wim 0:a8090b59eb05 1907 else
wim 0:a8090b59eb05 1908 {
wim 3:2dccfa0121de 1909 _wr_reg(0x50, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1910 _wr_reg(0x51, y+CHAR_H-1); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1911 _wr_reg(0x52, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1912 _wr_reg(0x53, x+w-1); /* Vertical GRAM End Address (-1) */
wim 0:a8090b59eb05 1913 }
wim 0:a8090b59eb05 1914
wim 0:a8090b59eb05 1915 val = (val * w) >> 10; /* Scale value for 24x12 characters */
wim 2:43ede88fb5a3 1916 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1917 {
wim 3:2dccfa0121de 1918 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1919 _wr_reg(0x4f, x);
wim 0:a8090b59eb05 1920 }
wim 0:a8090b59eb05 1921 else
wim 0:a8090b59eb05 1922 {
wim 3:2dccfa0121de 1923 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1924 _wr_reg(0x21, x);
wim 0:a8090b59eb05 1925 }
wim 0:a8090b59eb05 1926 LCD_CS(0)
wim 3:2dccfa0121de 1927 _wr_cmd(0x22);
wim 3:2dccfa0121de 1928 _wr_dat_start();
wim 0:a8090b59eb05 1929 for (i = 0; i < h; i++) {
wim 0:a8090b59eb05 1930 for (j = w-1; j >= 0; j--) {
wim 0:a8090b59eb05 1931 if(j >= val) {
wim 3:2dccfa0121de 1932 _wr_dat_only(_backColor);
wim 0:a8090b59eb05 1933 } else {
wim 3:2dccfa0121de 1934 _wr_dat_only(_textColor);
wim 0:a8090b59eb05 1935 }
wim 0:a8090b59eb05 1936 }
wim 0:a8090b59eb05 1937 }
wim 3:2dccfa0121de 1938 _wr_dat_stop();
wim 0:a8090b59eb05 1939 }
wim 0:a8090b59eb05 1940
wim 0:a8090b59eb05 1941
wim 0:a8090b59eb05 1942 /*******************************************************************************
wim 0:a8090b59eb05 1943 * Display graphical bitmap image at position x horizontally and y vertically *
wim 0:a8090b59eb05 1944 * (This function is optimized for 16 bits per pixel format, it has to be *
wim 0:a8090b59eb05 1945 * adapted for any other bits per pixel format) *
wim 0:a8090b59eb05 1946 * Parameter: x: horizontal position *
wim 0:a8090b59eb05 1947 * y: vertical position *
wim 0:a8090b59eb05 1948 * w: width of bitmap *
wim 0:a8090b59eb05 1949 * h: height of bitmap *
wim 0:a8090b59eb05 1950 * bitmap: address at which the bitmap data resides *
wim 0:a8090b59eb05 1951 * Return: *
wim 0:a8090b59eb05 1952 *******************************************************************************/
wim 0:a8090b59eb05 1953
wim 3:2dccfa0121de 1954 void GLCD::Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bitmap) {
wim 0:a8090b59eb05 1955 unsigned int i, j;
wim 3:2dccfa0121de 1956 uint16_t *bitmap_ptr = (uint16_t *)bitmap;
wim 0:a8090b59eb05 1957
wim 0:a8090b59eb05 1958 x = WIDTH-x-w;
wim 2:43ede88fb5a3 1959 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 1960 {
wim 3:2dccfa0121de 1961 _wr_reg(0x44, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1962 _wr_reg(0x44, y |((y+h-1)<<8)); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1963 _wr_reg(0x45, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1964 _wr_reg(0x46, x+w-1); /* Vertical GRAM End Address (-1) */
wim 3:2dccfa0121de 1965 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 1966 _wr_reg(0x4f, x);
wim 0:a8090b59eb05 1967 }
wim 0:a8090b59eb05 1968 else
wim 0:a8090b59eb05 1969 {
wim 3:2dccfa0121de 1970 _wr_reg(0x50, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 1971 _wr_reg(0x51, y+h-1); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 1972 _wr_reg(0x52, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 1973 _wr_reg(0x53, x+w-1); /* Vertical GRAM End Address (-1) */
wim 3:2dccfa0121de 1974 _wr_reg(0x20, y);
wim 3:2dccfa0121de 1975 _wr_reg(0x21, x);
wim 0:a8090b59eb05 1976 }
wim 0:a8090b59eb05 1977 LCD_CS(0)
wim 3:2dccfa0121de 1978 _wr_cmd(0x22);
wim 3:2dccfa0121de 1979 _wr_dat_start();
wim 0:a8090b59eb05 1980 for (j = 0; j < h; j++) {
wim 0:a8090b59eb05 1981 bitmap_ptr += w-1;
wim 0:a8090b59eb05 1982 for (i = 0; i < w; i++) {
wim 3:2dccfa0121de 1983 _wr_dat_only(*bitmap_ptr--);
wim 0:a8090b59eb05 1984 }
wim 0:a8090b59eb05 1985 bitmap_ptr += w+1;
wim 0:a8090b59eb05 1986 }
wim 3:2dccfa0121de 1987 _wr_dat_stop();
wim 0:a8090b59eb05 1988 }
wim 0:a8090b59eb05 1989
wim 0:a8090b59eb05 1990
wim 0:a8090b59eb05 1991 /*******************************************************************************
wim 0:a8090b59eb05 1992 * Display graphical bmp file image at position x horizontally and y vertically *
wim 0:a8090b59eb05 1993 * (This function is optimized for 16 bits per pixel format, it has to be *
wim 0:a8090b59eb05 1994 * adapted for any other bits per pixel format) *
wim 0:a8090b59eb05 1995 * Parameter: x: horizontal position *
wim 0:a8090b59eb05 1996 * y: vertical position *
wim 0:a8090b59eb05 1997 * w: width of bitmap *
wim 0:a8090b59eb05 1998 * h: height of bitmap *
wim 0:a8090b59eb05 1999 * bmp: address at which the bmp data resides *
wim 0:a8090b59eb05 2000 * Return: *
wim 0:a8090b59eb05 2001 *******************************************************************************/
wim 0:a8090b59eb05 2002
wim 3:2dccfa0121de 2003 void GLCD::Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bmp) {
wim 0:a8090b59eb05 2004 unsigned int i, j;
wim 3:2dccfa0121de 2005 uint16_t *bitmap_ptr = (uint16_t *)bmp;
wim 0:a8090b59eb05 2006
wim 1:ea0f7b1c5daf 2007 //wh x = WIDTH-x-w;
wim 0:a8090b59eb05 2008
wim 2:43ede88fb5a3 2009 if(_driverCode==SSD1289_ID)
wim 0:a8090b59eb05 2010 {
wim 3:2dccfa0121de 2011 //wh _wr_reg(0x44, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 2012 _wr_reg(0x44, y |((y+h-1)<<8)); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 2013 _wr_reg(0x45, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 2014 _wr_reg(0x46, x+w-1); /* Vertical GRAM End Address (-1) */
wim 3:2dccfa0121de 2015 _wr_reg(0x4e, y);
wim 3:2dccfa0121de 2016 _wr_reg(0x4f, x);
wim 0:a8090b59eb05 2017 }
wim 0:a8090b59eb05 2018 else
wim 0:a8090b59eb05 2019 {
wim 3:2dccfa0121de 2020 _wr_reg(0x50, y); /* Horizontal GRAM Start Address */
wim 3:2dccfa0121de 2021 _wr_reg(0x51, y+h-1); /* Horizontal GRAM End Address (-1) */
wim 3:2dccfa0121de 2022 _wr_reg(0x52, x); /* Vertical GRAM Start Address */
wim 3:2dccfa0121de 2023 _wr_reg(0x53, x+w-1); /* Vertical GRAM End Address (-1) */
wim 3:2dccfa0121de 2024 _wr_reg(0x20, y);
wim 3:2dccfa0121de 2025 _wr_reg(0x21, x);
wim 0:a8090b59eb05 2026 }
wim 0:a8090b59eb05 2027 LCD_CS(0)
wim 3:2dccfa0121de 2028 _wr_cmd(0x22);
wim 3:2dccfa0121de 2029 _wr_dat_start();
wim 1:ea0f7b1c5daf 2030 // bitmap_ptr += (h*w)-1;
wim 1:ea0f7b1c5daf 2031 // for (j = 0; j < h; j++) {
wim 1:ea0f7b1c5daf 2032 // for (i = 0; i < w; i++) {
wim 3:2dccfa0121de 2033 // _wr_dat_only(*bitmap_ptr--);
wim 1:ea0f7b1c5daf 2034 // }
wim 1:ea0f7b1c5daf 2035 // }
wim 1:ea0f7b1c5daf 2036
wim 1:ea0f7b1c5daf 2037
wim 0:a8090b59eb05 2038 for (j = 0; j < h; j++) {
wim 0:a8090b59eb05 2039 for (i = 0; i < w; i++) {
wim 3:2dccfa0121de 2040 _wr_dat_only(*bitmap_ptr++);
wim 0:a8090b59eb05 2041 }
wim 0:a8090b59eb05 2042 }
wim 1:ea0f7b1c5daf 2043
wim 1:ea0f7b1c5daf 2044
wim 3:2dccfa0121de 2045 _wr_dat_stop();
wim 3:2dccfa0121de 2046 }
wim 3:2dccfa0121de 2047
wim 3:2dccfa0121de 2048
wim 3:2dccfa0121de 2049
wim 3:2dccfa0121de 2050
wim 3:2dccfa0121de 2051
wim 3:2dccfa0121de 2052 #if(0)
wim 3:2dccfa0121de 2053
wim 3:2dccfa0121de 2054 void LCD_PolyLine(pPoint Points, uint16_t PointCount)
wim 3:2dccfa0121de 2055 {
wim 3:2dccfa0121de 2056 int16_t X = 0, Y = 0;
wim 3:2dccfa0121de 2057
wim 3:2dccfa0121de 2058 if(PointCount < 2)
wim 3:2dccfa0121de 2059 {
wim 3:2dccfa0121de 2060 return;
wim 3:2dccfa0121de 2061 }
wim 3:2dccfa0121de 2062
wim 3:2dccfa0121de 2063 while(--PointCount)
wim 3:2dccfa0121de 2064 {
wim 3:2dccfa0121de 2065 X = Points->X;
wim 3:2dccfa0121de 2066 Y = Points->Y;
wim 3:2dccfa0121de 2067 Points++;
wim 3:2dccfa0121de 2068 LCD_DrawUniLine(X, Y, Points->X, Points->Y);
wim 3:2dccfa0121de 2069 }
wim 3:2dccfa0121de 2070 }
wim 3:2dccfa0121de 2071
wim 3:2dccfa0121de 2072 static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed)
wim 3:2dccfa0121de 2073 {
wim 3:2dccfa0121de 2074 int16_t X = 0, Y = 0;
wim 3:2dccfa0121de 2075 pPoint First = Points;
wim 3:2dccfa0121de 2076
wim 3:2dccfa0121de 2077 if(PointCount < 2)
wim 3:2dccfa0121de 2078 {
wim 3:2dccfa0121de 2079 return;
wim 3:2dccfa0121de 2080 }
wim 3:2dccfa0121de 2081 X = Points->X;
wim 3:2dccfa0121de 2082 Y = Points->Y;
wim 3:2dccfa0121de 2083 while(--PointCount)
wim 3:2dccfa0121de 2084 {
wim 3:2dccfa0121de 2085 Points++;
wim 3:2dccfa0121de 2086 LCD_DrawUniLine(X, Y, X + Points->X, Y + Points->Y);
wim 3:2dccfa0121de 2087 X = X + Points->X;
wim 3:2dccfa0121de 2088 Y = Y + Points->Y;
wim 3:2dccfa0121de 2089 }
wim 3:2dccfa0121de 2090 if(Closed)
wim 3:2dccfa0121de 2091 {
wim 3:2dccfa0121de 2092 LCD_DrawUniLine(First->X, First->Y, X, Y);
wim 3:2dccfa0121de 2093 }
wim 3:2dccfa0121de 2094 }
wim 3:2dccfa0121de 2095
wim 3:2dccfa0121de 2096 void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount)
wim 3:2dccfa0121de 2097 {
wim 3:2dccfa0121de 2098 LCD_PolyLine(Points, PointCount);
wim 3:2dccfa0121de 2099 LCD_DrawUniLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
wim 3:2dccfa0121de 2100 }
wim 3:2dccfa0121de 2101
wim 3:2dccfa0121de 2102
wim 3:2dccfa0121de 2103 void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount)
wim 3:2dccfa0121de 2104 {
wim 3:2dccfa0121de 2105 LCD_PolyLineRelativeClosed(Points, PointCount, 0);
wim 3:2dccfa0121de 2106 }
wim 3:2dccfa0121de 2107
wim 3:2dccfa0121de 2108
wim 3:2dccfa0121de 2109 void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount)
wim 3:2dccfa0121de 2110 {
wim 3:2dccfa0121de 2111 LCD_PolyLineRelativeClosed(Points, PointCount, 1);
wim 0:a8090b59eb05 2112 }
wim 0:a8090b59eb05 2113
wim 3:2dccfa0121de 2114 void LCD_FillPolyLine(pPoint Points, uint16_t PointCount)
wim 3:2dccfa0121de 2115 {
wim 3:2dccfa0121de 2116 /* public-domain code by Darel Rex Finley, 2007 */
wim 3:2dccfa0121de 2117 uint16_t nodes = 0, nodeX[MAX_POLY_CORNERS], pixelX = 0, pixelY = 0, i = 0,
wim 3:2dccfa0121de 2118 j = 0, swap = 0;
wim 3:2dccfa0121de 2119 uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0;
wim 3:2dccfa0121de 2120
wim 3:2dccfa0121de 2121 IMAGE_LEFT = IMAGE_RIGHT = Points->X;
wim 3:2dccfa0121de 2122 IMAGE_TOP= IMAGE_BOTTOM = Points->Y;
wim 3:2dccfa0121de 2123
wim 3:2dccfa0121de 2124 for(i = 1; i < PointCount; i++)
wim 3:2dccfa0121de 2125 {
wim 3:2dccfa0121de 2126 pixelX = POLY_X(i);
wim 3:2dccfa0121de 2127 if(pixelX < IMAGE_LEFT)
wim 3:2dccfa0121de 2128 {
wim 3:2dccfa0121de 2129 IMAGE_LEFT = pixelX;
wim 3:2dccfa0121de 2130 }
wim 3:2dccfa0121de 2131 if(pixelX > IMAGE_RIGHT)
wim 3:2dccfa0121de 2132 {
wim 3:2dccfa0121de 2133 IMAGE_RIGHT = pixelX;
wim 3:2dccfa0121de 2134 }
wim 3:2dccfa0121de 2135
wim 3:2dccfa0121de 2136 pixelY = POLY_Y(i);
wim 3:2dccfa0121de 2137 if(pixelY < IMAGE_TOP)
wim 3:2dccfa0121de 2138 {
wim 3:2dccfa0121de 2139 IMAGE_TOP = pixelY;
wim 3:2dccfa0121de 2140 }
wim 3:2dccfa0121de 2141 if(pixelY > IMAGE_BOTTOM)
wim 3:2dccfa0121de 2142 {
wim 3:2dccfa0121de 2143 IMAGE_BOTTOM = pixelY;
wim 3:2dccfa0121de 2144 }
wim 3:2dccfa0121de 2145 }
wim 3:2dccfa0121de 2146
wim 3:2dccfa0121de 2147 LCD_SetTextColor(BackColor);
wim 3:2dccfa0121de 2148
wim 3:2dccfa0121de 2149 /* Loop through the rows of the image. */
wim 3:2dccfa0121de 2150 for (pixelY = IMAGE_TOP; pixelY < IMAGE_BOTTOM; pixelY++)
wim 3:2dccfa0121de 2151 {
wim 3:2dccfa0121de 2152 /* Build a list of nodes. */
wim 3:2dccfa0121de 2153 nodes = 0; j = PointCount-1;
wim 3:2dccfa0121de 2154
wim 3:2dccfa0121de 2155 for (i = 0; i < PointCount; i++)
wim 3:2dccfa0121de 2156 {
wim 3:2dccfa0121de 2157 if (((POLY_Y(i)<(double) pixelY) && (POLY_Y(j)>=(double) pixelY)) || \
wim 3:2dccfa0121de 2158 ((POLY_Y(j)<(double) pixelY) && (POLY_Y(i)>=(double) pixelY)))
wim 3:2dccfa0121de 2159 {
wim 3:2dccfa0121de 2160 nodeX[nodes++]=(int) (POLY_X(i)+((pixelY-POLY_Y(i))*(POLY_X(j)-POLY_X(i)))/(POLY_Y(j)-POLY_Y(i)));
wim 3:2dccfa0121de 2161 }
wim 3:2dccfa0121de 2162 j = i;
wim 3:2dccfa0121de 2163 }
wim 3:2dccfa0121de 2164
wim 3:2dccfa0121de 2165 /* Sort the nodes, via a simple "Bubble" sort. */
wim 3:2dccfa0121de 2166 i = 0;
wim 3:2dccfa0121de 2167 while (i < nodes-1)
wim 3:2dccfa0121de 2168 {
wim 3:2dccfa0121de 2169 if (nodeX[i]>nodeX[i+1])
wim 3:2dccfa0121de 2170 {
wim 3:2dccfa0121de 2171 swap = nodeX[i];
wim 3:2dccfa0121de 2172 nodeX[i] = nodeX[i+1];
wim 3:2dccfa0121de 2173 nodeX[i+1] = swap;
wim 3:2dccfa0121de 2174 if(i)
wim 3:2dccfa0121de 2175 {
wim 3:2dccfa0121de 2176 i--;
wim 3:2dccfa0121de 2177 }
wim 3:2dccfa0121de 2178 }
wim 3:2dccfa0121de 2179 else
wim 3:2dccfa0121de 2180 {
wim 3:2dccfa0121de 2181 i++;
wim 3:2dccfa0121de 2182 }
wim 3:2dccfa0121de 2183 }
wim 3:2dccfa0121de 2184
wim 3:2dccfa0121de 2185 /* Fill the pixels between node pairs. */
wim 3:2dccfa0121de 2186 for (i = 0; i < nodes; i+=2)
wim 3:2dccfa0121de 2187 {
wim 3:2dccfa0121de 2188 if(nodeX[i] >= IMAGE_RIGHT)
wim 3:2dccfa0121de 2189 {
wim 3:2dccfa0121de 2190 break;
wim 3:2dccfa0121de 2191 }
wim 3:2dccfa0121de 2192 if(nodeX[i+1] > IMAGE_LEFT)
wim 3:2dccfa0121de 2193 {
wim 3:2dccfa0121de 2194 if (nodeX[i] < IMAGE_LEFT)
wim 3:2dccfa0121de 2195 {
wim 3:2dccfa0121de 2196 nodeX[i]=IMAGE_LEFT;
wim 3:2dccfa0121de 2197 }
wim 3:2dccfa0121de 2198 if(nodeX[i+1] > IMAGE_RIGHT)
wim 3:2dccfa0121de 2199 {
wim 3:2dccfa0121de 2200 nodeX[i+1] = IMAGE_RIGHT;
wim 3:2dccfa0121de 2201 }
wim 3:2dccfa0121de 2202 LCD_SetTextColor(BackColor);
wim 3:2dccfa0121de 2203 LCD_DrawLine(pixelY, nodeX[i+1], nodeX[i+1] - nodeX[i], LCD_DIR_HORIZONTAL);
wim 3:2dccfa0121de 2204 LCD_SetTextColor(TextColor);
wim 3:2dccfa0121de 2205 PutPixel(pixelY, nodeX[i+1]);
wim 3:2dccfa0121de 2206 PutPixel(pixelY, nodeX[i]);
wim 3:2dccfa0121de 2207 /* for (j=nodeX[i]; j<nodeX[i+1]; j++) PutPixel(j,pixelY); */
wim 3:2dccfa0121de 2208 }
wim 3:2dccfa0121de 2209 }
wim 3:2dccfa0121de 2210 }
wim 3:2dccfa0121de 2211
wim 3:2dccfa0121de 2212 /* draw the edges */
wim 3:2dccfa0121de 2213 LCD_SetTextColor(TextColor);
wim 3:2dccfa0121de 2214 }
wim 3:2dccfa0121de 2215
wim 3:2dccfa0121de 2216
wim 3:2dccfa0121de 2217
wim 3:2dccfa0121de 2218
wim 3:2dccfa0121de 2219 #endif
wim 0:a8090b59eb05 2220 /******************************************************************************/