Go Down

Topic: 2.8 TFT LCD resistive touchscreen shield Adafruit - SPI (Read 353 times) previous topic - next topic

Guest144

I'm working on a project that includes Genuino Mega 2560 and 2.8 TFT LCD resistive touchscreen shield (ILI9341). I want to connect them via SPI and by not putting shield on top of the Genuino. Instead I want to connect them with wires. So here's what I did: MOSI(51) pin on Genuino board  -> digital pin 11 on shield, MISO(50) pin -> pin 12, SCK(52) pin -> pin 13, SS(53) -> pin 10, and pins 9 and 8 to pins 9 and 8 on the shield, plus power (I connected both 3.3V and 5V pins on Genuino to equivalent pins on the shield, and of course ground to ground. I used Adafruits graphicstest example.

Result: white screen.

Did I make a mistake by connecting the wrong pins together?

Altought the program appeared to have uploaded just fine because in the serial monitor the code was executed correctly. However at the very bottom of the status area there was some kind of error.->
avrdude: stk500v2_recv(): checksum error
avrdude: stk500v2_recv(): checksum error
avrdude: verification error, first mismatch at byte 0x0111
         0x69 != 0x6e
avrdude: verification error; content mismatch


Despite that the program seemed to work in the serial monitor.

Did anybody encounter similar problems?

I intend to use UTouch and UTFT libraries and was wondering has anybody tried to use them with this kind of a display? What are the correct parameters and connections to make it work via SPI?

UTFT myGLCD(ILI9341_S4P,51,52,53,A0);
UTouch  myTouch(52, 8, 51, 50, 17);

This is what I came up with but I'm not sure it will work.

Any help would be much appreciated.




http://www.rinkydinkelectronics.com/library.php?id=51 (UTFT library)

david_prentice

God invented Shields so that you could plug them into your Arduino.

Of course you can always use trailing wires if you really want to.
However,  it is important to connect the wires to the correct pins.

If you post a link to the actual shield that you own,   we could help with the constructor.

It is extremely unlikely that your TFT uses the "S4P" interface.

David.

Guest144

here is the link :https://www.adafruit.com/product/1651

Guest144

I have managed to get my Adafruits graphics test example to work without placing the shield directly on board with slight modifications. In the code I defined pins in following manner:

#define TFT_DC 9
#define TFT_CS 53
#define TFT_MOSI 51
#define TFT_MISO 50
#define TFT_CLK 52
#define TFT_RST 6

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Now I'm going to move to UTFT and UTOUCH libraries. Has anybody tried them with this type of shield and how should this lines look to make it work (I'm not sure that this is correct and don't want to destroy the board by connecting the wrong pins together):

UTFT myGLCD(ILI9341_S4P,51,52,53,A0);
UTouch  myTouch(52, 8, 51, 50, 17);

Thanks for help.


david_prentice

If someone buys a quality product from Adafruit,   they are probably going to use it with the quality libraries from Adafruit.

Yes,   a nerd like me would possibly try the hardware with the UTFT libraries out of general curiosity.
Yes,   I am sure that they would work with the correct constructor.

I have not got around to looking at your docs.    I would be very surprised if it is "S4P".
When you use the correct UTFT constructor,   you will be dumbstruck by the performance.

As a silly question.  Why do you want  to use UTFT?

David.

Guest144

I have already written a code that is supported by UTFT and UTOUCH and I really don't want to do it all over again (I don't have much time left for that project). In the PDF documents of UTFT library it said that you could use 2.8 tft and that for ILI9341 it supports four or five serial communication.

david_prentice

#6
Jul 14, 2016, 01:27 pm Last Edit: Jul 14, 2016, 01:28 pm by david_prentice
If you want to use UTFT,  you will need the equivalent UTFT constructor()

Code: [Select]

#define TFT_DC 9
#define TFT_CS 53
#define TFT_MOSI 51
#define TFT_MISO 50
#define TFT_CLK 52
#define TFT_RST 6

//this is your Adafruit constructor()
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);


//this would be the equivalent UTFT constructor()
UTFT myGLCD(ILI9341_S5P, TFT_MOSI, TFT_CLK, TFT_CS, TFT_RST, TFT_DC); 



Surely Adafruit provide proven libraries and examples.   And of course they would be able to put the TFT and the XPT2046 onto a single SPI bus.

UTFT/UTouch don't understand the concept of a bus.   You probably have to use separate pins for each device.

David.

Guest144

UTFT myGLCD(ILI9341_S5P, TFT_MOSI, TFT_CLK, TFT_CS, TFT_RST, TFT_DC);  this constructor is correct. The display is showing exactly what it needs to show, so thank you for that David.

I would just have I follow up question on how Utouch constructor should look to make it fully functional.

UTouch  myTouch(52, 8, 51, 50, 17);this is what I'm using right now and it doesn't work.

Guest144

Is it possible  to use UTFT library for display and Adafruit library for touch screen part?

david_prentice

#9
Jul 19, 2016, 09:00 am Last Edit: Jul 19, 2016, 09:01 am by david_prentice
I think it is highly unlikely that you can use anything with a bit-bashed UTFT Serial.    But you can always try it for yourself.

Most 16-bit shields have separate pins for the XPT2046 and the other TFT signals.   So it does not matter with UTFT / UTouch.   You just use lots of wires.

Since you already have quality Adafruit libraries,   why not use them?

If you wrote the TFT code,   you could re-write it for the (more intuitive) Adafruit methods.

If you want help with this,   post your TFT code.    I suppose that I could even test it for you with Adafruit libraries.    I am not very keen to try the UTFT / UTouch libraries because I am fairly certain that I would have to "correct" those libraries.

David.

Guest144

I have successfully re-written the code and it works fine. However I do have a question about a part of my code which I can't get to work. I want to use my touch LCD to type in a password which is compared to predefined value (in my case textfield2). The numbers are stored in a textfield and printed to screen.



#define TEXT_LEN 4
char textfield[TEXT_LEN+1] = " ";
uint8_t textfield_i=0;


char textfield2[TEXT_LEN+1] = "1111";

if (textfield == textfield2){ //it doesn't work
//do something
}

if(textfield != textfield2){     //it does work
//do something else
}

david_prentice

An Arduino is C++ so you can use String methods.

Since you are actually using C char arrays rather than String objects,   you use strcmp() to compare strings.

David.

Guest144

I have changed the code as follows:

if ((strcmp(textfield," ") == 1111){      - it does not work
//do something
}

if ((strcmp(textfield," ") != 1111){       - it works
//do something
}

Yet still the same result.

david_prentice

Google how to use strcmp()
Or just read any C textbook.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy