Playing with pixels – Arduino and the T6963c
The weather here in the UK has been pretty miserable this weekend, and rather than cycle about in it, I decided to stay in and tackle a project I’ve been meaning to get on with for a while; getting to grips with using graphic LCD displays. So this Saturday has been spent looking at how to get the very nicely featured arduino-t6963c library to do the business with this nice 240×128 graphic LCD you can see below, drawing text, bitmaps, graphic functions and even animations!
To start off with, this is a panel manufactured by a company called FORDATA. Basic specs are:
- 240 pixels wide, 128 pixels tall
- Panel is blue, with active pixels appearing white (Negative Transmissive polarization) (white back-light)
- LED Back-light, just feed 5V DC, on-board current limiting resistor.
- Built in negative voltage source for contrast driving (more on this later).
and the golden bit:
- Controller Type: T6963C
Before this project, the only displays I had ever driven were simple 16×2 character displays. There is a lot of stuff out there on the web showing how to get up and running with these displays, a lot more than there is on graphic LCDs! This is probably in part due to the fact that there are far fewer configurations of character displays, where as there are 101 varieties of graphic LCD that I’ve seen so far.
That being said, it is really only mildly more complex to get up and running with one of these panels, and really worth the effort if you are going for a project that requires user interaction!
So let’s look at the setup used here:
Firstly, you’ll need an Arduino-compatible board. (for reference, I’m using a hand-built ATMEGA 328 board and Arduino 1.0 on OSX).
|Display Pin||Name||Arduino Pin (168/328)||Arduino Pin (MEGA)||Notes|
|1||Vee||N/C||N/C||Negative Voltage Source|
|2||Vss||0V / GND||0V / GND|
|9||/RST||/RESET||/RESET||Reset Pin Tied to Arduino|
|19||LED+||+5V||+5V||LED back-light Anode|
|20||LED-||0V / GND||0V / GND||LED back-light Cathode|
The setup eats pretty much all the available I/O on a 28 pin 168/328, but it does leave the hardware SPI and I2C interfaces free, so it’s not such a big deal thankfully. (Next step I’m going on to will involve the addition of a SPI radio module, allowing the screen to be used as a remote info display for my PC.)
Take a visit to the Google Code repository for the t6963c library, and grab the file “T6963_Lib.zip” and if you’ve got access to a Windows machine, you can have some fun with animations later if you grab “bmp2c.zip” also. I’ve not yet got round to playing with the font creation utility listed there, but I plan to in another post.
Extract the t6963 library folder into your Arduino library collection, but before launching the IDE, open the files T6963.h & T6963.cpp with a notepad utility. Look for the line [#include “WProgram.h] in each file, and replace it with [#include “Arduino.h“]. This will stop some compile errors caused when the library looks for an old pre-Arduino1.0 pin definition file.
Within the library folder for the t6963, there is an example folder. The contained sketch for 240 x 128 compiled and ran first time on the target board, resulting in the 2nd photo seen in this post.
Also available from the Google Code repository is a nice little utility called GLCD Test-Env. This utility allows you to take fonts installed on your windows system, and convert them into the required C files needed for the library to use with the LCD.glcd_print1_P() and LCD.glcd_print2_P() functions.
I need to get a good deal of screenshots from my Windows machine to demonstrate this, but long story short is that you use your image editor of choice (I use the online pixlr editor) to generate a multi-layer animation, resolution should be a 1:1 pixel mapping of your display. Then bounce each layer down to a monochrome bitmap using mspaint (or other, Pixlr doesn’t have this option unfortunately!), and process each slice using bmp2c, and stitch the .c output of each slice into a larger .c file, and edit the accompanying .h file to reflect the additional slices.
Soon I’ll do a quick how-to for animations, but for now, here’s a quick video of a logo/boot-screen type thing. This took about an hour, learning along the way, I’m sure it could be made a lot faster with some clever scripting?