Look at the back of the 2.2inch TFT LCD Display Module Touch Screen Shield from OpenSmart. These are not the same pins we saw with the 2.4inch ILI9341 which followed the MCUFRIEND layout.
Let's go through the pinouts and see what they are. The UART and I2C ports are available and they are wired out to the face of the shield. A few pins are unused. The data leads for the LCD screen are spread about. Schematics say the SPI pins are standard.
When I ordered my board the vendor gave me a link to GoogleDocs where I downloaded a zip file. The Zip file was for more than one product. Inside the ILI9225 shield folder were two arduino libraries for Arduino TouchScreen and UTFT.
Move or copy these two folders into your Arduino libraries folder along with the other libraries.
When you restart your Arduino IDE there will be menus for TouchScreen and UTFT added to your examples. Look inside the examples folder in the library and you will see several TFT screen products are listed.
We go inside the examples folder for our board, the TFT 2.2inch Shield ILI9255. There aren't many.
Let's open the example TFT_2in2_176x220_Demo and compile to make sure everything is working. Error messages do contain useful information about what you have to repair.
Upload the sketch and the Demo program will run on the screen. There are two more example sketches for our shield: TFT_2in2_Show_bmp and TouchScreen_2inch_9225.
Look through the code and see what is there. Try to understand what the functions do and how to use them. Change values and see the effect.
To run TFT_2in2_Show_bmp you will need to prepare an SD card and load a bit map image file.bmp from the library folder.
Basic SketchLet us try another sketch. This one is very basic and you should change parameters around to see what you get. Change colours, change locations.
// Demo of Graphics on OpenSmart ILI9225 2.2inch shield 176x220
// Basic functions to print alphabet and to draw simple shapes
// This program requires the UTFT library 2.78 modified by OpenSmart
#include <UTFT.h>
// fonts are located in the file DefaultFonts.c
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
// DATA0-DATA7 pins on shield are OpenSmart not MCUFRIEND
// #define LCD_CS A3 // Chip Select Analog 3
// #define LCD_RS A2 // Command/Data Analog 2
// #define LCD_WR A1 // LCD Write Analog 1
// UTFT myGLCD(ILI9225,LCD_RS,LCD_WR,LCD_CS); // or use the line below
UTFT myGLCD(ILI9225, A2, A1, A3);
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
}
void loop()
{ while (1) {
myGLCD.setColor(255, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.setFont(BigFont);
myGLCD.clrScr();
myGLCD.print(" !\"#$%&'()*+,-./", CENTER, 0);
myGLCD.print("0123456789:;<=>?", CENTER, 16);
myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 32);
myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 48);
myGLCD.print("`abcdefghijklmno", CENTER, 64);
myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 80);
// delay(300);
delay(100);
// pigment
myGLCD.clrScr();
myGLCD.setBackColor(0, 0, 0);
// colour 1
myGLCD.setColor(0, 255, 255);
delay(100);
myGLCD.fillRect(0, 4, 40, 80);
myGLCD.print(" 0-255-255 ", RIGHT, 30);
delay(200);
// colour 2
myGLCD.setColor(255, 0, 255);
myGLCD.fillCircle(30, 90, 30);
myGLCD.print(" 255-0-255 ", RIGHT, 90);
// colour 3
myGLCD.setColor(255, 255, 0);
myGLCD.fillRoundRect(0, 130, 40, 170);
myGLCD.print(" 255-255-0 ", RIGHT, 150);
delay(2500);
myGLCD.clrScr();
// smallfont
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(0, 0, 0);
// colour 1
myGLCD.setColor(0, 255, 255);
myGLCD.print(" !\"#$%&'()*+,-./0123456789:;<=>?", CENTER, 40);
myGLCD.print("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", CENTER, 102);
myGLCD.print("`abcdefghijklmnopqrstuvwxyz{|}~ ", CENTER, 134);
delay(300);
myGLCD.clrScr();
// primary
myGLCD.clrScr();
myGLCD.setFont(BigFont);
myGLCD.setBackColor(0, 0, 0);
// colour 1
myGLCD.setColor(0, 0, 255);
delay(100);
myGLCD.fillRect(0, 4, 40, 80);
myGLCD.print(" 0-0-255 ", RIGHT, 30);
delay(200);
// colour 2
myGLCD.setColor(255, 0, 0);
myGLCD.fillCircle(30, 90, 30);
myGLCD.print(" 255-0-0 ", RIGHT, 90);
// colour 3
myGLCD.setColor(0, 255, 0);
myGLCD.fillRoundRect(0, 130, 40, 170);
myGLCD.print(" 0-255-0 ", RIGHT, 150);
delay(2500);
myGLCD.clrScr();
}
}
Verify that the sketch compiles. Upload to a board. Modify the sketch: change colours, sizes, locations, timing.
We are using release 2.78 of the UTFT library from 2014. OpenSmart has modified the library to support their boards. That is why they gave me a download.
The UTFT library was produced by Rink Dink Electronics and you can download the latest release 2.83 from 2018. Unfortunately, this version of the library will not work with our board. It does not have files to work with the ILI9225. But we can still use the examples if we modify them.
Open the sketch UTFT_ViewFont and find the constructor. Comment out the line UTFT myGLCD(ITDB32S, 38, 39, 40, 41) because it is for a different display type on a different Arduino board.
We could replace the constructor with a new one
UTFT myGLCD(ILI9225, A2, A1, A3); // OpenSmart 9225 shield
Or this more readable version with several lines. You should understand how these are equivalent.
Repeat with the other examples. Some may not run. Read error messages and learn from them.
Comments