Sample program to use ILI9225_TFT library

Dependencies:   ILI9225_SPI_TFT mbed

ILI9225 SPI TFT sample code

/media/uploads/Arman92/sss.jpg /media/uploads/Arman92/ssss.jpg

This program uses ILI9225_SPI_TFT to drive a ILI9225 TFT LCD, with supporting Persian language as an extra feature.

include the mbed library with this snippet

#include "mbed.h"


const unsigned char str[] =
{
	0x28, 0x06, 0x47, 0x06, 0x20, 0x00, 0x46, 0x06, 0x27, 0x06, 0x45, 0x06, 0x20, 0x00,
	0x2E, 0x06, 0x2F, 0x06, 0x27, 0x06, 0x00
};  // A unicode string, each unicode char divided to 2 bytes, for Persian language support

int main()
{
	TFT_22_ILI9225 tft(PB_13, PB_14, PB_15, SPI_MOSI, SPI_SCK, PB_1); // RST,  RS,  CS, SDI (MOSI), CLK (SCK), LED

        tft.begin();

	tft.fill(COLOR_BLACK);  // Setting LCD background
	tft.setFontColor(COLOR_BLUEVIOLET); // Setting Font color
	tft.setFontEffect(2); // Setting font effect (Only for persian language)
	tft.goToXY(0, 16 * 0);

	tft.setOrientation(1); // Setting orientation to portrait
	tft.unicode2ascii((char *)str, lcd_buf);  // Converting Unicode to 
	tft.putMixedEnAndFaString((unsigned char*)lcd_buf, 3);  // Printing Persian string

	tft.roundRectangle(10, 16 * 4 - 5, tft.maxX() - 10, 16*4 + 40, 20, true, COLOR_LIGHTBLUE);
	tft.goToXY(30, 16 * 4);
	char *ss = "سلام"; // Printing Arabic String, Persian characters such as ی will not be shown correcty
	tft.putMixedEnAndFaString((unsigned char *)ss, 2);

        wait(2);


	tft.drawRectangle(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_WHITE);
	tft.setFont(Terminal6x8);
	tft.drawText(10, 10, "hello!");
	wait_ms(1000);

	tft.clear();
	tft.drawText(10, 20, "clear");
	wait_ms(1000);

	tft.drawText(10, 30, "text small");
	tft.setBackgroundColor(COLOR_YELLOW);
	tft.setFont(Terminal11x16);
	tft.drawText(90, 30, "BIG", COLOR_RED);
	tft.setBackgroundColor(COLOR_BLACK);
	tft.setFont(Terminal6x8);
	wait_ms(1000);

	tft.drawText(10, 40, "setBacklight off");
	wait_ms(500);
	tft.setBacklight(false);
	wait_ms(500);
	tft.setBacklight(true);
	tft.drawText(10, 50, "setBacklight on");
	wait_ms(1000);

	tft.drawRectangle(10, 10, 110, 110, COLOR_BLUE);
	tft.drawText(10, 60, "rectangle");
	wait_ms(1000);

	tft.fillRectangle(20, 20, 120, 120, COLOR_RED);
	tft.drawText(10, 70, "solidRectangle");
	wait_ms(1000);

	tft.drawCircle(80, 80, 50, COLOR_YELLOW);
	tft.drawText(10, 80, "circle");
	wait_ms(1000);

	tft.fillCircle(90, 90, 30, COLOR_GREEN);
	tft.drawText(10, 90, "solidCircle");
	wait_ms(1000);

	tft.drawLine(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_CYAN);
	tft.drawText(10, 100, "line");
	wait_ms(1000);

	for (uint8_t i = 0; i < 4; i++) { // Changing orientation and drawing the same objects again
		tft.clear();
		tft.setOrientation(i);
		tft.drawRectangle(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_WHITE);
		tft.drawRectangle(10, 20, 50, 60, COLOR_GREEN);
		tft.drawCircle(70, 80, 10, COLOR_BLUE);
		tft.drawLine(30, 40, 70, 80, COLOR_YELLOW);
		wait_ms(1000);
	}

        tft.setOrientation(0);
	tft.clear();
	tft.setFont(Terminal12x16);
	tft.setBackgroundColor(COLOR_YELLOW);
	tft.drawText(10, 40, "bye!", COLOR_RED);
	tft.setBackgroundColor(COLOR_BLACK);
	tft.setFont(Terminal12x16);
	wait_ms(1000);

	tft.drawText(10, 60, "off");
	wait_ms(1000);

	tft.setBacklight(false);
	tft.setDisplay(false);

}
Download repository: zip gz

Files at revision 0:d1e956d0dce6

Name Size Actions
[up]
ILI9225_TFT.lib 76 Revisions Annotate
main.cpp 3530 Revisions Annotate
mbed.bld 65 Revisions Annotate