3.2 inch TFT LCD + Shield V3.0 problem with library ot code ???

Good day guys! Please could you help me, I've stumbled upon LEDStick project on Github and trying to get in running on ILI9341_16 screen and I have a problem that the touchscreen stops working after the stage of reading the memory card (tried to load the menu by turning off the memory card and the buttons still did not work).
I shot a problem on this video : TFT LCD Touch Screen - YouTube

  1. WiFi R3 ATmega2560 + ESP8266
  2. TFT LCD Mega Shield V3.0 (34 pin)
  3. 3.2 inch TFT LCD Touch Screen (34 pin)

At the attached firmware file is a screen setup.

After loading the firmware and pressing a key "Painting BMP", LCD screen shows:

[ Previous ] [ -5 ]
CROSS100.BMP 10
[ Next ] [ +5 ]
200 x 137
7 Seconds
[ File Information ]
[ Paint BMP ]

and at this moment it seems like a firmware freezes, doesn't respond to any key presses.

Most likely, a problem is in a cycle which is situated inside a function "void bmploop()" line 273. It will be very nice of you if you could tell a good idea how to solve it.

while (true)
{
if (myTouch.dataAvailable() == true)
{
pressed_button = myButtons.checkButtons();

if (pressed_button==prev)
{
if (m_FileIndex > 0)
{
m_FileIndex--;
}
else
{
m_FileIndex = m_NumberOfFiles -1; //wrap round to the last file
}

DisplayCurrentFilename();
delay(500);
keypress = 0;
}
if (pressed_button==next)
{
if (m_FileIndex < m_NumberOfFiles -1)
{
m_FileIndex++;
}
else
{
m_FileIndex = 0;
}
DisplayCurrentFilename();
delay(500);
keypress = 0;
}
if (pressed_button==plus)
{
if (frameDelay > 5)
{
frameDelay-=5;
}
ShowFrameDelay();
}
if (pressed_button==minus)
{
if (frameDelay < 200)
{
frameDelay+=5;
}
ShowFrameDelay();
}
if (pressed_button==paint)
{
Paint();
}
if(pressed_button==info)
{
DisplayFile(m_FileNames[m_FileIndex]);
}
}
}

LW.ino (15.1 KB)

LCD module specification .pdf (659 KB)

3.2 inch ILI9341 module schematic.pdf (94.1 KB)

3.2 inch ILI9341 module dimension.pdf (41.6 KB)

Your MEGA2560 has got 8192 bytes of SRAM. I would still be careful with using too much.

I am not sure what your video is supposed to show.

I have never seen a 34-pin Adapter Shield. Please can you post a link.

David.

david_prentice:
Your MEGA2560 has got 8192 bytes of SRAM. I would still be careful with using too much.

I am not sure what your video is supposed to show.

I have never seen a 34-pin Adapter Shield. Please can you post a link.

David.

Dear David, in the video I show that - while loading - a button in first menu is working, but after searching the images on a memory card, the next menu does not respond to touches - buttons stop working.

I found this 34-pin shield only at one store on Taobao because for a screen with a 34pin version, this shield is not sold on Aliexpress and in other stores. When I ordered the screen, the seller sent a Screen of the new version but of 34pin instead of 40pin. After this I had to order this shield, because in an assembly - if you connect all the elements directly without a shield - you get a bulky structure that doesn 't fit in a small box

Rudi

There have been many threads on the Forum where punters have bought 34-pin displays.

It is good to know that a 34-pin Adapter Shield exists. Even if buying an item from Taobao is painful.

I assume that the pinout matches the popular 40-pin Adapter Shield. i.e. TFT, SD, XPT2046 work with the default constructors in UTFT examples.

Regarding your SD + Touch problem. I would reduce your String m_FileNames[200];

David.

david_prentice:
I would reduce your String m_FileNames[200];

Great advice, but it seems that OP has encountered a conflict between XPT2046 touch screen controller and the SD card of ILI9341 screen: they are sharing the same SPI bus, and OP's project tries to use both of them. There is a workaround, could be found if to search by " "xpt2046" "sd" "conflict" "ili9341" " - i.e. at pjrc forum - however it's not easy to implement, as the touch screen library needs to be written with this possible problem in mind and it seems URTouch hasn't been created this way. I'd suggest contacting an author of URTouch library and maybe he could implement this workaround.

The OP is using different pins for TFT, XPT2046, SD :

#include <SD.h>
#include <SPI.h>
...
UTFT          myGLCD(ITDB32S,38,39,40,41);
UTouch        myTouch(6,5,4,3,2);
UTFT_Buttons  myButtons(&myGLCD, &myTouch);
...
#define SDssPin 53  //SD card CS pin
#define PIN 8 
...
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, PIN, NEO_GRB + NEO_KHZ800);

UTouch is now called URTouch. But it is much the same library. It is just bit-bashed on regular GPIO pins.

I don't see any pin conflicts in the constructors.
I don't have your hardware. So I can't reproduce your project.

I would reduce the String memory use. And see if it affects the behaviour.

David.

david_prentice:
The OP is using different pins for TFT, XPT2046, SD

Only their CS is separate (see the attached picture), meanwhile the other SPI bus pins - MOSI, MISO, CLK - are shared between them, and it seems there's a conflict between XPT2046 touch and SD card.

david_prentice:
I would reduce the String memory use. And see if it affects the behaviour.

As I have the same components and a similar problem, I've tried your suggestion now but sadly it didn't help. Perhaps the only software-independent solution to have both XP2046 touch and SD card at the same time on these ILI9341 screen - is to solder a separate SD card to the free pins and somehow set up a secondary SPI bus for it. Could be a bit tricky, considering every online example sets up only CS. Do you know where to find the settings for MOSI, MISO, CLK?

There is no problem with having multiple SPI devices.
F_CS is for a Font chip. Probably unmounted
SDCS is for an SD card.
T_CS is for XPT2046 Touch controller

Obviously all the Slaves that share the SPI bus must use HW SPI.
Do not try to mix SW SPI and HW SPI on the same pins.

CS is for the TFT parallel interface.

Pure guesswork. We have no idea what components are mounted on the pcb. The photo in #6 only shows part of the pcb.

If xpt2046sd cares to provide the information, he would get an accurate answer.

David.

Big thanks to @david_prentice for kind help.

@Rudi_i, if you have a spare SD card adapter board like this, you could somehow connect or solder it to the Arduino Mega2560 10-13 pins: a bit tricky to be honest, because a shield is covering them, but you can solder the extra pins to the shield's parallel unused holes which are above the Arduino Mega2560 holes of 10-13 pins.

You will also need to modify URTouch for a touch mirror fix, and - most importantly - SD card library to switch it to 10-13 pins a software SPI instead of using a hardware SPI. I've posted a full solution, together with the modded libraries, to this thread - Custom pins numbers for SD card's SPI bus: how to setup CS, MOSI, SCK, MISO? - #5 by xpt2046sd - Displays - Arduino Forum <--- feel free to download them.

By the way, I got this rare 34-pin shield not from a Taobao directly, but asked the same AliExpress seller who sold this ILI9341 screen to me, and he resell 2pcs of rare adapter (one spare) for just 8 usd total with shipping included. A few others also offered their help, although their prices were higher - 8.8 usd and above. So - if you need any rare Taobao item and don't know how to get it directly - just spam a lot of Ali sellers (only those who are reputable, of course!), choose the best offer and get a multiple of $1 usd "add shipping" fake items from their store - equivalent to your agreement's price - while writing a Taobao link at order description.