Intro: Arduino - TFT Display of Icons and Images From FLASH Memory
In this Instructable you will find a library and sketch to plot images stored in the Arduino FLASH memory onto a TFT screen.
Here we use my favorite 2.2" 320 x 240 pixel ILI9341 based TFT display. This display is a nice size for Arduino based projects and is available at low cost on eBay.
I have other Instructables on the topic of interfacing with these displays so this one is going to be brief!
Step 1: Connecting Up
Connections between UNO and the display are:
- UNO +5V to display pin 1 (VCC)
- UNO +5V through a 56 Ohm resistor to display pin 8 (LED)
- UNO 0V (GND) to display pin 2 (GND)
- UNO digital pin 7 through a 1K2 resistor to display pin 4 (RESET), add a 1K8 resistor from display pin 4 to GND
- UNO digital pin 9 through a 1K2 resistor to display pin 5(DC/RS), add a 1K8 resistor from display pin 5 to GND
- UNO digital pin 10 through a 1K2 resistor to display pin 3 (CS), add a 1K8 resistor from display pin 3 to GND
- UNO digital pin 11 through a 1K2 resistor to both display pin 6 (MOSI), add a 1K8 resistor from display pin 6 to GND
- UNO digital pin 13 through a 1K2 resistor to display pin 7 (SCK), add a 1K8 resistor from display pin 7 to GND
Other pin outs at the Arduino can be used by adapting the sketch should you have a display from another supplier or wish to use an existing setup.
The connections are compatible with my Instructable here which shows how to plot images pulled off an SD Card.
Step 2: Libraries and Sketch
The sketch to plot the bitmaps is an example in the "Adafruit_ILI9341_AS" library attached.
This library needs the Adafruit_GFX_AS supporting library.
The sketch draws graphical icons to the screen. the icon images are stored in FLASH. You can add your own icon images, commensurate with the available FLASH space, by using the UTFT library utility "ImageConverter565.exe" that is within the UTFT library.
The image pixels are stored in a 16 bit integer array, the array is created by importing a bitmap file of the .bmp type into the ImageConverter565 application and saving as a .c file. The array can then be cut and pasted from the .c file into the "Flash_icons.h" file that is part of the sketch. Take a note of the width and height numbers, add a comment in front of the array.
Look at the example sketch and you will get the idea!