.

Committer:
dreschpe
Date:
Sun Oct 18 13:53:20 2015 +0000
Revision:
25:daacdcf34e52
Parent:
21:ae0a4eedfc90
Child:
27:acb2594b8aa4
Add check if platform supports par port mode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 20:14daa48ffd4c 1 /* mbed UniGraphic library - custom TFT driver class, ILI932x specific
Geremia 20:14daa48ffd4c 2 * Copyright (c) 2015 Giuliano Dianda
Geremia 20:14daa48ffd4c 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 20:14daa48ffd4c 4 */
Geremia 20:14daa48ffd4c 5
Geremia 20:14daa48ffd4c 6 #include "TFT932x.h"
Geremia 20:14daa48ffd4c 7
Geremia 20:14daa48ffd4c 8 //#include "mbed_debug.h"
Geremia 20:14daa48ffd4c 9
Geremia 20:14daa48ffd4c 10 #define SWAP(a, b) { a ^= b; b ^= a; a ^= b; }
Geremia 20:14daa48ffd4c 11
dreschpe 25:daacdcf34e52 12 #if DEVICE_PORTINOUT
Geremia 20:14daa48ffd4c 13 TFT932x::TFT932x(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 20:14daa48ffd4c 14 : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y)
Geremia 20:14daa48ffd4c 15 {
Geremia 20:14daa48ffd4c 16 if(displayproto==PAR_8)
Geremia 20:14daa48ffd4c 17 {
Geremia 20:14daa48ffd4c 18 proto = new PAR8(port, CS, reset, DC, WR, RD);
Geremia 20:14daa48ffd4c 19 dummycycles=1;
Geremia 20:14daa48ffd4c 20 }
Geremia 20:14daa48ffd4c 21 else if(displayproto==PAR_16)
Geremia 20:14daa48ffd4c 22 {
Geremia 20:14daa48ffd4c 23 proto = new PAR16(port, CS, reset, DC, WR, RD);
Geremia 20:14daa48ffd4c 24 dummycycles=0;
Geremia 20:14daa48ffd4c 25 }
Geremia 20:14daa48ffd4c 26 // set_orientation(0);
Geremia 20:14daa48ffd4c 27 foreground(White);
Geremia 20:14daa48ffd4c 28 background(Black);
Geremia 20:14daa48ffd4c 29 set_auto_up(false); //we don't have framebuffer
Geremia 20:14daa48ffd4c 30 usefastwindow=false;
Geremia 20:14daa48ffd4c 31 fastwindowready=false;
Geremia 20:14daa48ffd4c 32 is18bit=false;
Geremia 20:14daa48ffd4c 33 isBGR=false;
Geremia 20:14daa48ffd4c 34 // cls();
Geremia 20:14daa48ffd4c 35 // locate(0,0);
Geremia 20:14daa48ffd4c 36 }
dreschpe 25:daacdcf34e52 37 #endif
Geremia 21:ae0a4eedfc90 38 TFT932x::TFT932x(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const int lcdsize_x, const int lcdsize_y, const char *name)
Geremia 21:ae0a4eedfc90 39 : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y)
Geremia 21:ae0a4eedfc90 40 {
Geremia 21:ae0a4eedfc90 41 if(displayproto==BUS_8)
Geremia 21:ae0a4eedfc90 42 {
Geremia 21:ae0a4eedfc90 43 PinName pins[16];
Geremia 21:ae0a4eedfc90 44 for(int i=0; i<16; i++) pins[i]=NC;
Geremia 21:ae0a4eedfc90 45 for(int i=0; i<8; i++) pins[i]=buspins[i];
Geremia 21:ae0a4eedfc90 46 proto = new BUS8(pins, CS, reset, DC, WR, RD);
Geremia 21:ae0a4eedfc90 47 dummycycles=1;
Geremia 21:ae0a4eedfc90 48 }
Geremia 21:ae0a4eedfc90 49 else if(displayproto==BUS_16)
Geremia 21:ae0a4eedfc90 50 {
Geremia 21:ae0a4eedfc90 51 proto = new BUS16(buspins, CS, reset, DC, WR, RD);
Geremia 21:ae0a4eedfc90 52 dummycycles=0;
Geremia 21:ae0a4eedfc90 53 }
Geremia 21:ae0a4eedfc90 54 // set_orientation(0);
Geremia 21:ae0a4eedfc90 55 foreground(White);
Geremia 21:ae0a4eedfc90 56 background(Black);
Geremia 21:ae0a4eedfc90 57 set_auto_up(false); //we don't have framebuffer
Geremia 21:ae0a4eedfc90 58 usefastwindow=false;
Geremia 21:ae0a4eedfc90 59 fastwindowready=false;
Geremia 21:ae0a4eedfc90 60 is18bit=false;
Geremia 21:ae0a4eedfc90 61 isBGR=false;
Geremia 21:ae0a4eedfc90 62 // cls();
Geremia 21:ae0a4eedfc90 63 // locate(0,0);
Geremia 21:ae0a4eedfc90 64 }
Geremia 20:14daa48ffd4c 65 TFT932x::TFT932x(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, const int lcdsize_x, const int lcdsize_y, const char *name)
Geremia 20:14daa48ffd4c 66 : GraphicsDisplay(name), screensize_X(lcdsize_x), screensize_Y(lcdsize_y)
Geremia 20:14daa48ffd4c 67 {
Geremia 20:14daa48ffd4c 68 if(displayproto==SPI_8)
Geremia 20:14daa48ffd4c 69 {
Geremia 20:14daa48ffd4c 70 proto = new SPI8(Hz, mosi, miso, sclk, CS, reset);
Geremia 20:14daa48ffd4c 71 dummycycles=4;
Geremia 20:14daa48ffd4c 72 }
Geremia 20:14daa48ffd4c 73 else if(displayproto==SPI_16)
Geremia 20:14daa48ffd4c 74 {
Geremia 20:14daa48ffd4c 75 proto = new SPI16(Hz, mosi, miso, sclk, CS, reset);
Geremia 20:14daa48ffd4c 76 dummycycles=2;
Geremia 20:14daa48ffd4c 77 }
Geremia 20:14daa48ffd4c 78 // set_orientation(0);
Geremia 20:14daa48ffd4c 79 foreground(White);
Geremia 20:14daa48ffd4c 80 background(Black);
Geremia 20:14daa48ffd4c 81 set_auto_up(false);
Geremia 20:14daa48ffd4c 82 usefastwindow=false;
Geremia 20:14daa48ffd4c 83 fastwindowready=false;
Geremia 20:14daa48ffd4c 84 is18bit=false;
Geremia 20:14daa48ffd4c 85 isBGR=false;
Geremia 20:14daa48ffd4c 86 // locate(0,0);
Geremia 20:14daa48ffd4c 87 }
Geremia 20:14daa48ffd4c 88 // dummy read needed before read gram
Geremia 20:14daa48ffd4c 89 // read gram protocol function does 1 dymmy read as for MIPI standard, but ILI932x needs more and protocol specific number of cycles
Geremia 20:14daa48ffd4c 90 // for example in spi mode, 5 dummy byte read needed, so for SPI16 2x16bit clocks done here and the 5th dummy will be handled by read gram function
Geremia 20:14daa48ffd4c 91 void TFT932x::dummyread()
Geremia 20:14daa48ffd4c 92 {
Geremia 20:14daa48ffd4c 93 for(unsigned int i=0; i<dummycycles; i++) proto->dummyread();
Geremia 20:14daa48ffd4c 94 }
Geremia 20:14daa48ffd4c 95 void TFT932x::reg_select(unsigned char reg, bool forread)
Geremia 20:14daa48ffd4c 96 {
Geremia 20:14daa48ffd4c 97 proto->reg_select(reg, forread);
Geremia 20:14daa48ffd4c 98 }
Geremia 20:14daa48ffd4c 99 void TFT932x::reg_write(unsigned char reg, unsigned short data)
Geremia 20:14daa48ffd4c 100 {
Geremia 20:14daa48ffd4c 101 proto->reg_write(reg, data);
Geremia 20:14daa48ffd4c 102 }
Geremia 20:14daa48ffd4c 103 unsigned short TFT932x::reg_read(unsigned char reg)
Geremia 20:14daa48ffd4c 104 {
Geremia 20:14daa48ffd4c 105 return proto->reg_read(reg);
Geremia 20:14daa48ffd4c 106 }
Geremia 20:14daa48ffd4c 107 void TFT932x::wr_gram(unsigned short data)
Geremia 20:14daa48ffd4c 108 {
Geremia 20:14daa48ffd4c 109 proto->wr_gram(data);
Geremia 20:14daa48ffd4c 110 }
Geremia 20:14daa48ffd4c 111 void TFT932x::wr_gram(unsigned short data, unsigned int count)
Geremia 20:14daa48ffd4c 112 {
Geremia 20:14daa48ffd4c 113 proto->wr_gram(data, count);
Geremia 20:14daa48ffd4c 114 }
Geremia 20:14daa48ffd4c 115 void TFT932x::wr_grambuf(unsigned short* data, unsigned int lenght)
Geremia 20:14daa48ffd4c 116 {
Geremia 20:14daa48ffd4c 117 proto->wr_grambuf(data, lenght);
Geremia 20:14daa48ffd4c 118 }
Geremia 20:14daa48ffd4c 119 unsigned short TFT932x::rd_gram()
Geremia 20:14daa48ffd4c 120 {
Geremia 20:14daa48ffd4c 121 return proto->rd_gram(is18bit); // protocol will handle 18to16 bit conversion
Geremia 20:14daa48ffd4c 122
Geremia 20:14daa48ffd4c 123 }
Geremia 20:14daa48ffd4c 124 //for TFT, just send data, position counters are in hw
Geremia 20:14daa48ffd4c 125 void TFT932x::window_pushpixel(unsigned short color)
Geremia 20:14daa48ffd4c 126 {
Geremia 20:14daa48ffd4c 127 proto->wr_gram(color);
Geremia 20:14daa48ffd4c 128 }
Geremia 20:14daa48ffd4c 129 void TFT932x::window_pushpixel(unsigned short color, unsigned int count)
Geremia 20:14daa48ffd4c 130 {
Geremia 20:14daa48ffd4c 131 proto->wr_gram(color, count);
Geremia 20:14daa48ffd4c 132 }
Geremia 20:14daa48ffd4c 133 void TFT932x::window_pushpixelbuf(unsigned short* color, unsigned int lenght)
Geremia 20:14daa48ffd4c 134 {
Geremia 20:14daa48ffd4c 135 proto->wr_grambuf(color, lenght);
Geremia 20:14daa48ffd4c 136 }
Geremia 20:14daa48ffd4c 137 void TFT932x::hw_reset()
Geremia 20:14daa48ffd4c 138 {
Geremia 20:14daa48ffd4c 139 proto->hw_reset();
Geremia 20:14daa48ffd4c 140 BusEnable(true);
Geremia 20:14daa48ffd4c 141 }
Geremia 20:14daa48ffd4c 142 void TFT932x::BusEnable(bool enable)
Geremia 20:14daa48ffd4c 143 {
Geremia 20:14daa48ffd4c 144 proto->BusEnable(enable);
Geremia 20:14daa48ffd4c 145 }
Geremia 20:14daa48ffd4c 146 // ILI932x can't rotate in hw (swap raw<->columns) for landscape views,
Geremia 20:14daa48ffd4c 147 // but can change the way address counter is auto incremented/decremented
Geremia 20:14daa48ffd4c 148 void TFT932x::set_orientation(int o)
Geremia 20:14daa48ffd4c 149 {
Geremia 20:14daa48ffd4c 150 // if(orientation == o) return;
Geremia 20:14daa48ffd4c 151 orientation = o;
Geremia 20:14daa48ffd4c 152 switch (orientation)
Geremia 20:14daa48ffd4c 153 // BGR bit set for all modes, seems most TFT are like that, in case override set_orientation() in init
Geremia 20:14daa48ffd4c 154 // ORG bit set for all modes
Geremia 20:14daa48ffd4c 155 {
Geremia 20:14daa48ffd4c 156 case 0:// default, portrait view 0°
Geremia 20:14daa48ffd4c 157 reg_write(0x0001,0x0100); // S720 to S1
Geremia 20:14daa48ffd4c 158 reg_write(0x0060,0xA700); // G320 to G1
Geremia 20:14daa48ffd4c 159 reg_write(0x03, 0x10B0);
Geremia 20:14daa48ffd4c 160 set_width(screensize_X);
Geremia 20:14daa48ffd4c 161 set_height(screensize_Y);
Geremia 20:14daa48ffd4c 162 break;
Geremia 20:14daa48ffd4c 163 case 1:// landscape view +90°
Geremia 20:14daa48ffd4c 164 reg_write(0x0001,0x0000); // S1 to S720
Geremia 20:14daa48ffd4c 165 reg_write(0x0060,0xA700); // G320 to G1
Geremia 20:14daa48ffd4c 166 reg_write(0x03, 0x10B8); // AM=1 increase addr ctr first vertically then horizontally
Geremia 20:14daa48ffd4c 167 set_width(screensize_Y);
Geremia 20:14daa48ffd4c 168 set_height(screensize_X);
Geremia 20:14daa48ffd4c 169 break;
Geremia 20:14daa48ffd4c 170 case 2:// portrait view +180°
Geremia 20:14daa48ffd4c 171 reg_write(0x0001,0x0000); // S1 to S720
Geremia 20:14daa48ffd4c 172 reg_write(0x0060,0x2700); // G1 to G320
Geremia 20:14daa48ffd4c 173 reg_write(0x03, 0x10B0);
Geremia 20:14daa48ffd4c 174 set_width(screensize_X);
Geremia 20:14daa48ffd4c 175 set_height(screensize_Y);
Geremia 20:14daa48ffd4c 176 break;
Geremia 20:14daa48ffd4c 177 case 3:// landscape view -90°
Geremia 20:14daa48ffd4c 178 reg_write(0x0001,0x0100); // S720 to S1
Geremia 20:14daa48ffd4c 179 reg_write(0x0060,0x2700); // G1 to G320
Geremia 20:14daa48ffd4c 180 reg_write(0x03, 0x10B8); // AM=1 increase addr ctr first vertically then horizontally
Geremia 20:14daa48ffd4c 181 set_width(screensize_Y);
Geremia 20:14daa48ffd4c 182 set_height(screensize_X);
Geremia 20:14daa48ffd4c 183 break;
Geremia 20:14daa48ffd4c 184 }
Geremia 20:14daa48ffd4c 185 }
Geremia 20:14daa48ffd4c 186 void TFT932x::invert(unsigned char o)
Geremia 20:14daa48ffd4c 187 {
Geremia 20:14daa48ffd4c 188 unsigned short oldreg = reg_read(0x61);
Geremia 20:14daa48ffd4c 189 if(o == 0) reg_write(0x61, oldreg|1); // seems most TFT have REV bit enabled for normal display
Geremia 20:14daa48ffd4c 190 else reg_write(0x61, oldreg&0xFFFE);
Geremia 20:14daa48ffd4c 191 }
Geremia 20:14daa48ffd4c 192 void TFT932x::FastWindow(bool enable)
Geremia 20:14daa48ffd4c 193 {
Geremia 20:14daa48ffd4c 194 usefastwindow=enable;
Geremia 20:14daa48ffd4c 195 }
Geremia 20:14daa48ffd4c 196 // TFT have both column and raw autoincrement inside a window, with internal counters
Geremia 20:14daa48ffd4c 197 void TFT932x::window(int x, int y, int w, int h)
Geremia 20:14daa48ffd4c 198 {
Geremia 20:14daa48ffd4c 199 if(orientation==1 || orientation==3)
Geremia 20:14daa48ffd4c 200 {
Geremia 20:14daa48ffd4c 201 SWAP(x,y);
Geremia 20:14daa48ffd4c 202 SWAP(w,h);
Geremia 20:14daa48ffd4c 203 }
Geremia 20:14daa48ffd4c 204 fastwindowready=false; // end raw/column going to be set to lower value than bottom-right corner
Geremia 20:14daa48ffd4c 205 reg_write(0x50, x);//start column
Geremia 20:14daa48ffd4c 206 reg_write(0x51, x+w-1);//end column
Geremia 20:14daa48ffd4c 207 reg_write(0x52, y);//start page
Geremia 20:14daa48ffd4c 208 reg_write(0x53, y+h-1);//end page
Geremia 20:14daa48ffd4c 209
Geremia 20:14daa48ffd4c 210 reg_write(0x20, 0); // since ORG bit is set, address is windows relative, so should be set always to 0000
Geremia 20:14daa48ffd4c 211 reg_write(0x21, 0);
Geremia 20:14daa48ffd4c 212
Geremia 20:14daa48ffd4c 213 reg_select(0x22, false); //write mem, just write gram next
Geremia 20:14daa48ffd4c 214 }
Geremia 20:14daa48ffd4c 215 void TFT932x::window4read(int x, int y, int w, int h)
Geremia 20:14daa48ffd4c 216 {
Geremia 20:14daa48ffd4c 217 if(orientation==1 || orientation==3)
Geremia 20:14daa48ffd4c 218 {
Geremia 20:14daa48ffd4c 219 SWAP(x,y);
Geremia 20:14daa48ffd4c 220 SWAP(w,h);
Geremia 20:14daa48ffd4c 221 }
Geremia 20:14daa48ffd4c 222 fastwindowready=false; // end raw/column going to be set to lower value than bottom-right corner
Geremia 20:14daa48ffd4c 223 reg_write(0x50, x);//start column
Geremia 20:14daa48ffd4c 224 reg_write(0x51, x+w-1);//end column
Geremia 20:14daa48ffd4c 225 reg_write(0x52, y);//start page
Geremia 20:14daa48ffd4c 226 reg_write(0x53, y+h-1);//end page
Geremia 20:14daa48ffd4c 227
Geremia 20:14daa48ffd4c 228 reg_write(0x20, 0); // since ORG bit is set, address is windows relative, so should be set always to 0000
Geremia 20:14daa48ffd4c 229 reg_write(0x21, 0);
Geremia 20:14daa48ffd4c 230
Geremia 20:14daa48ffd4c 231 reg_select(0x22, true); //read mem, just read gram next
Geremia 20:14daa48ffd4c 232 dummyread();
Geremia 20:14daa48ffd4c 233 }
Geremia 20:14daa48ffd4c 234 void TFT932x::pixel(int x, int y, unsigned short color)
Geremia 20:14daa48ffd4c 235 {
Geremia 20:14daa48ffd4c 236 if(usefastwindow)
Geremia 20:14daa48ffd4c 237 {
Geremia 20:14daa48ffd4c 238 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 20:14daa48ffd4c 239 {
Geremia 20:14daa48ffd4c 240 if(orientation==1 || orientation==3) SWAP(x,y);
Geremia 20:14daa48ffd4c 241 reg_write(0x50, x);//start column only
Geremia 20:14daa48ffd4c 242 reg_write(0x52, y);//start page only
Geremia 20:14daa48ffd4c 243 reg_write(0x20, 0); // since ORG bit is set, address is window relative, so should be set always to 0000
Geremia 20:14daa48ffd4c 244 reg_write(0x21, 0);
Geremia 20:14daa48ffd4c 245 reg_select(0x22, false); //write mem, just write gram next
Geremia 20:14daa48ffd4c 246 }
Geremia 20:14daa48ffd4c 247 else
Geremia 20:14daa48ffd4c 248 {
Geremia 20:14daa48ffd4c 249 window(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 20:14daa48ffd4c 250 fastwindowready=true;
Geremia 20:14daa48ffd4c 251 }
Geremia 20:14daa48ffd4c 252 }
Geremia 20:14daa48ffd4c 253 else window(x,y,1,1);
Geremia 20:14daa48ffd4c 254 wr_gram(color);
Geremia 20:14daa48ffd4c 255 }
Geremia 20:14daa48ffd4c 256 unsigned short TFT932x::pixelread(int x, int y)
Geremia 20:14daa48ffd4c 257 {
Geremia 20:14daa48ffd4c 258 /* if(usefastwindow) // for ILI9325 fastwindows for reading works only in PAR16
Geremia 20:14daa48ffd4c 259 {
Geremia 20:14daa48ffd4c 260 if(fastwindowready) //setting only start column/page does speedup, but needs end raw/column previously set to bottom-right corner
Geremia 20:14daa48ffd4c 261 {
Geremia 20:14daa48ffd4c 262 if(orientation==1 || orientation==3) SWAP(x,y);
Geremia 20:14daa48ffd4c 263 reg_write(0x50, x);//start column only
Geremia 20:14daa48ffd4c 264 reg_write(0x52, y);//start page only
Geremia 20:14daa48ffd4c 265 reg_write(0x20, 0); // since ORG bit is set, address is window relative, so should be set always to 0000
Geremia 20:14daa48ffd4c 266 reg_write(0x21, 0);
Geremia 20:14daa48ffd4c 267 reg_select(0x22, true); //read mem, just read gram next
Geremia 20:14daa48ffd4c 268 }
Geremia 20:14daa48ffd4c 269 else
Geremia 20:14daa48ffd4c 270 {
Geremia 20:14daa48ffd4c 271 window4read(x,y,width()-x,height()-y); // set also end raw/column to bottom-right corner
Geremia 20:14daa48ffd4c 272 fastwindowready=true;
Geremia 20:14daa48ffd4c 273 }
Geremia 20:14daa48ffd4c 274 }
Geremia 20:14daa48ffd4c 275 else*/
Geremia 20:14daa48ffd4c 276 window4read(x,y,1,1);
Geremia 20:14daa48ffd4c 277
Geremia 20:14daa48ffd4c 278 unsigned short color;
Geremia 20:14daa48ffd4c 279 color = rd_gram();
Geremia 20:14daa48ffd4c 280 if(isBGR) color = BGR2RGB(color); // in case, convert BGR to RGB
Geremia 20:14daa48ffd4c 281 return color;
Geremia 20:14daa48ffd4c 282 }
Geremia 20:14daa48ffd4c 283 void TFT932x::setscrollarea (int startY, int areasize) // ie 0,480 for whole screen
Geremia 20:14daa48ffd4c 284 {
Geremia 20:14daa48ffd4c 285 // ILI932x allows only ful lscreen scrolling
Geremia 20:14daa48ffd4c 286 unsigned short oldreg = reg_read(0x61);
Geremia 20:14daa48ffd4c 287 reg_write(0x61, oldreg|2); // enable scroll
Geremia 20:14daa48ffd4c 288 }
Geremia 20:14daa48ffd4c 289 void TFT932x::scroll (int lines) // ie 1= scrollup 1, 479= scrolldown 1
Geremia 20:14daa48ffd4c 290 {
Geremia 20:14daa48ffd4c 291 reg_write(0x6A, lines%screensize_Y); // select the (absolute)line which will be displayed as first line
Geremia 20:14daa48ffd4c 292 }
Geremia 20:14daa48ffd4c 293 void TFT932x::scrollreset()
Geremia 20:14daa48ffd4c 294 {
Geremia 20:14daa48ffd4c 295 unsigned short oldreg = reg_read(0x61);
Geremia 20:14daa48ffd4c 296 // reg_write(0x61, oldreg&0xFFFD); // disable scroll
Geremia 20:14daa48ffd4c 297 reg_write(0x6A, 0);
Geremia 20:14daa48ffd4c 298 }
Geremia 20:14daa48ffd4c 299 void TFT932x::cls (void)
Geremia 20:14daa48ffd4c 300 {
Geremia 20:14daa48ffd4c 301 WindowMax();
Geremia 20:14daa48ffd4c 302 wr_gram(_background,screensize_X*screensize_Y);
Geremia 20:14daa48ffd4c 303 }
Geremia 20:14daa48ffd4c 304 // try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR
Geremia 20:14daa48ffd4c 305 void TFT932x::auto_gram_read_format()
Geremia 20:14daa48ffd4c 306 {
Geremia 20:14daa48ffd4c 307 unsigned short px=0xCDB1;
Geremia 20:14daa48ffd4c 308 unsigned short rback, rback18;
Geremia 20:14daa48ffd4c 309 pixel(0,0,px);
Geremia 20:14daa48ffd4c 310 window4read(0,0,1,1);
Geremia 20:14daa48ffd4c 311 rback=proto->rd_gram(0); // try 16bit
Geremia 20:14daa48ffd4c 312 window4read(0,0,1,1);
Geremia 20:14daa48ffd4c 313 rback18=proto->rd_gram(1); // try 18bit converted to 16
Geremia 20:14daa48ffd4c 314 if((rback18==px) || (BGR2RGB(rback18)==px))
Geremia 20:14daa48ffd4c 315 {
Geremia 20:14daa48ffd4c 316 is18bit=true;
Geremia 20:14daa48ffd4c 317 if(BGR2RGB(rback18)==px) isBGR=true;
Geremia 20:14daa48ffd4c 318 }
Geremia 20:14daa48ffd4c 319 else if((rback==px) || (BGR2RGB(rback)==px))
Geremia 20:14daa48ffd4c 320 {
Geremia 20:14daa48ffd4c 321 if(BGR2RGB(rback)==px) isBGR=true;
Geremia 20:14daa48ffd4c 322 }
Geremia 20:14daa48ffd4c 323 // 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 20:14daa48ffd4c 324 }
Geremia 20:14daa48ffd4c 325 // try to identify display controller
Geremia 20:14daa48ffd4c 326 void TFT932x::identify()
Geremia 20:14daa48ffd4c 327 {
Geremia 20:14daa48ffd4c 328 tftID = reg_read(0x00);
Geremia 20:14daa48ffd4c 329 hw_reset(); // in case wrong cmd messed up important settings
Geremia 20:14daa48ffd4c 330 }
Geremia 20:14daa48ffd4c 331 int TFT932x::sizeX()
Geremia 20:14daa48ffd4c 332 {
Geremia 20:14daa48ffd4c 333 return screensize_X;
Geremia 20:14daa48ffd4c 334 }
Geremia 20:14daa48ffd4c 335 int TFT932x::sizeY()
Geremia 20:14daa48ffd4c 336 {
Geremia 20:14daa48ffd4c 337 return screensize_Y;
Geremia 20:14daa48ffd4c 338 }