test

Fork of UniGraphic by GraphicsDisplay

Committer:
Geremia
Date:
Mon Mar 23 14:08:04 2015 +0000
Revision:
20:14daa48ffd4c
Parent:
15:b9483ba842c8
Child:
21:ae0a4eedfc90
Add  ILI 9320/9325/9328 custom TFT932x class, parallel/spi 8/16bit, with orientation, scroll, pixelread, fastwindow.; Par8 and 16 tested, SPI not at all, needs checking if the CS toggle is necessary (see SPI8.cpp SPI16.cpp).

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 20:14daa48ffd4c 126 BusEnable(true);
Geremia 2:713844a55c4e 127 }
Geremia 2:713844a55c4e 128 void TFT::BusEnable(bool enable)
Geremia 2:713844a55c4e 129 {
Geremia 2:713844a55c4e 130 proto->BusEnable(enable);
Geremia 2:713844a55c4e 131 }
Geremia 2:713844a55c4e 132 // color TFT can rotate in hw (swap raw<->columns) for landscape views
Geremia 2:713844a55c4e 133 void TFT::set_orientation(int o)
Geremia 2:713844a55c4e 134 {
Geremia 2:713844a55c4e 135 orientation = o;
Geremia 2:713844a55c4e 136 wr_cmd8(0x36);
Geremia 2:713844a55c4e 137 switch (orientation) {
Geremia 2:713844a55c4e 138 case 0:// default, portrait view 0°
Geremia 2:713844a55c4e 139 if(mipistd) wr_data8(0x0A); // this is in real a vertical flip enabled, seems most displays are vertical flipped
Geremia 3:48f3282c2be8 140 else wr_data8(0x48); //for some other ILIxxxx
Geremia 7:bb0383b91104 141 set_width(screensize_X);
Geremia 7:bb0383b91104 142 set_height(screensize_Y);
Geremia 2:713844a55c4e 143 break;
Geremia 2:713844a55c4e 144 case 1:// landscape view +90°
Geremia 2:713844a55c4e 145 if(mipistd) wr_data8(0x28);
Geremia 3:48f3282c2be8 146 else wr_data8(0x29);//for some other ILIxxxx
Geremia 7:bb0383b91104 147 set_width(screensize_Y);
Geremia 7:bb0383b91104 148 set_height(screensize_X);
Geremia 2:713844a55c4e 149 break;
Geremia 2:713844a55c4e 150 case 2:// portrait view +180°
Geremia 2:713844a55c4e 151 if(mipistd) wr_data8(0x09);
Geremia 3:48f3282c2be8 152 else wr_data8(0x99);//for some other ILIxxxx
Geremia 7:bb0383b91104 153 set_width(screensize_X);
Geremia 7:bb0383b91104 154 set_height(screensize_Y);
Geremia 2:713844a55c4e 155 break;
Geremia 2:713844a55c4e 156 case 3:// landscape view -90°
Geremia 2:713844a55c4e 157 if(mipistd) wr_data8(0x2B);
Geremia 3:48f3282c2be8 158 else wr_data8(0xF8);//for some other ILIxxxx
Geremia 7:bb0383b91104 159 set_width(screensize_Y);
Geremia 7:bb0383b91104 160 set_height(screensize_X);
Geremia 2:713844a55c4e 161 break;
Geremia 2:713844a55c4e 162 }
Geremia 2:713844a55c4e 163 }
Geremia 7:bb0383b91104 164 void TFT::invert(unsigned char o)
Geremia 7:bb0383b91104 165 {
Geremia 7:bb0383b91104 166 if(o == 0) wr_cmd8(0x20);
Geremia 7:bb0383b91104 167 else wr_cmd8(0x21);
Geremia 7:bb0383b91104 168 }
Geremia 10:668cf78ff93a 169 void TFT::FastWindow(bool enable)
Geremia 10:668cf78ff93a 170 {
Geremia 10:668cf78ff93a 171 usefastwindow=enable;
Geremia 10:668cf78ff93a 172 }
Geremia 2:713844a55c4e 173 // TFT have both column and raw autoincrement inside a window, with internal counters
Geremia 2:713844a55c4e 174 void TFT::window(int x, int y, int w, int h)
Geremia 2:713844a55c4e 175 {
Geremia 10:668cf78ff93a 176 fastwindowready=false; // end raw/column going to be set to lower value than bottom-right corner
Geremia 2:713844a55c4e 177 wr_cmd8(0x2A);
Geremia 2:713844a55c4e 178 wr_data16(x); //start column
Geremia 2:713844a55c4e 179 wr_data16(x+w-1);//end column
Geremia 2:713844a55c4e 180
Geremia 2:713844a55c4e 181 wr_cmd8(0x2B);
Geremia 2:713844a55c4e 182 wr_data16(y); //start page
Geremia 2:713844a55c4e 183 wr_data16(y+h-1);//end page
Geremia 2:713844a55c4e 184
Geremia 2:713844a55c4e 185 wr_cmd8(0x2C); //write mem, just send pixels color next
Geremia 2:713844a55c4e 186 }
Geremia 5:b222a9461d6b 187 void TFT::window4read(int x, int y, int w, int h)
Geremia 5:b222a9461d6b 188 {
Geremia 10:668cf78ff93a 189 fastwindowready=false;
Geremia 5:b222a9461d6b 190 wr_cmd8(0x2A);
Geremia 5:b222a9461d6b 191 wr_data16(x); //start column
Geremia 5:b222a9461d6b 192 wr_data16(x+w-1);//end column
Geremia 5:b222a9461d6b 193
Geremia 5:b222a9461d6b 194 wr_cmd8(0x2B);
Geremia 5:b222a9461d6b 195 wr_data16(y); //start page
Geremia 5:b222a9461d6b 196 wr_data16(y+h-1);//end page
Geremia 5:b222a9461d6b 197
Geremia 5:b222a9461d6b 198 wr_cmd8(0x2E); //read mem, just pixelread next
Geremia 5:b222a9461d6b 199 }
Geremia 2:713844a55c4e 200 void TFT::pixel(int x, int y, unsigned short color)
Geremia 2:713844a55c4e 201 {
Geremia 10:668cf78ff93a 202 if(usefastwindow) //ili9486 does not like truncated 2A/2B cmds, at least in par mode
Geremia 10:668cf78ff93a 203 {
Geremia 10:668cf78ff93a 204 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 10:668cf78ff93a 205 {
Geremia 10:668cf78ff93a 206 wr_cmd8(0x2A);
Geremia 10:668cf78ff93a 207 wr_data16(x); //start column only
Geremia 10:668cf78ff93a 208 wr_cmd8(0x2B);
Geremia 10:668cf78ff93a 209 wr_data16(y); //start page only
Geremia 10:668cf78ff93a 210 wr_cmd8(0x2C); //write mem, just send pixels color next
Geremia 10:668cf78ff93a 211 }
Geremia 10:668cf78ff93a 212 else
Geremia 10:668cf78ff93a 213 {
Geremia 10:668cf78ff93a 214 window(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 10:668cf78ff93a 215 fastwindowready=true;
Geremia 10:668cf78ff93a 216 }
Geremia 10:668cf78ff93a 217 }
Geremia 10:668cf78ff93a 218 else window(x,y,1,1);
Geremia 4:12ba0ecc2c1f 219 // proto->wr_gram(color); // 2C expects 16bit parameters
Geremia 4:12ba0ecc2c1f 220 wr_gram(color);
Geremia 2:713844a55c4e 221 }
Geremia 5:b222a9461d6b 222 unsigned short TFT::pixelread(int x, int y)
Geremia 5:b222a9461d6b 223 {
Geremia 10:668cf78ff93a 224 if(usefastwindow) //ili9486 does not like truncated 2A/2B cmds, at least in par mode
Geremia 10:668cf78ff93a 225 {
Geremia 10:668cf78ff93a 226 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 10:668cf78ff93a 227 {
Geremia 10:668cf78ff93a 228 wr_cmd8(0x2A);
Geremia 10:668cf78ff93a 229 wr_data16(x); //start column only
Geremia 10:668cf78ff93a 230 wr_cmd8(0x2B);
Geremia 10:668cf78ff93a 231 wr_data16(y); //start page only
Geremia 10:668cf78ff93a 232 wr_cmd8(0x2E); //read mem, just pixelread next
Geremia 10:668cf78ff93a 233 }
Geremia 10:668cf78ff93a 234 else
Geremia 10:668cf78ff93a 235 {
Geremia 10:668cf78ff93a 236 window4read(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 10:668cf78ff93a 237 fastwindowready=true;
Geremia 10:668cf78ff93a 238 }
Geremia 10:668cf78ff93a 239 }
Geremia 10:668cf78ff93a 240 else window4read(x,y,1,1);
Geremia 10:668cf78ff93a 241
Geremia 5:b222a9461d6b 242 unsigned short color;
Geremia 5:b222a9461d6b 243 // proto->wr_gram(color); // 2C expects 16bit parameters
Geremia 5:b222a9461d6b 244 color = rd_gram();
Geremia 11:b842b8e332cb 245 if(isBGR) color = BGR2RGB(color); // in case, convert BGR to RGB (should depend on cmd36 bit3) but maybe is device specific
Geremia 5:b222a9461d6b 246 return color;
Geremia 5:b222a9461d6b 247 }
Geremia 7:bb0383b91104 248 void TFT::setscrollarea (int startY, int areasize) // ie 0,480 for whole screen
Geremia 7:bb0383b91104 249 {
Geremia 7:bb0383b91104 250 unsigned int bfa;
Geremia 7:bb0383b91104 251 topfixedareasize=startY;
Geremia 7:bb0383b91104 252 scrollareasize=areasize;
Geremia 7:bb0383b91104 253 wr_cmd8(0x33);
Geremia 7:bb0383b91104 254 wr_data16(topfixedareasize); //num lines of top fixed area
Geremia 7:bb0383b91104 255 wr_data16(scrollareasize+scrollbugfix); //num lines of vertical scroll area, +1 for ILI9481 fix
Geremia 8:26757296c79d 256 if((areasize+startY)>screensize_Y) bfa=0;
Geremia 8:26757296c79d 257 else bfa = screensize_Y-(areasize+startY);
Geremia 7:bb0383b91104 258 wr_data16(bfa); //num lines of bottom fixed area
Geremia 7:bb0383b91104 259 }
Geremia 7:bb0383b91104 260 void TFT::scroll (int lines) // ie 1= scrollup 1, 479= scrolldown 1
Geremia 7:bb0383b91104 261 {
Geremia 7:bb0383b91104 262 wr_cmd8(0x37);
Geremia 8:26757296c79d 263 wr_data16(topfixedareasize+(lines%scrollareasize)); // select the (absolute)line which will be displayed as first scrollarea line
Geremia 7:bb0383b91104 264 }
Geremia 7:bb0383b91104 265 void TFT::scrollreset()
Geremia 7:bb0383b91104 266 {
Geremia 7:bb0383b91104 267 wr_cmd8(0x13); //normal display mode
Geremia 7:bb0383b91104 268 }
Geremia 2:713844a55c4e 269 void TFT::cls (void)
Geremia 2:713844a55c4e 270 {
Geremia 2:713844a55c4e 271 WindowMax();
Geremia 7:bb0383b91104 272 // proto->wr_gram(_background,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 273 // proto->wr_gram(0,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 274 wr_gram(_background,screensize_X*screensize_Y);
Geremia 7:bb0383b91104 275 }
Geremia 11:b842b8e332cb 276 // try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR
Geremia 11:b842b8e332cb 277 void TFT::auto_gram_read_format()
Geremia 11:b842b8e332cb 278 {
Geremia 11:b842b8e332cb 279 unsigned short px=0xCDB1;
Geremia 11:b842b8e332cb 280 unsigned short rback, rback18;
Geremia 11:b842b8e332cb 281 pixel(0,0,px);
Geremia 11:b842b8e332cb 282 window4read(0,0,1,1);
Geremia 11:b842b8e332cb 283 rback=proto->rd_gram(0); // try 16bit
Geremia 11:b842b8e332cb 284 window4read(0,0,1,1);
Geremia 11:b842b8e332cb 285 rback18=proto->rd_gram(1); // try 18bit converted to 16
Geremia 11:b842b8e332cb 286 if((rback18==px) || (BGR2RGB(rback18)==px))
Geremia 11:b842b8e332cb 287 {
Geremia 11:b842b8e332cb 288 is18bit=true;
Geremia 11:b842b8e332cb 289 if(BGR2RGB(rback18)==px) isBGR=true;
Geremia 11:b842b8e332cb 290 }
Geremia 11:b842b8e332cb 291 else if((rback==px) || (BGR2RGB(rback)==px))
Geremia 11:b842b8e332cb 292 {
Geremia 11:b842b8e332cb 293 if(BGR2RGB(rback)==px) isBGR=true;
Geremia 11:b842b8e332cb 294 }
Geremia 20:14daa48ffd4c 295 // debug("\r\nIdentify gram read color format,\r\nsent %.4X read16 %.4X(bgr%.4X) read18 %.4X(bgr%.4X)", px, rback, BGR2RGB(rback), rback18, BGR2RGB(rback18));
Geremia 11:b842b8e332cb 296 }
Geremia 7:bb0383b91104 297 // try to identify display controller
Geremia 7:bb0383b91104 298 void TFT::identify()
Geremia 7:bb0383b91104 299 {
Geremia 7:bb0383b91104 300 // MIPI std read ID cmd
Geremia 7:bb0383b91104 301 tftID=rd_reg_data32(0xBF);
Geremia 7:bb0383b91104 302 mipistd=true;
Geremia 7:bb0383b91104 303 // debug("ID MIPI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 304 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 305 {
Geremia 7:bb0383b91104 306 mipistd=false;
Geremia 7:bb0383b91104 307 // ILI specfic read ID cmd
Geremia 7:bb0383b91104 308 tftID=rd_reg_data32(0xD3)>>8;
Geremia 7:bb0383b91104 309 // debug("ID ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 310 }
Geremia 7:bb0383b91104 311 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 312 {
Geremia 7:bb0383b91104 313 // ILI specfic read ID cmd with ili9341 specific spi read-in enable 0xD9 cmd
Geremia 7:bb0383b91104 314 tftID=rd_extcreg_data32(0xD3, 0xD9);
Geremia 7:bb0383b91104 315 // debug("ID D9 extc ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 316 }
Geremia 7:bb0383b91104 317 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF)))
Geremia 7:bb0383b91104 318 {
Geremia 7:bb0383b91104 319 // ILI specfic read ID cmd with ili9486/88 specific spi read-in enable 0xFB cmd
Geremia 7:bb0383b91104 320 tftID=rd_extcreg_data32(0xD3, 0xFB);
Geremia 7:bb0383b91104 321 // debug("ID D9 extc ILI : 0x%8X\r\n",tftID);
Geremia 7:bb0383b91104 322 }
Geremia 7:bb0383b91104 323 if(((tftID&0xFF)==((tftID>>8)&0xFF)) && ((tftID&0xFF)==((tftID>>16)&0xFF))) tftID=0xDEAD;
Geremia 7:bb0383b91104 324 if ((tftID&0xFFFF)==0x9481) scrollbugfix=1;
Geremia 7:bb0383b91104 325 else scrollbugfix=0;
Geremia 7:bb0383b91104 326 hw_reset(); // in case wrong cmds messed up important settings
Geremia 7:bb0383b91104 327 }
Geremia 7:bb0383b91104 328 int TFT::sizeX()
Geremia 7:bb0383b91104 329 {
Geremia 7:bb0383b91104 330 return screensize_X;
Geremia 7:bb0383b91104 331 }
Geremia 7:bb0383b91104 332 int TFT::sizeY()
Geremia 7:bb0383b91104 333 {
Geremia 7:bb0383b91104 334 return screensize_Y;
Geremia 2:713844a55c4e 335 }