Go Down

Topic: UTFT library optimised for Due/SSD1289 (Read 4580 times) previous topic - next topic


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!

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:

Code: [Select]


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



He recommended the itead studio version

I looked at Itead, what version, of what are you talking about?

Could you provide a minimum code that would compile using your optimized method?

Thanks for posting what you have so far, I have the display you are speaking of, and I hope to use it with my Due also.
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com


This is the shield:

This is the screen:

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)



Thank you for the reply! I think I might also get the Itead shield, it looks like that is a good idea!
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com


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.



I also have problems getting the SD-Card to work, not only the Touch Interface...

For now only the Display is working with my Arduino Due.

I have Problems with the Touch functionality and the SD-Card access.

Does anyone have the same combination of hardware, where those 3 features are working?

My Hardware:
- Arduino Due
- IteadStudio ITDB02 Arduino Mega Shield v2
- Sainsmart 3.2" with  SD-Card Interface

Go Up