TFT LCD 2.8″ 240×320 RGB SPI Display with Touchscreen
-
RM55.00
- Product Code: TFT2.9
- Availability: In Stock
Description:
This 2.8″ TFT LCD is a full color display with a resolution of 240 x 320 pixels or 320 x 240 pixels depending on how it is oriented. It uses the ILI9341 controller with SPI interface. It also includes a resistive touchscreen with built-in XPT2046 controller.
Same as our 3.2″ version, just a little smaller and a little less expensive.
Package includes:
Key features:
These full color displays are large enough for many applications even when using touch. The supplied stylus is helpful when using smaller touch targets.
The modules have an SD card socket. This socket has separate connections to the opposite end of the board.
Internally the display operates at 3.3V, so if using with a 5V microcontroller, be sure to include logic level shifters on the data lines to prevent possible damage.
The module power comes in on the Vcc pin. The module includes an on-board 3.3V regulator, so the module should normally be operated off of 3.6 to 5.5V power on this pin to feed the regulator. Current is typically 55-60mA
If you would prefer to operate the module directly from a 3.3V power source, there are two solder pads labeled J1. By solder shorting these two pads together, the regulator is bypassed and the module can be powered directly from 3.3V.
In general, it is best to operate the display off of 5V to ensure enough power is available. Be careful of trying to operate the display from the built-in 3.3V available on Arduino and similar microcontrollers since these power sources often have limited current capability and may overheat.
This display incorporates the SPI interface which provides for fast display updates. It is a 4-wire interface so includes a CS (Chip Select).
The touch screen also uses the SPI interface and can hook up to the same pins as the display. It does use a separate CS to avoid conflict.
For best performance a hardware SPI interface should be used if possible to get the fastest screen updates.
The display can be rotated in all 4 directions. Use setRotation(n) to rotate the image to match the physical rotation where n ranges from 0 to 3.
You will also need to set the rotation of the touch screen. The number do not match, so use one of the following combinations.
ILI9341 Display | XPT2046 Touchscreen |
0 | 2 |
1 | 3 |
2 | 0 |
3 | 1 |
The SD card socket comes out to solder pads on the opposite end of the module. There are reports of this socket not working without modification.
If you plan to use this socket, you should take a look at this thread on the Teensy forums about possible modifications that may be required.
Connect the SPI and control lines for the display. In our example we are using hardware SPI as it gives the best performance. The SPI pin location will depend on the MCU you are using.
Connect the touchscreen. The SPI pins are connected to the same pins as the display SPI. The CS pin has to be unique.
Remember: If you are using a 3.3V MCU, these lines can be connected directly. If you are using a 5V MCU, then be sure to use a logic level converter like shown at the bottom of the page.
/* Exercise the 240x360 ILI9341 TFT LCD with touch Based loosely on Adafruit mandelbrot example */ #include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h" #include "XPT2046_Touchscreen.h" #define TFT_CS 10 #define TFT_DC 9 #define TOUCH_CS 8 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); XPT2046_Touchscreen ts(TOUCH_CS); const int16_t bits = 12, // Fractional resolution pixelWidth = 320, // TFT dimensions pixelHeight = 240, iterations = 30; // Fractal iteration limit or 'dwell' float centerReal = -0.6, // Image center point in complex plane centerImag = 0.0, rangeReal = 3.0, // Image coverage in complex plane rangeImag = 3.0; boolean istouched = false; //=============================================================================== // Initialization //=============================================================================== void setup(void) { Serial.begin(115200); Serial.println("Mandelbrot - tap screen to increase zoom"); tft.begin(); // Init TFT LCD screen tft.setRotation(1); tft.fillScreen(ILI9341_BLACK); ts.begin(); // Init Touch ts.setRotation(3); } //=============================================================================== // Main //=============================================================================== void loop() { int64_t n, a, b, a2, b2, posReal, posImag; uint32_t startTime,elapsedTime; int32_t startReal = (int64_t)((centerReal - rangeReal * 0.5) * (float)(1 << bits)), startImag = (int64_t)((centerImag + rangeImag * 0.5) * (float)(1 << bits)), incReal = (int64_t)((rangeReal / (float)pixelWidth) * (float)(1 << bits)), incImag = (int64_t)((rangeImag / (float)pixelHeight) * (float)(1 << bits)); startTime = millis(); // Calculate how long it takes to create image posImag = startImag; for (int y = 0; y < pixelHeight; y++) { posReal = startReal; for (int x = 0; x < pixelWidth; x++) { a = posReal; b = posImag; for (n = iterations; n > 0 ; n--) { a2 = (a * a) >> bits; b2 = (b * b) >> bits; if ((a2 + b2) >= (4 << bits)) break; b = posImag + ((a * b) >> (bits - 1)); a = posReal + a2 - b2; } tft.drawPixel(x, y, (n * 29)<<8 | (n * 67)); // Change 29/67 to affect colors posReal += incReal; } posImag -= incImag; } elapsedTime = millis()-startTime; Serial.print("Took "); Serial.print(elapsedTime/1000.0); Serial.println(" secs"); tft.setCursor(2, 10); tft.setTextColor(ILI9341_RED); tft.setTextSize(2); tft.print("Pass Complete: "); tft.println(rangeReal); while (istouched == false) {// When drawing complete, wait for touch istouched = ts.touched(); } if (istouched) { tft.fillScreen(ILI9341_BLACK); // Blank screen TS_Point p = ts.getPoint(); // Send touch info out to serial monitor Serial.print("Pressure = "); Serial.print(p.z); Serial.print(", x = "); Serial.print(p.x); Serial.print(", y = "); Serial.println(p.y); rangeReal *= 0.90; // Zoom in each iteration rangeImag *= 0.90; istouched = false; // Reset touch flag if (rangeReal < 1.3) { // Reset the zoom rangeReal = 3.0; rangeImag = 3.0; } }
}