Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.

Dependents:   afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more

Fork of UniGraphic by GraphicsDisplay

UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.

Committer:
Geremia
Date:
Sat Nov 28 18:37:19 2015 +0000
Revision:
29:866213bb9bf0
Add ILI9327 and S6D04D1 (240x400 displays)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 29:866213bb9bf0 1 /* mbed UniGraphic library - Device specific class
Geremia 29:866213bb9bf0 2 * Copyright (c) 2015 Giuliano Dianda
Geremia 29:866213bb9bf0 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 29:866213bb9bf0 4 */
Geremia 29:866213bb9bf0 5 #include "Protocols.h"
Geremia 29:866213bb9bf0 6 #include "S6D04D1.h"
Geremia 29:866213bb9bf0 7
Geremia 29:866213bb9bf0 8 //////////////////////////////////////////////////////////////////////////////////
Geremia 29:866213bb9bf0 9 // display settings ///////////////////////////////////////////////////////
Geremia 29:866213bb9bf0 10 /////////////////////////////////////////////////////////////////////////
Geremia 29:866213bb9bf0 11
Geremia 29:866213bb9bf0 12 // put in constructor
Geremia 29:866213bb9bf0 13 //#define LCDSIZE_X 240 // display X pixels, TFTs are usually portrait view
Geremia 29:866213bb9bf0 14 //#define LCDSIZE_Y 400 // display Y pixels
Geremia 29:866213bb9bf0 15
Geremia 29:866213bb9bf0 16
Geremia 29:866213bb9bf0 17
Geremia 29:866213bb9bf0 18 S6D04D1::S6D04D1(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y)
Geremia 29:866213bb9bf0 19 : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 29:866213bb9bf0 20 {
Geremia 29:866213bb9bf0 21 hw_reset();
Geremia 29:866213bb9bf0 22 BusEnable(true);
Geremia 29:866213bb9bf0 23 identify(); // will collect tftID, set mipistd flag
Geremia 29:866213bb9bf0 24 init();
Geremia 29:866213bb9bf0 25 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 29:866213bb9bf0 26 // scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
Geremia 29:866213bb9bf0 27 set_orientation(0);
Geremia 29:866213bb9bf0 28 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
Geremia 29:866213bb9bf0 29 cls();
Geremia 29:866213bb9bf0 30 locate(0,0);
Geremia 29:866213bb9bf0 31 }
Geremia 29:866213bb9bf0 32 S6D04D1::S6D04D1(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y)
Geremia 29:866213bb9bf0 33 : TFT(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 29:866213bb9bf0 34 {
Geremia 29:866213bb9bf0 35 hw_reset();
Geremia 29:866213bb9bf0 36 BusEnable(true);
Geremia 29:866213bb9bf0 37 identify(); // will collect tftID, set mipistd flag
Geremia 29:866213bb9bf0 38 init();
Geremia 29:866213bb9bf0 39 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 29:866213bb9bf0 40 // scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
Geremia 29:866213bb9bf0 41 set_orientation(0);
Geremia 29:866213bb9bf0 42 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
Geremia 29:866213bb9bf0 43 cls();
Geremia 29:866213bb9bf0 44 locate(0,0);
Geremia 29:866213bb9bf0 45 }
Geremia 29:866213bb9bf0 46 S6D04D1::S6D04D1(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name , unsigned int LCDSIZE_X , unsigned int LCDSIZE_Y )
Geremia 29:866213bb9bf0 47 : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 29:866213bb9bf0 48 {
Geremia 29:866213bb9bf0 49 hw_reset(); //TFT class forwards to Protocol class
Geremia 29:866213bb9bf0 50 BusEnable(true); //TFT class forwards to Protocol class
Geremia 29:866213bb9bf0 51 identify(); // will collect tftID and set mipistd flag
Geremia 29:866213bb9bf0 52 init(); // per display custom init cmd sequence, implemented here
Geremia 29:866213bb9bf0 53 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 29:866213bb9bf0 54 // scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
Geremia 29:866213bb9bf0 55 set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
Geremia 29:866213bb9bf0 56 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
Geremia 29:866213bb9bf0 57 cls();
Geremia 29:866213bb9bf0 58 locate(0,0);
Geremia 29:866213bb9bf0 59 }
Geremia 29:866213bb9bf0 60 // reset and init the lcd controller
Geremia 29:866213bb9bf0 61 void S6D04D1::init()
Geremia 29:866213bb9bf0 62 {
Geremia 29:866213bb9bf0 63 /**********************************************
Geremia 29:866213bb9bf0 64 TFT1P CODE Initialization of Truly
Geremia 29:866213bb9bf0 65
Geremia 29:866213bb9bf0 66 ************************************************
Geremia 29:866213bb9bf0 67 Panel:3.0 240400
Geremia 29:866213bb9bf0 68 Driver IC:S6D04D1X21-BAF8
Geremia 29:866213bb9bf0 69
Geremia 29:866213bb9bf0 70 ************************************************/
Geremia 29:866213bb9bf0 71 wr_cmd8(0xE0);
Geremia 29:866213bb9bf0 72 wr_data8(0x01);
Geremia 29:866213bb9bf0 73
Geremia 29:866213bb9bf0 74 wr_cmd8(0x11);
Geremia 29:866213bb9bf0 75 wait_ms(150);
Geremia 29:866213bb9bf0 76
Geremia 29:866213bb9bf0 77 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 78 wr_data8(0x01);
Geremia 29:866213bb9bf0 79 wr_data8(0x00);
Geremia 29:866213bb9bf0 80 wr_data8(0x00);
Geremia 29:866213bb9bf0 81 wr_data8(0x0C);//Do not set any higher VCI1 level than VCI -0.15V. 0C 0A
Geremia 29:866213bb9bf0 82 wr_data8(0x03);//VGH和VGL 01 02VGH=6VCI1,VGL=-4VCI1.
Geremia 29:866213bb9bf0 83 wr_data8(0x75);
Geremia 29:866213bb9bf0 84 wr_data8(0x75);
Geremia 29:866213bb9bf0 85 wr_data8(0x30);
Geremia 29:866213bb9bf0 86
Geremia 29:866213bb9bf0 87 wr_cmd8(0xF4);
Geremia 29:866213bb9bf0 88 wr_data8(0x4C);
Geremia 29:866213bb9bf0 89 wr_data8(0x4C);
Geremia 29:866213bb9bf0 90 wr_data8(0x44);
Geremia 29:866213bb9bf0 91 wr_data8(0x44);
Geremia 29:866213bb9bf0 92 wr_data8(0x22);
Geremia 29:866213bb9bf0 93
Geremia 29:866213bb9bf0 94 wr_cmd8(0xF5);
Geremia 29:866213bb9bf0 95 wr_data8(0x10);
Geremia 29:866213bb9bf0 96 wr_data8(0x22);
Geremia 29:866213bb9bf0 97 wr_data8(0x05);
Geremia 29:866213bb9bf0 98 wr_data8(0xF0);
Geremia 29:866213bb9bf0 99 wr_data8(0x70);
Geremia 29:866213bb9bf0 100 wr_data8(0x1F);
Geremia 29:866213bb9bf0 101 wait_ms(30);
Geremia 29:866213bb9bf0 102
Geremia 29:866213bb9bf0 103 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 104 wr_data8(0x03);
Geremia 29:866213bb9bf0 105 wait_ms(30);
Geremia 29:866213bb9bf0 106 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 107 wr_data8(0x07);
Geremia 29:866213bb9bf0 108 wait_ms(30);
Geremia 29:866213bb9bf0 109 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 110 wr_data8(0x0F);
Geremia 29:866213bb9bf0 111 wait_ms(30);
Geremia 29:866213bb9bf0 112 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 113 wr_data8(0x1F);
Geremia 29:866213bb9bf0 114 wait_ms(30);
Geremia 29:866213bb9bf0 115 wr_cmd8(0xF3);
Geremia 29:866213bb9bf0 116 wr_data8(0x7F);
Geremia 29:866213bb9bf0 117 wait_ms(30);
Geremia 29:866213bb9bf0 118
Geremia 29:866213bb9bf0 119
Geremia 29:866213bb9bf0 120 wr_cmd8(0xF7);
Geremia 29:866213bb9bf0 121 wr_data8(0x80);
Geremia 29:866213bb9bf0 122 wr_data8(0x00);
Geremia 29:866213bb9bf0 123 wr_data8(0x00);
Geremia 29:866213bb9bf0 124 wr_data8(0x05);
Geremia 29:866213bb9bf0 125 wr_data8(0x0D);
Geremia 29:866213bb9bf0 126 wr_data8(0x1F);
Geremia 29:866213bb9bf0 127 wr_data8(0x26);
Geremia 29:866213bb9bf0 128 wr_data8(0x2D);
Geremia 29:866213bb9bf0 129 wr_data8(0x14);
Geremia 29:866213bb9bf0 130 wr_data8(0x15);
Geremia 29:866213bb9bf0 131 wr_data8(0x26);
Geremia 29:866213bb9bf0 132 wr_data8(0x20);
Geremia 29:866213bb9bf0 133 wr_data8(0x01);
Geremia 29:866213bb9bf0 134 wr_data8(0x22);
Geremia 29:866213bb9bf0 135 wr_data8(0x22);
Geremia 29:866213bb9bf0 136
Geremia 29:866213bb9bf0 137 wr_cmd8(0xF8);
Geremia 29:866213bb9bf0 138 wr_data8(0x80);
Geremia 29:866213bb9bf0 139 wr_data8(0x00);
Geremia 29:866213bb9bf0 140 wr_data8(0x00);
Geremia 29:866213bb9bf0 141 wr_data8(0x00);
Geremia 29:866213bb9bf0 142 wr_data8(0x07);
Geremia 29:866213bb9bf0 143 wr_data8(0x1E);
Geremia 29:866213bb9bf0 144 wr_data8(0x2A);
Geremia 29:866213bb9bf0 145 wr_data8(0x32);
Geremia 29:866213bb9bf0 146 wr_data8(0x10);
Geremia 29:866213bb9bf0 147 wr_data8(0x16);
Geremia 29:866213bb9bf0 148 wr_data8(0x36);
Geremia 29:866213bb9bf0 149 wr_data8(0x3C);
Geremia 29:866213bb9bf0 150 wr_data8(0x3B);
Geremia 29:866213bb9bf0 151 wr_data8(0x22);
Geremia 29:866213bb9bf0 152 wr_data8(0x22);
Geremia 29:866213bb9bf0 153
Geremia 29:866213bb9bf0 154 wr_cmd8(0xF9);
Geremia 29:866213bb9bf0 155 wr_data8(0x80);
Geremia 29:866213bb9bf0 156 wr_data8(0x00);
Geremia 29:866213bb9bf0 157 wr_data8(0x00);
Geremia 29:866213bb9bf0 158 wr_data8(0x05);
Geremia 29:866213bb9bf0 159 wr_data8(0x0D);
Geremia 29:866213bb9bf0 160 wr_data8(0x1F);
Geremia 29:866213bb9bf0 161 wr_data8(0x26);
Geremia 29:866213bb9bf0 162 wr_data8(0x2D);
Geremia 29:866213bb9bf0 163 wr_data8(0x14);
Geremia 29:866213bb9bf0 164 wr_data8(0x15);
Geremia 29:866213bb9bf0 165 wr_data8(0x26);
Geremia 29:866213bb9bf0 166 wr_data8(0x20);
Geremia 29:866213bb9bf0 167 wr_data8(0x01);
Geremia 29:866213bb9bf0 168 wr_data8(0x22);
Geremia 29:866213bb9bf0 169 wr_data8(0x22);
Geremia 29:866213bb9bf0 170
Geremia 29:866213bb9bf0 171
Geremia 29:866213bb9bf0 172 wr_cmd8(0xFA);
Geremia 29:866213bb9bf0 173 wr_data8(0x80);
Geremia 29:866213bb9bf0 174 wr_data8(0x00);
Geremia 29:866213bb9bf0 175 wr_data8(0x00);
Geremia 29:866213bb9bf0 176 wr_data8(0x00);
Geremia 29:866213bb9bf0 177 wr_data8(0x07);
Geremia 29:866213bb9bf0 178 wr_data8(0x1E);
Geremia 29:866213bb9bf0 179 wr_data8(0x2A);
Geremia 29:866213bb9bf0 180 wr_data8(0x32);
Geremia 29:866213bb9bf0 181 wr_data8(0x10);
Geremia 29:866213bb9bf0 182 wr_data8(0x16);
Geremia 29:866213bb9bf0 183 wr_data8(0x36);
Geremia 29:866213bb9bf0 184 wr_data8(0x3C);
Geremia 29:866213bb9bf0 185 wr_data8(0x3B);
Geremia 29:866213bb9bf0 186 wr_data8(0x22);
Geremia 29:866213bb9bf0 187 wr_data8(0x22);
Geremia 29:866213bb9bf0 188
Geremia 29:866213bb9bf0 189
Geremia 29:866213bb9bf0 190 wr_cmd8(0xFB);
Geremia 29:866213bb9bf0 191 wr_data8(0x80);
Geremia 29:866213bb9bf0 192 wr_data8(0x00);
Geremia 29:866213bb9bf0 193 wr_data8(0x00);
Geremia 29:866213bb9bf0 194 wr_data8(0x05);
Geremia 29:866213bb9bf0 195 wr_data8(0x0D);
Geremia 29:866213bb9bf0 196 wr_data8(0x1F);
Geremia 29:866213bb9bf0 197 wr_data8(0x26);
Geremia 29:866213bb9bf0 198 wr_data8(0x2D);
Geremia 29:866213bb9bf0 199 wr_data8(0x14);
Geremia 29:866213bb9bf0 200 wr_data8(0x15);
Geremia 29:866213bb9bf0 201 wr_data8(0x26);
Geremia 29:866213bb9bf0 202 wr_data8(0x20);
Geremia 29:866213bb9bf0 203 wr_data8(0x01);
Geremia 29:866213bb9bf0 204 wr_data8(0x22);
Geremia 29:866213bb9bf0 205 wr_data8(0x22);
Geremia 29:866213bb9bf0 206
Geremia 29:866213bb9bf0 207 wr_cmd8(0xFC);
Geremia 29:866213bb9bf0 208 wr_data8(0x80);
Geremia 29:866213bb9bf0 209 wr_data8(0x00);
Geremia 29:866213bb9bf0 210 wr_data8(0x00);
Geremia 29:866213bb9bf0 211 wr_data8(0x00);
Geremia 29:866213bb9bf0 212 wr_data8(0x07);
Geremia 29:866213bb9bf0 213 wr_data8(0x1E);
Geremia 29:866213bb9bf0 214 wr_data8(0x2A);
Geremia 29:866213bb9bf0 215 wr_data8(0x32);
Geremia 29:866213bb9bf0 216 wr_data8(0x10);
Geremia 29:866213bb9bf0 217 wr_data8(0x16);
Geremia 29:866213bb9bf0 218 wr_data8(0x36);
Geremia 29:866213bb9bf0 219 wr_data8(0x3C);
Geremia 29:866213bb9bf0 220 wr_data8(0x3B);
Geremia 29:866213bb9bf0 221 wr_data8(0x22);
Geremia 29:866213bb9bf0 222 wr_data8(0x22);
Geremia 29:866213bb9bf0 223
Geremia 29:866213bb9bf0 224 //wr_cmd8(0x35);
Geremia 29:866213bb9bf0 225 wr_cmd8(0x34); // tearing effect line off
Geremia 29:866213bb9bf0 226
Geremia 29:866213bb9bf0 227 wr_cmd8(0x36);
Geremia 29:866213bb9bf0 228 wr_data8(0x48);//08
Geremia 29:866213bb9bf0 229
Geremia 29:866213bb9bf0 230 wr_cmd8(0x3A);
Geremia 29:866213bb9bf0 231 wr_data8(0x05);
Geremia 29:866213bb9bf0 232
Geremia 29:866213bb9bf0 233 wr_cmd8(0xF2);
Geremia 29:866213bb9bf0 234 wr_data8(0x17);
Geremia 29:866213bb9bf0 235 wr_data8(0x17);
Geremia 29:866213bb9bf0 236 wr_data8(0x0F);
Geremia 29:866213bb9bf0 237 wr_data8(0x08);
Geremia 29:866213bb9bf0 238 wr_data8(0x08);
Geremia 29:866213bb9bf0 239 wr_data8(0x00);
Geremia 29:866213bb9bf0 240 wr_data8(0x00);
Geremia 29:866213bb9bf0 241 wr_data8(0x00);
Geremia 29:866213bb9bf0 242 wr_data8(0x00);
Geremia 29:866213bb9bf0 243 wr_data8(0x13);
Geremia 29:866213bb9bf0 244 wr_data8(0x00);
Geremia 29:866213bb9bf0 245
Geremia 29:866213bb9bf0 246 wr_cmd8(0xF6);
Geremia 29:866213bb9bf0 247 wr_data8(0x00);
Geremia 29:866213bb9bf0 248 wr_data8(0x08);
Geremia 29:866213bb9bf0 249 wr_data8(0x00);
Geremia 29:866213bb9bf0 250 wr_data8(0x00);
Geremia 29:866213bb9bf0 251
Geremia 29:866213bb9bf0 252 wr_cmd8(0xFD);
Geremia 29:866213bb9bf0 253 wr_data8(0x02);
Geremia 29:866213bb9bf0 254 wr_data8(0x01);//240*400
Geremia 29:866213bb9bf0 255
Geremia 29:866213bb9bf0 256 wait_ms(20);
Geremia 29:866213bb9bf0 257 wr_cmd8(0x29); // display on
Geremia 29:866213bb9bf0 258 wait_ms(20);
Geremia 29:866213bb9bf0 259
Geremia 29:866213bb9bf0 260 }