256×320 Colour LCD (5408 driver)

256×320 colour LCD screens are widely and cheaply available and very often come on a board that we can connect up to an Arduino Uno (and some other boards types). It’s then just a simple manner of adding the required libraries and trying out an example. This is all we are planning to do in this article, just to get you going. In other future articles we’ll look at using this screen in our own work and in the other articles we’ll get this screen up and running with other MCU’s such as the Arduino Nano, ESP chips etc.

First let’s look at a typical example purchased cheaply from Ali Express for around the price of a cheap coffee and donut (delivered). This one is based on the 5408 chip. Here’s some photos.

As you can see it’s designed as an Arduino Uno Shield and will slot right on top. So add yours to your Uno and we’ll look at making it doing something.

The Required Libraries
Launch your Arduino IDE and go to Sketch->Include Library->Manage Libraries. The library manager will open, as this screen is based on the 5408 driver chip we need a library that can talk to it, type in 5408 into the search field. You should be left with a an entry that says something like “SPFD 5408 TFT Library”. At time of writing the author is listed as Sadika Sumanapala. Install this. If you’ve not already installed the Adafruit Graphics Library then this will need installing too. Simply type “adafruit gfx” into the search box and install this too if you have not already installed it.

Testing – graphics
Go to “Examples->SPFD 5408 TFT Library->graphics test”, compile and upload and you should get the display appearing below.

Testing – Touchscreen
Another library is required to use the touchscreen, go to the library manager as you have done above and type “touchscreen” into the search box. Install the Adafruit touchscreen. Then go to “Examples->SPFD 5408 TFT Library->tftpaint”, compile and upload and you should get the display appearing earlier (barring the already written “Hello” !). You can now draw on the screen with your finger or any object. You may find the where you press is not exactly where the line appears. This is because these screens often need calibrating for use, there is no built in way with this demo unfortunately to do this, you’d have to got into the code to adjust it. In a future article we’ll look at how to do this.

Testing – SD card
The libraries for reading SD cards are (I think) installed as standard. Load up “Examples->SPFD 5408 TFT Library->tftbmp”, compile and upload. If the compilation does fail because if the lack of an SD library then go through the procedure above for adding an SD card library. You will need to put an image on the SD that is the correct ratio of 320×256 pixels. The file is loaded in the lines using the bmpDraw function, i.e. in the example it uses this line

bmpDraw(“woof.bmp”, 0, 0);   and  bmpDraw(“miniwoof.bmp”, j, j);

The “woof.bmp” is loaded in the setup and the “miniwoof,bmp” in the main loop. For testing purposes I would type return  right at the beginning of the loop function, i.e.

and the “woof.bmp” can be renamed to whatever image name you put into the root of your SD card. The image must be a BMP image (Bit-mapped image) and normally your image will probably be a JPEG (JPG) image. So load it up into any sort of image editing software, re-size the image to 320×256 pixels and then re-save as type BMP. Compile and upload. If the image is not of the correction orientation then add this line

tft.setRotation(1);

just before

bmpDraw(“woof.bmp”, 0, 0);

This will effectively rotate the image. You could rotate it in your image editing software before adding to the SD card if you wished.

That should get you up and running with these screens, why not look at the supplied examples to work out how to add these to your projects.

Next Time
Next time in this series we will connect these screens up to a Nano, till then Happy Hacking!