I have just finished a modified version of Henning Karlsen's marvelous UTFT library which has been optimized for the Arduino Due running a 3.2" TFT touch screen (popular/cheap on ebay) driven by the SSD1289 chipset (same as ITDB32S mode in the original library). The results for the example library UTFT_Demo_320x240 compiled under IDE=1.5.1r2
original UTFT dueSSD1289 version
Compile Time 25 Sec 20 Sec
Code Size 42,096 29,848
Run time 26673 mSec 25766 mSec
The faster compile time is cool, and there is a slight (3% ish) speed increase but the big win is the code saving of about 12k. I know the Due has plenty anyway, but this was part of an exercise in getting to grips with library / device driver writing and learning about the ARM Cortex at low-level.
None of the above means there is anything "wrong" with the UTFT library - far from it - it's actually pretty damn good: it "just works"! And it "just works" on pretty much any sort of display you can think of running on Uno, Mega, Due and more. All in all its quite a feat of software engineering, so my heavily hacked and badly mauled version stands on the the shoulders of giants. That flexibility comes at a price though...there is a lot of code / compiler directives purely to cope with making it fit all tastes. My own taste is for lean/mean. so the clever stuff had to go...
It has been a very interesting exercise and I have learned a lot - I even put in some ARM Cortex inline assembler while "bit banging" the low-level interface which I was pretty pleased with since its my first ever attempt at it. Whoever designed the Mega / Due / TFT shield pinouts...see me after class. I want some of what you were all smoking! We need to manipulate FOUR ports to get our 16 bits of data out, in the delightful(?) H->L order of:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (output bit posn)
D6,D3,D2,D1,D0,A15,A14,B26,D9,A7,D10,C1,C2,C3,C4,C5 (putput Port/pin)
sheesh! There's logic in there somewhere I guess, but the original library resorts to 16 separate bit mask / shift operations (1 per bit). I managed to cut it down with a nifty assembler trick, but it was an exercise in masochism!
1. Henning is a very decent chap. I had a problem with my Sainsmart Mega Shield (it worked perfectly on my Mega, but stared blankly from my Due). I emailed Henning, not expecting a reply...and got one within hours suggesting the 3.3v levels on the Due might be taxing the sainsmart beyond its cheap capabilities. He recommended the itead studio version, which I bought on his advice and - hey presto - its works perfectly on both the Due and the Mega - thanks Henning!
2. I read the SSD1289 datasheet till my eyes bled - and I still don't understand a lot of it, especially the seriously low-level timing stuff. By a process of trial-and-error, I managed top ge the the init code register initialization down to only a handful of lines:
I can feel howls of derision coming on and tales of exploding TFTs or power supplies...all I can tell you is it works just fine for my setup!
3. I plan to add some features to manage the "Split Screen" / "window in window" / "unused zone" features that I found in the datasheet. Lord knows if they will ever be of any practical use, but I'm sure it will keep me busy for weeks! I will let you know how I get on.
Happy to answer any queries on any aspect of this