I'm working with a TFT LCD 2.8" 240x320px with SD card reader (SPI) and an Arduino Uno. The display uses the ILI9341 driver. I am also using the URTouch library for the touchscreen functionality.
Here’s the code I’m using:
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "URTouch.h"
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
#define TFT_MISO 12
#define TFT_MOSI 11
#define TFT_CLK 13
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
#define t_SCK 3
#define t_CS 4
#define t_MOSI 5
#define t_MISO 6
#define t_IRQ 7
URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
void setup() {
Serial.begin(9600); // Start serial communication for debugging
tft.begin();
tft.setRotation(0);
Serial.println("Starting ILI9341 Diagnostics:");
uint8_t x = tft.readcommand8(ILI9341_RDMODE); // Example diagnostic command
Serial.print("Read Mode: 0x"); Serial.println(x, HEX);
ts.InitTouch();
ts.setPrecision(PREC_EXTREME);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_PURPLE);
tft.setTextSize(2);
tft.setCursor(85, 5);
tft.print("Touch Demo");
}
void loop() {
int x, y;
while(ts.dataAvailable()) {
ts.read();
x = ts.getX();
y = ts.getY();
if((x != -1) && (y != -1)) {
x += 13;
y += 4;
int radius = 4;
tft.fillCircle(x, y, radius, ILI9341_YELLOW);
}
}
}
The issue is that the display doesn’t seem to use the full screen. The text and graphics are limited to a smaller portion of the display. I’ve tried adjusting the setRotation() and recalibrating the touchscreen, but it didn’t help.
Could anyone guide me on:
- Why the display isn’t utilizing the full 240x320 resolution?
- If there are specific settings I need to configure for the ILI9341 driver or the URTouch library?
Thanks in advance for any insights or suggestions!
