I purchased a shield with the description 3.5" TFT LCD Shield for Arduino Uno/Mega (ILI9481) recently from here 3.5" TFT LCD Shield for Arduino Uno/Mega (ILI9481) - Electronics Display LCD Graphic - Boxtec Onlineshop.
It is described as having a resolution of 320x420.
I have used the library MCUFRIEND_kbv.h and it generally appears to work using a sketch based on a supplied example for printing text. The problem is only that the sketch reports a display resolution of 240x320 which differs from the advertised specification.
TFT LCD test
Using Adafruit 2.4" TFT Breakout Board Pinout
TFT size is 240x320
Found ILI9481 LCD driver
(ignore the Adafruit 2.4" TFT line)
The obvious conclusion is that there is an error in the specification from the supplier, but could there be another explanation ? 320x420 is anyway an unusual resolution and I am wondering if I can actually get up to 320x480 which the ILI9481 driver appears to support.
/*
// mod fdm use <MCUFRIEND_kbv.h> library
v0.01 initial
v0.02 rotate screen attempt
v0.03 change text to match telephone
v0.04 fonts
to do - rassign reset.
*/
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
//Technical support:goodtft@163.com
#include <Adafruit_GFX.h> // Core graphics library //fdm
//#include <Adafruit_TFTLCD.h> // Hardware-specific library //fdm
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
unsigned int colour[] = { GREEN, CYAN, MAGENTA, YELLOW, WHITE} ;
byte colours = sizeof ( colour ) / sizeof ( colour[0] ) ;
byte currentColour = 0 ;
unsigned int bg = BLACK ;
//fdm - use MCUFriend
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
// Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft; //(fdm)
void setup(void) {
Serial.begin(9600);
Serial.println(F("TFT LCD test"));
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
Serial.println(F("Using Adafruit 2.4\" TFT Arduino Shield Pinout"));
#else
Serial.println(F("Using Adafruit 2.4\" TFT Breakout Board Pinout"));
#endif
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
tft.reset();
uint16_t identifier = tft.readID();
if (identifier == 0x0101)
identifier = 0x9341;
if (identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if (identifier == 0x4535) {
Serial.println(F("Found LGDP4535 LCD driver"));
} else if (identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if (identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if (identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if (identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else if (identifier == 0x9481) {
Serial.println(F("Found ILI9481 LCD driver"));
}
else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.4\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
return;
}
tft.begin(identifier);
}
void loop(void) {
tft.fillScreen( bg ); // fdm
unsigned long start = micros();
tft.setRotation(1) ; // fdm
tft.setCursor(0, 50);
//tft.setFont();
//tft.setTextColor( colour[currentColour] ); tft.setTextSize(1);
//tft.println(".") ;
tft.setFont(&FreeMonoBold18pt7b);
tft.setTextColor( colour[currentColour] ); tft.setTextSize(2);
tft.println("079") ;
tft.println("123 4567");
//tft.println("") ;
tft.setFont(&FreeMonoBold9pt7b);
tft.setTextColor(colour[currentColour]); tft.setTextSize(2);
tft.println("John Smith & Co.");
tft.println("... but up to 50 ch") ;
tft.setTextColor(colour[currentColour]); tft.setTextSize(2);
tft.println("22.06.2017 18:25");
// tft.println();
// tft.println();
currentColour ++ ;
if ( currentColour == colours ) {
currentColour = 0 ;
// if ( bg == BLACK ) bg = WHITE ;
// else bg = BLACK ;
}
delay(1000); delay(1000); delay(1000); delay(1000); delay(1000);
}
And here is the output from the Read Registers utility:
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)
reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 RDID2 HX8347-G
reg(0x0063) 00 00 RDID3 HX8347-G
reg(0x0064) 00 00 RDID1 HX8347-A
reg(0x0065) 00 00 RDID2 HX8347-A
reg(0x0066) 00 00 RDID3 HX8347-A
reg(0x0067) 00 00 RDID Himax HX8347-A
reg(0x0070) 00 00 Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 00 Inversion Control
reg(0x00B6) 00 00 00 00 00 Display Control
reg(0x00B7) 00 00 Entry Mode Set
reg(0x00BF) 00 02 04 94 81 FF ILI9481, HX8357-B
reg(0x00C0) 00 10 3B 00 02 11 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 43 Power Control
reg(0x00D2) 00 01 22 00 00 NVM Read
reg(0x00D3) 00 01 22 00 ILI9341, ILI9488
reg(0x00D4) 00 01 22 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) 00 00 33 00 00 00 00 00 00 00 00 00 Adjust Control 2
reg(0x00F6) 00 80 80 80 Interface Control