Go Down

Topic: Using the UTFT libraries with the Seeedstudio 2.8'' TFT Touch Shield V2.0 (Read 729 times) previous topic - next topic

R_Hart

Like many folks here, I recently (about 3 weeks ago) bought a Seeedstudio 2.8'' TFT Touch Shield V2.0 from a Radio Shack that was being closed. Although the libraries from Seeed worked, I didn't like the limits in fonts and graphics, and wanted to use the much richer set of functions and fonts in the UTFT libraries. Although scouring both this forum and the net in general didn't result in a direct answer, I did finally piece together enough info to figure out the LCD portion.

The problem I had was that Seeed's documentation makes it sound like the SPI on their shield connects through the regular header pins and not the ICSP. Actually, the SPI bus on their shield is ONLY connected through the ICSP for MOSI, MISO and SCK, while CS and D/C (RS) are physically connected to D5 and D6 respectively. Reset is connected to the Arduino's hardware Reset pin. I found on another site (http://www.dimdim.gr/tag/utft/) that if a TFT shield uses the hardware Reset, the value in the Init line in your sketch using the UTFT libraries should use the value 0 for that parameter.

With all this in mind, the simple answer for using UTFT libraries with this shield is that if you're using an UNO, the init line should read "UTFT myGLCD(ILI9341_S5P,11,13,5,0,6);", and if using a Mega 2560, the line should read "UTFT myGLCD(ILI9341_S5P,51,52,5,0,6);".

Using the above line in my sketch using a Mega 2560 works perfectly, with an average time to run the graphics demo of about 1.9 minutes. I haven't started to tackle the touch screen programming yet - that's next.

Sorry if this is actually common knowledge, but I figured if I couldn't find it, others were probably having problems too.

R_Hart

Tonight I tackled the touch screen part, hoping to use the UTouch libraries that go with the UTFT libraries. I quickly discovered that that's not possible as UTouch expects that the module pre-processes the R-values into D-in and D-out from the screen before connecting to the Arduino. The Seeedstudio shield connects the x+, x-, y+ and y- pins directly to the analog pins A0 - A3, which pretty much forces you to use their touch library. However, it wasn't too hard to figure out what functions and values to substitute to make the UTouch demo UTouch_ButtonTest.ino to work. I'm going to try converting the other demos as well just for the experience.

In doing this I discovered that the vectors for this screen are different than that of the LCD. I need to look into this a bit more, maybe I can extend the Seeedstudio library to translate the coordinates to match what Mr. Karlsen does in his library in offering a switch for portrait/landscape.

Bob

R_Hart

Well, no luck finding a way to create a library function so far, but I have discovered that I can swap the pin assignments when I initialize the touch screen in a sketch so that the screen orientation matches the display orientation. As an example, the stock demo from SEEED for their paint.ino has the line set to :

TouchScreen ts = TouchScreen(57, A2, A1, 54)

for the Mega 2560. This actually comes from the TFTv2 library which sets the pin assignment according to which Arduino you're using (by the way, in this case 57 refers to A3 and 54 to A0). This sets the orientation to portrait, which works for their paint sketch, but not something in landscape like the UTFT UTouch_ButtonTest sketch, which is in landscape. However, if you swap the pin assignment to TouchScreen(54, 57, A2, A1), the axis and vectors will be the same as the demo. You also need to map the values to the pixels using something like the following lines:

p.x = map(p.x, TS_MINX, TS_MAXX, 0, 320); //Landscape X
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 240); //Landscape Y

(p is the variable I used for the values returned by the function getPoint)

The full example for converting the UTouch_ButtonTest sketch to use the Seeedstudio touch library instead is attached. (I was going to post in-line, but it cause the post to exceed 9000)

I should mention that I changed the name of the Seeed touch library from SeeedTouchScreen to STouch to reduce the typing, if you don't want to mess with that just use the library names from Seeed.

The sketch works, but unfortunately I can't seem to figure out how to change Karlsen's UTouch Buttons library to use the same functions. If anyone has advice about doing this (I realize you need to know both Seeed's library and Karlsen's UTouch library to sort it out) I would greatly appreciate it. Meanwhile, I have some C gurus at work I'm going to tag to look at my changes so far to see if we can figure it out. If anyone here is interested in helping, let me know and I'll post what I have at that point.

Bob

borbitz

Hi Bob,

Unfortunately none of the aforementioned methods have worked for me. I am also trying to use the UTFT_Buttons library on the SeeedStudio 2.8" TFT shield. Mine says v2.1 on the back though.

Do you mind uploading the exact libraries you are using and also note with version of the Arduino IDE you are using?

Thank you for the work you've done so far!

Pedro.

Joes1107

is it possible to use tft display without using shield.|
I just wanna connect wires directly from arduino to display. If i do so is the UTFT and UTouch libraries compatible??

R_Hart

Sorry I haven't replied sooner, I've been away from this forum for a while and didn't know there were questions.

Pedro: I used Karl's current UTFT for the display part of the code, and the current Seeedstudio Touch library for the touchscreen control, I just changed the library name to reduce the typing. You can use their library without changing the name, the function names are the same. Just change the include statement to #include SeeedTouchScreen.h. The IDE version is the current one, v1.6.1 (at least I think that's current, it hasn't bugged me about updating).

joes1107: I'm not sure what you mean by using the screen without the shield. If you mean connecting wires to the shield pins without plugging it directly into the Arduino, I don't see why you couldn't do that, just follow the pin assignments in Seeed's documentation and remember that the SPI connections are actually physically on the ICSP connector, NOT on the header pins (this is for MOSI, MISO and SCK). The other pins could go to pretty much any other digital connections, just adjust the assignments accordingly. Also, don't forget about the power, ground and reset pins.

If you mean removing the screen from the shield, that's a different matter, as the shield is handling the level shifting required for the screen, which you would have to physically do yourself. Plus, you would need the flex connector for the cable, etc. Unless you really understand hardware I would recommend not trying that, plus you would lose the SD card, which can be quite nice for some tasks.

Bob

Erutan409

R_Hart, this is awesome.  Thank you so much for your time and effort sharing this information.  I've tried using this shield in the past (trying to experiment with limited knowledge) and now I feel like I can give it another shot.  Much appreciated!

zappman

........
The full example for converting the UTouch_ButtonTest sketch to use the Seeedstudio touch library instead is attached. (I was going to post in-line, but it cause the post to exceed 9000)

I should mention that I changed the name of the Seeed touch library from SeeedTouchScreen to STouch to reduce the typing, if you don't want to mess with that just use the library names from Seeed.
......

Bob
Hi Bob,

Thank you for your post(s) they got my Seeedstudio 2.8'' TFT Touch Shield V2.0 working with my mega 2560 using UTFT. :)

Can you check the "USeeed_ButtonTest.ino" file you uploaded?

I cannot figure out how to make the sketch compile correctly.

The Seeed paint demo runs correctly, so I know the "touch" portion of my display (the hardware) works.

Maybe I don't have all the supporting files required to run "USeeed_ButtonTest.ino" installed correctly.

Thanks,

zappman

R_Hart

zappman,

The problem may be my renaming the Seeedstudio touch library to STouch. I'm uploading a version with an include statement that calls the touch library by the original name. I just checked it and it compiles correctly. Hope this helps.

Bob

p.s. If you continue to have problems, include the error message from the ide window in your next post.

Booskaboo

Hiya R_Hart! I'm having an issue with getting your second file to compile. I'm using an arduino UNO with a seeed shield 2.0

USeeed_ButtonTest.ino: In function 'void loop()':
USeeed_ButtonTest:157: error: 'TS_MINX' was not declared in this scope
USeeed_ButtonTest:157: error: 'TS_MAXX' was not declared in this scope
USeeed_ButtonTest:158: error: 'TS_MINY' was not declared in this scope
USeeed_ButtonTest:158: error: 'TS_MAXY' was not declared in this scope
'TS_MINX' was not declared in this scope

Not sure how to get the thing to properly declare in this scope!
zappman,

The problem may be my renaming the Seeedstudio touch library to STouch. I'm uploading a version with an include statement that calls the touch library by the original name. I just checked it and it compiles correctly. Hope this helps.

Bob

p.s. If you continue to have problems, include the error message from the ide window in your next post.

R_Hart

Booskaboo,

I just looked at my UTFT library and compared it to Henning's. The following lines are in my UTFT.h file. As they are not in Henning's current file, it looks like I must have added them (honestly don't remember doing it, but I am getting up there in years, and as they're there, I must have).

#define NOTINUSE      255 // this line exists in the original library

#define TS_MINX 116*2
#define TS_MAXX 890*2
#define TS_MINY 83*2
#define TS_MAXY 913*2

Add the 4 above defines to the header file in the pre-compile section (the location I used works fine) and save it. Then re-open the IDE and try to compile. It should work. If you have other problems post them, I don't get to here often, but I do try to check every couple of weeks. Unfortunately, I was gone on vacation for a few weeks and didn't get on the thread until today.

Bob

Go Up