.

Committer:
Geremia
Date:
Mon Feb 23 16:05:16 2015 +0000
Revision:
15:b9483ba842c8
Parent:
11:b842b8e332cb
Child:
20:14daa48ffd4c
LCD macro undef workaround for KL46Z KL43Z, thanks ban4jp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 4:12ba0ecc2c1f 1 /* mbed UniGraphic library - universal TFT driver class
Geremia 4:12ba0ecc2c1f 2 * Copyright (c) 2015 Giuliano Dianda
Geremia 4:12ba0ecc2c1f 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 4:12ba0ecc2c1f 4 *
Geremia 4:12ba0ecc2c1f 5 * Derived work of:
Geremia 4:12ba0ecc2c1f 6 *
Geremia 4:12ba0ecc2c1f 7 * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
Geremia 3:48f3282c2be8 8 * Copyright (c) 2013 Peter Drescher - DC2PD
Geremia 3:48f3282c2be8 9 *
Geremia 3:48f3282c2be8 10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Geremia 3:48f3282c2be8 11 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Geremia 3:48f3282c2be8 12 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Geremia 3:48f3282c2be8 13 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Geremia 3:48f3282c2be8 14 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Geremia 3:48f3282c2be8 15 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Geremia 3:48f3282c2be8 16 * THE SOFTWARE.
Geremia 3:48f3282c2be8 17 */
Geremia 3:48f3282c2be8 18
Geremia 2:713844a55c4e 19 #include "TFT.h"
Geremia 2:713844a55c4e 20
Geremia 15:b9483ba842c8 21 //#include "mbed_debug.h"
Geremia 2:713844a55c4e 22
Geremia 2:713844a55c4e 23 #define SWAP(a, b) { a ^= b; b ^= a; a ^= b; }
Geremia 2:713844a55c4e 24
Geremia 2:713844a55c4e 25 TFT::TFT(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const int lcdsize_x, const int lcdsize_y, const char *name)
Geremia 7:bb0383b91104 26 : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y)
Geremia 2:713844a55c4e 27 {
Geremia 2:713844a55c4e 28 if(displayproto==PAR_8) proto = new PAR8(port, CS, reset, DC, WR, RD);
Geremia 4:12ba0ecc2c1f 29 else if(displayproto==PAR_16) proto = new PAR16(port, CS, reset, DC, WR, RD);
Geremia 2:713844a55c4e 30 useNOP=false;
Geremia 4:12ba0ecc2c1f 31 scrollbugfix=0;
Geremia 4:12ba0ecc2c1f 32 mipistd=false;
Geremia 2:713844a55c4e 33 set_orientation(0);
Geremia 2:713844a55c4e 34 foreground(White);
Geremia 2:713844a55c4e 35 background(Black);
Geremia 2:713844a55c4e 36 set_auto_up(false); //we don't have framebuffer
Geremia 7:bb0383b91104 37 topfixedareasize=0;
Geremia 7:bb0383b91104 38 scrollareasize=0;
Geremia 10:668cf78ff93a 39 usefastwindow=false;
Geremia 10:668cf78ff93a 40 fastwindowready=false;
Geremia 11:b842b8e332cb 41 is18bit=false;
Geremia 11:b842b8e332cb 42 isBGR=false;
Geremia 2:713844a55c4e 43 // cls();
Geremia 2:713844a55c4e 44 // locate(0,0);
Geremia 2:713844a55c4e 45 }
Geremia 2:713844a55c4e 46 TFT::TFT(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const int lcdsize_x, const int lcdsize_y, const char *name)
Geremia 7:bb0383b91104 47 : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y)
Geremia 2:713844a55c4e 48 {
Geremia 2:713844a55c4e 49 if(displayproto==SPI_8)
Geremia 2:713844a55c4e 50 {
Geremia 2:713844a55c4e 51 proto = new SPI8(Hz, mosi, miso, sclk, CS, reset, DC);
Geremia 2:713844a55c4e 52 useNOP=false;
Geremia 2:713844a55c4e 53 }
Geremia 2:713844a55c4e 54 else if(displayproto==SPI_16)
Geremia 2:713844a55c4e 55 {
Geremia 2:713844a55c4e 56 proto = new SPI16(Hz, mosi, miso, sclk, CS, reset, DC);
Geremia 2:713844a55c4e 57 useNOP=true;
Geremia 2:713844a55c4e 58 }
Geremia 4:12ba0ecc2c1f 59 scrollbugfix=0;
Geremia 4:12ba0ecc2c1f 60 mipistd=false;
Geremia 2:713844a55c4e 61 set_orientation(0);
Geremia 2:713844a55c4e 62 foreground(White);
Geremia 2:713844a55c4e 63 background(Black);
Geremia 2:713844a55c4e 64 set_auto_up(false);
Geremia 7:bb0383b91104 65 topfixedareasize=0;
Geremia 7:bb0383b91104 66 scrollareasize=0;
Geremia 10:668cf78ff93a 67 usefastwindow=false;
Geremia 10:668cf78ff93a 68 fastwindowready=false;
Geremia 11:b842b8e332cb 69 is18bit=false;
Geremia 11:b842b8e332cb 70 isBGR=false;
Geremia 2:713844a55c4e 71 // locate(0,0);
Geremia 2:713844a55c4e 72 }
Geremia 2:713844a55c4e 73 void TFT::wr_cmd8(unsigned char cmd)
Geremia 2:713844a55c4e 74 {
Geremia 2:713844a55c4e 75 if(useNOP) proto->wr_cmd16(cmd); // 0x0000|cmd, 00 is NOP cmd for TFT
Geremia 2:713844a55c4e 76 else proto->wr_cmd8(cmd);
Geremia 2:713844a55c4e 77 }
Geremia 2:713844a55c4e 78 void TFT::wr_data8(unsigned char data)
Geremia 2:713844a55c4e 79 {
Geremia 2:713844a55c4e 80 proto->wr_data8(data);
Geremia 2:713844a55c4e 81 }
Geremia 2:713844a55c4e 82 void TFT::wr_data16(unsigned short data)
Geremia 2:713844a55c4e 83 {
Geremia 2:713844a55c4e 84 proto->wr_data16(data);
Geremia 2:713844a55c4e 85 }
Geremia 4:12ba0ecc2c1f 86 void TFT::wr_gram(unsigned short data)
Geremia 4:12ba0ecc2c1f 87 {
Geremia 4:12ba0ecc2c1f 88 proto->wr_gram(data);
Geremia 4:12ba0ecc2c1f 89 }
Geremia 4:12ba0ecc2c1f 90 void TFT::wr_gram(unsigned short data, unsigned int count)
Geremia 2:713844a55c4e 91 {
Geremia 4:12ba0ecc2c1f 92 proto->wr_gram(data, count);
Geremia 4:12ba0ecc2c1f 93 }
Geremia 4:12ba0ecc2c1f 94 void TFT::wr_grambuf(unsigned short* data, unsigned int lenght)
Geremia 4:12ba0ecc2c1f 95 {
Geremia 4:12ba0ecc2c1f 96 proto->wr_grambuf(data, lenght);
Geremia 2:713844a55c4e 97 }
Geremia 5:b222a9461d6b 98 unsigned short TFT::rd_gram()
Geremia 5:b222a9461d6b 99 {
Geremia 11:b842b8e332cb 100 return proto->rd_gram(is18bit); // protocol will handle 18to16 bit conversion
Geremia 7:bb0383b91104 101 }
Geremia 7:bb0383b91104 102 unsigned int TFT::rd_reg_data32(unsigned char reg)
Geremia 7:bb0383b91104 103 {
Geremia 7:bb0383b91104 104 return proto->rd_reg_data32(reg);
Geremia 7:bb0383b91104 105 }
Geremia 7:bb0383b91104 106 unsigned int TFT::rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd)
Geremia 7:bb0383b91104 107 {
Geremia 7:bb0383b91104 108 return proto->rd_extcreg_data32(reg, SPIreadenablecmd);
Geremia 5:b222a9461d6b 109 }
Geremia 4:12ba0ecc2c1f 110 //for TFT, just send data, position counters are in hw
Geremia 4:12ba0ecc2c1f 111 void TFT::window_pushpixel(unsigned short color)
Geremia 4:12ba0ecc2c1f 112 {
Geremia 4:12ba0ecc2c1f 113 proto->wr_gram(color);
Geremia 4:12ba0ecc2c1f 114 }
Geremia 4:12ba0ecc2c1f 115 void TFT::window_pushpixel(unsigned short color, unsigned int count)
Geremia 4:12ba0ecc2c1f 116 {
Geremia 4:12ba0ecc2c1f 117 proto->wr_gram(color, count);
Geremia 4:12ba0ecc2c1f 118 }
Geremia 4:12ba0ecc2c1f 119 void TFT::window_pushpixelbuf(unsigned short* color, unsigned int lenght)
Geremia 2:713844a55c4e 120 {
Geremia 4:12ba0ecc2c1f 121 proto->wr_grambuf(color, lenght);
Geremia 2:713844a55c4e 122 }
Geremia 2:713844a55c4e 123 void TFT::hw_reset()
Geremia 2:713844a55c4e 124 {
Geremia 2:713844a55c4e 125 proto->hw_reset();
Geremia 2:713844a55c4e 126 }
Geremia 2:713844a55c4e 127 void TFT::BusEnable(bool enable)
Geremia 2:713844a55c4e 128 {
Geremia 2:713844a55c4e 129 proto->BusEnable(enable);
Geremia 2:713844a55c4e 130 }
Geremia 2:713844a55c4e 131 // color TFT can rotate in hw (swap raw<->columns) for landscape views
Geremia 2:713844a55c4e 132 void TFT::set_orientation(int o)
Geremia 2:713844a55c4e 133 {
Geremia 2:713844a55c4e 134 orientation = o;
Geremia 2:713844a55c4e 135 wr_cmd8(0x36);
Geremia 2:713844a55c4e 136 switch (orientation) {
Geremia 2:713844a55c4e 137 case 0:// default, portrait view 0°
Geremia 2:713844a55c4e 138 if(mipistd) wr_data8(0x0A); // this is in real a vertical flip enabled, seems most displays are vertical flipped
Geremia 3:48f3282c2be8 139 else wr_data8(0x48); //for some other ILIxxxx
Geremia 7:bb0383b91104 140 set_width(screensize_X);
Geremia 7:bb0383b91104 141 set_height(screensize_Y);
Geremia 2:713844a55c4e 142 break;
Geremia 2:713844a55c4e 143 case 1:// landscape view +90°
Geremia 2:713844a55c4e 144 if(mipistd) wr_data8(0x28);
Geremia 3:48f3282c2be8 145 else wr_data8(0x29);//for some other ILIxxxx
Geremia 7:bb0383b91104 146 set_width(screensize_Y);
Geremia 7:bb0383b91104 147 set_height(screensize_X);
Geremia 2:713844a55c4e 148 break;
Geremia 2:713844a55c4e 149 case 2:// portrait view +180°
Geremia 2:713844a55c4e 150 if(mipistd) wr_data8(0x09);
Geremia 3:48f3282c2be8 151 else wr_data8(0x99);//for some other ILIxxxx
Geremia 7:bb0383b91104 152 set_width(screensize_X);
Geremia 7:bb0383b91104 153 set_height(screensize_Y);
Geremia 2:713844a55c4e 154 break;
Geremia 2:713844a55c4e 155 case 3:// landscape view -90°
Geremia 2:713844a55c4e 156 if(mipistd) wr_data8(0x2B);
Geremia 3:48f3282c2be8 157 else wr_data8(0xF8);//for some other ILIxxxx
Geremia 7:bb0383b91104 158 set_width(screensize_Y);
Geremia 7:bb0383b91104 159 set_height(screensize_X);
Geremia 2:713844a55c4e 160 break;
Geremia 2:713844a55c4e 161 }
Geremia 2:713844a55c4e 162 }
Geremia 7:bb0383b91104 163 void TFT::invert(unsigned char o)
Geremia 7:bb0383b91104 164 {
Geremia 7:bb0383b91104 165 if(o == 0) wr_cmd8(0x20);
Geremia 7:bb0383b91104 166 else wr_cmd8(0x21);
Geremia 7:bb0383b91104 167 }
Geremia 10:668cf78ff93a 168 void TFT::FastWindow(bool enable)
Geremia 10:668cf78ff93a 169 {
Geremia 10:668cf78ff93a 170 usefastwindow=enable;
Geremia 10:668cf78ff93a 171 }
Geremia 2:713844a55c4e 172 // TFT have both column and raw autoincrement inside a window, with internal counters
Geremia 2:713844a55c4e 173 void TFT::window(int x, int y, int w, int h)
Geremia 2:713844a55c4e 174 {
Geremia 10:668cf78ff93a 175 fastwindowready=false; // end raw/column going to be set to lower value than bottom-right corner
Geremia 2:713844a55c4e 176 wr_cmd8(0x2A);
Geremia 2:713844a55c4e 177 wr_data16(x); //start column
Geremia 2:713844a55c4e 178 wr_data16(x+w-1);//end column
Geremia 2:713844a55c4e 179
Geremia 2:713844a55c4e 180 wr_cmd8(0x2B);
Geremia 2:713844a55c4e 181 wr_data16(y); //start page
Geremia 2:713844a55c4e 182 wr_data16(y+h-1);//end page
Geremia 2:713844a55c4e 183
Geremia 2:713844a55c4e 184 wr_cmd8(0x2C); //write mem, just send pixels color next
Geremia 2:713844a55c4e 185 }
Geremia 5:b222a9461d6b 186 void TFT::window4read(int x, int y, int w, int h)
Geremia 5:b222a9461d6b 187 {
Geremia 10:668cf78ff93a 188 fastwindowready=false;
Geremia 5:b222a9461d6b 189 wr_cmd8(0x2A);
Geremia 5:b222a9461d6b 190 wr_data16(x); //start column
Geremia 5:b222a9461d6b 191 wr_data16(x+w-1);//end column
Geremia 5:b222a9461d6b 192
Geremia 5:b222a9461d6b 193 wr_cmd8(0x2B);
Geremia 5:b222a9461d6b 194 wr_data16(y); //start page
Geremia 5:b222a9461d6b 195 wr_data16(y+h-1);//end page
Geremia 5:b222a9461d6b 196
Geremia 5:b222a9461d6b 197 wr_cmd8(0x2E); //read mem, just pixelread next
Geremia 5:b222a9461d6b 198 }
Geremia 2:713844a55c4e 199 void TFT::pixel(int x, int y, unsigned short color)
Geremia 2:713844a55c4e 200 {
Geremia 10:668cf78ff93a 201 if(usefastwindow) //ili9486 does not like truncated 2A/2B cmds, at least in par mode
Geremia 10:668cf78ff93a 202 {
Geremia 10:668cf78ff93a 203 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 10:668cf78ff93a 204 {
Geremia 10:668cf78ff93a 205 wr_cmd8(0x2A);
Geremia 10:668cf78ff93a 206 wr_data16(x); //start column only
Geremia 10:668cf78ff93a 207 wr_cmd8(0x2B);
Geremia 10:668cf78ff93a 208 wr_data16(y); //start page only
Geremia 10:668cf78ff93a 209 wr_cmd8(0x2C); //write mem, just send pixels color next
Geremia 10:668cf78ff93a 210 }
Geremia 10:668cf78ff93a 211 else
Geremia 10:668cf78ff93a 212 {
Geremia 10:668cf78ff93a 213 window(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 10:668cf78ff93a 214 fastwindowready=true;
Geremia 10:668cf78ff93a 215 }
Geremia 10:668cf78ff93a 216 }
Geremia 10:668cf78ff93a 217 else window(x,y,1,1);
Geremia 4:12ba0ecc2c1f 218 // proto->wr_gram(color); // 2C expects 16bit parameters
Geremia 4:12ba0ecc2c1f 219 wr_gram(color);
Geremia 2:713844a55c4e 220 }
Geremia 5:b222a9461d6b 221 unsigned short TFT::pixelread(int x, int y)
Geremia 5:b222a9461d6b 222 {
Geremia 10:668cf78ff93a 223 if(usefastwindow) //ili9486 does not like truncated 2A/2B cmds, at least in par mode
Geremia 10:668cf78ff93a 224 {
Geremia 10:668cf78ff93a 225 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 10:668cf78ff93a 226 {
Geremia 10:668cf78ff93a 227 wr_cmd8(0x2A);
Geremia 10:668cf78ff93a 228 wr_data16(x); //start column only
Geremia 10:668cf78ff93a 229 wr_cmd8(0x2B);
Geremia 10:668cf78ff93a 230 wr_data16(y); //start page only
Geremia 10:668cf78ff93a 231 wr_cmd8(0x2E); //read mem, just pixelread next
Geremia 10:668cf78ff93a 232 }
Geremia 10:668cf78ff93a 233 else
Geremia 10:668cf78ff93a 234 {
Geremia 10:668cf78ff93a 235 window4read(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 10:668cf78ff93a 236 fastwindowready=true;
Geremia 10:668cf78ff93a 237 }
Geremia 10:668cf78ff93a 238 }
Geremia 10:668cf78ff93a 239 else window4read(x,y,1,1);
Geremia 10:668cf78ff93a 240
Geremia 5:b222a9461d6b 241 unsigned short color;
Geremia 5:b222a9461d6b 242 // proto->wr_gram(color); // 2C expects 16bit parameters
Geremia 5:b222a9461d6b 243 color = rd_gram();
Geremia 11:b842b8e332cb 244 if(isBGR) color = BGR2RGB(color); // in case, convert BGR to RGB (should depend on cmd36 bit3) but maybe is device specific
Geremia 5:b222a9461d6b 245 return color;
Geremia 5:b222a9461d6b 246 }
Geremia 7:bb0383b91104 247 void TFT::setscrollarea (int startY, int areasize) // ie 0,480 for whole screen
Geremia 7:bb0383b91104 248 {
Geremia 7:bb0383b91104 249 unsigned int bfa;
Geremia 7:bb0383b91104 250 topfixedareasize=startY;
Geremia 7:bb0383b91104 251 scrollareasize=areasize;
Geremia 7:bb0383b91104 252 wr_cmd8(0x33);
Geremia 7:bb0383b91104 253 wr_data16(topfixedareasize); //num lines of top fixed area
Geremia 7:bb0383b91104 254 wr_data16(scrollareasize+scrollbugfix); //num lines of vertical scroll area, +1 for ILI9481 fix
Geremia 8:26757296c79d 255 if((areasize+startY)>screensize_Y) bfa=0;
Geremia 8:26757296c79d 256 else bfa = screensize_Y-(areasize+startY);
Geremia 7:bb0383b91104 257 wr_data16(bfa); //num lines of bottom fixed area
Geremia 7:bb0383b91104 258 }
Geremia 7:bb0383b91104 259 void TFT::scroll (int lines) // ie 1= scrollup 1, 479= scrolldown 1
Geremia 7:bb0383b91104 260 {
Geremia 7:bb0383b91104 261 wr_cmd8(0x37);
Geremia 8:26757296c79d 262 wr_data16(topfixedareasize+(lines%scrollareasize)); // select the (absolute)line which will be displayed as first scrollarea line
Geremia 7:bb0383b91104 263 }
Geremia 7:bb0383b91104 264 void TFT::scrollreset()
Geremia 7:bb0383b91104 265 {
Geremia 7:bb0383b91104 266 wr_cmd8(0x13); //normal display mode
Geremia 7:bb0383b91104 267 }
Geremia 2:713844a55c4e 268 void TFT::cls (void)
Geremia 2:713844a55c4e 269 {
Geremia 2:713844a55c4e 270 WindowMax();
Geremia 7:bb0383b91104 271 // proto->wr_gram(_background,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 272 // proto->wr_gram(0,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 273 wr_gram(_background,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 274 }
Geremia 11:b842b8e332cb 275 // try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR
Geremia 11:b842b8e332cb 276 void TFT::auto_gram_read_format()
Geremia 11:b842b8e332cb 277 {
Geremia 11:b842b8e332cb 278 unsigned short px=0xCDB1;
Geremia 11:b842b8e332cb 279 unsigned short rback, rback18;
Geremia 11:b842b8e332cb 280 pixel(0,0,px);
Geremia 11:b842b8e332cb 281 window4read(0,0,1,1);
Geremia 11:b842b8e332cb 282 rback=proto->rd_gram(0); // try 16bit
Geremia 11:b842b8e332cb 283 window4read(0,0,1,1);
Geremia 11:b842b8e332cb 284 rback18=proto->rd_gram(1); // try 18bit converted to 16
Geremia 11:b842b8e332cb 285 if((rback18==px) || (BGR2RGB(rback18)==px))
Geremia 11:b842b8e332cb 286 {
Geremia 11:b842b8e332cb 287 is18bit=true;
Geremia 11:b842b8e332cb 288 if(BGR2RGB(rback18)==px) isBGR=true;
Geremia 11:b842b8e332cb 289 }
Geremia 11:b842b8e332cb 290 else if((rback==px) || (BGR2RGB(rback)==px))
Geremia 11:b842b8e332cb 291 {
Geremia 11:b842b8e332cb 292 if(BGR2RGB(rback)==px) isBGR=true;
Geremia 11:b842b8e332cb 293 }
Geremia 11:b842b8e332cb 294 // else debug("\r\nfail to identify gram read color format,\r\nsent %.4X read16 %.4X read18 %.4X", px, rback, rback18);
Geremia 11:b842b8e332cb 295 }
Geremia 7:bb0383b91104 296 // try to identify display controller
Geremia 7:bb0383b91104 297 void TFT::identify()
Geremia 7:bb0383b91104 298 {
Geremia 7:bb0383b91104 299 // MIPI std read ID cmd
Geremia 7:bb0383b91104 300 tftID=rd_reg_data32(0xBF);
Geremia 7:bb0383b91104 301 mipistd=true;
Geremia 7:bb0383b91104 302 // debug("ID MIPI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 303 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 304 {
Geremia 7:bb0383b91104 305 mipistd=false;
Geremia 7:bb0383b91104 306 // ILI specfic read ID cmd
Geremia 7:bb0383b91104 307 tftID=rd_reg_data32(0xD3)>>8;
Geremia 7:bb0383b91104 308 // debug("ID ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 309 }
Geremia 7:bb0383b91104 310 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 311 {
Geremia 7:bb0383b91104 312 // ILI specfic read ID cmd with ili9341 specific spi read-in enable 0xD9 cmd
Geremia 7:bb0383b91104 313 tftID=rd_extcreg_data32(0xD3, 0xD9);
Geremia 7:bb0383b91104 314 // debug("ID D9 extc ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 315 }
Geremia 7:bb0383b91104 316 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 317 {
Geremia 7:bb0383b91104 318 // ILI specfic read ID cmd with ili9486/88 specific spi read-in enable 0xFB cmd
Geremia 7:bb0383b91104 319 tftID=rd_extcreg_data32(0xD3, 0xFB);
Geremia 7:bb0383b91104 320 // debug("ID D9 extc ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 321 }
Geremia 7:bb0383b91104 322 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF))) tftID=0xDEAD;
Geremia 7:bb0383b91104 323 if ((tftID&0xFFFF)==0x9481) scrollbugfix=1;
Geremia 7:bb0383b91104 324 else scrollbugfix=0;
Geremia 7:bb0383b91104 325 hw_reset(); // in case wrong cmds messed up important settings
Geremia 7:bb0383b91104 326 }
Geremia 7:bb0383b91104 327 int TFT::sizeX()
Geremia 7:bb0383b91104 328 {
Geremia 7:bb0383b91104 329 return screensize_X;
Geremia 7:bb0383b91104 330 }
Geremia 7:bb0383b91104 331 int TFT::sizeY()
Geremia 7:bb0383b91104 332 {
Geremia 7:bb0383b91104 333 return screensize_Y;
Geremia 2:713844a55c4e 334 }