TFT LCD

Updated Version, 6-7-2012

Introduction

You can buy colour displays on eBay with a resolution of 320*240 for as little as 18 dollars nowadays, but when I had purchased one of these I found that the amount of readily available drivers is very small (for pic’s that is). I also had a bit of trouble figuring out how to get images displayed properly (by firstly creating an array of a bitmap). The software to do this also seemed impossible to find (most of the programs I found either didn’t work, or only supported greyscale images).

I therefore decided to rewrite a driver written for mikroBasic to mikroC, which can easily be converted to any specific compiler/language. I also wrote a little C# program to convert bitmaps (and some other common image formats such as jpeg and gif) to the needed 16bit arrays. The last thing that I could not find on the web where some simple examples, so I created 3 mikroC examples that can be downloaded at the bottom of the page (including a game of live simulation, simple function examples and a program to show images from your pc over usb). This download also includes some image arrays ready to use, as well as the C# app and a usb app to display images over usb.

The Hardware

When using a lcd display you really need to know which type of lcd controller it requires. The controller of the lcd display basically determines the type of connection/data transfer and the build in functionality (for example the buffer size, the ability to quickly draw geometric shapes etc). The screen used uses a SSD1289, and can easily be bought on eBay. The particular screen I bought also has a touch screen controller (which is not uncommon since they don’t cost that much and add a lot of functionality), but this touch screen controller is completely separate from the lcd controller (they share the supply lines, but that’s about it). This article wont cover the touch controller.

The SSD1289 has several connection possibilities, but all of the boards on eBay only let you use the 16 bit parallel connection, which is fine most of the time (it does use a lot of pins of course). I use a 18F4550 microcontroller, but any microcontroller with enough spare io pins will do. To wire it up you simply need to connect the power and gnd, connect the lines specified by the driver I rewrote, and supply the backlight with some power.

The Software

The driver is a single file, you can download it at the bottom of this page. Simply include it to use it ( #include “lcddriver.c” ), but don’t try to use the build in mikroC tft library at the same time, since they use the same function names.

I also wrote 3 programs to show what this lcd driver is capable of:

Simple_Functions_Example

This shows all of the functions the library offers, including the drawing of lines, squares, boxes, cirles, images, text etc. Its pretty self explanatory.

Game_Of_Live

A version of John Conway’s famous game of life, with some extra features.

LCD_USB

I wrote a program that receives data from a C# program , which enables you to display images directly from the pc over usb. To get this working please try to get the mikroC usb hid examples working first so that you know that you’ve got a stable usb connection. The C# program uses bitmap arrays that you can create with my program that is also included in the download. To use the C# usb program simply connect the pic to your pc,connect to the pic in the program, set the coordinates and dimensions of the image you want to display and load the array of the image (use an int 8 bit format for this).

The download also includes a folder with some ready made bitmap array’s (it containts 2 folders, one to use for displaying images directly (from say a memory card, or internal rom), and one for the usb program).

A demonstration video

Download

READ THIS BEFORE DOWNLOADING:

I am not responsible for any damage this software or the information on this site may directly or indirectly cause.

Updated Version, 6-7-2012

Download Here

Original MikroBasic Code

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation