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

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:

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!

Further thoughts: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.

posting the code will be tricky as a) i dont have github or sourceforge accounts (yet) and (b) there is way too much to post in text it would bust the forum limit. Also there are files / folders to be removed from the original etc...It's still a "work in progress"

My plan is to get the xtra bits working, do some more testing on it, then maybe post the whole thing as a zip to a public form once its stable...I will keep you informed if / when i do - thanks for your interest - might be useful to have someone else test it (not sure what the rules are here for publishing / exchanging email addresses etc)

Hello,I also have the Sainsmart 3,2" display with the IteadStudio Shield on my Due.

The Display works fine, but i cant get the Touch function to run. Does the Touch feature work on your Due?

When trying to use the UTouch Example "Utouch_ButtonTest" I can see the Buttons on the Display, but the Touch feature doesnt work.According to the Pin Routing Table of iTeadStudio Datashield, the Pin Routing should be the same as in the example.myTouch(6,5,4,3,2);