nopnop2002 / Raspberry-ili9325

Parallel TFT Shield Library for wiringPi
64 stars 14 forks source link

2.8" TFT (8bit) touch screen feature not working #33

Closed ciobania closed 2 years ago

ciobania commented 2 years ago

Hello,

Firstly, thank you for making this possible and sharing it; I've struggled to gather knowledge on how to make my display work with a Raspberry Pi for long time now.

I was able to run through most of the demo/examples you provided, successfully, apart from the last one with the touch screen.

My issue currently is that I cannot get input from the touch screen. I have compiled the touch binary with the 8BIT parameter, and when I run it, it displays the numbers, but that is pretty much all I can do with it; I see that in touch.c there is a pin defined for pen input on GPIO 6; I don't understand how that works, or where the input will come from, because my TFT screen does not have a separate pin for the PEN (I have the 8bit parallel version).

Because I have redefined the pins I'm using, I changed the pin in the touch.c file to an "empty" one, like it was initially (or that's how I'm reading it).

  1. Are you able to point me in the right direction on how to sort this out, please?
  2. Can I create my own interface to display, and get the touch screen input via Python script, rather than C?
  3. is there a way to control the backlight ON/OFF?

Here's my git diff output, to help you understand what I changed:

RST=7 CS=8 RS=9 -WR=11 +WR=5 -RD=31 +RD=6 D0=21 D1=22 D2=23 D3=24 D4=25 -D5=26 +D5=27 -D6=27 +D6=28 -D7=28 +D7=29

If your TFT is 8 bit Parallel,A definition after this isn't used.

D8=2 D9=3 diff --git a/touch.c b/touch.c index b559ffb..5eec9ab 100644 --- a/touch.c +++ b/touch.c @@ -12,8 +12,8 @@

define SPI_CHANNEL 0 // /dev/spidev0.0

//#define SPI_CHANNEL 1 // /dev/spidev0.1 -#define GPIO_PEN 6 +#define GPIO_PEN 26 -#define DEBUG 0 +#define DEBUG 1

This is the TFT Screen I am using: elegoo 2.8"TFT Touch Screen Thank you kindly for your effort and feedback, and for making this possible! Much appreciated!

Stay safe and healthy, ciobania

nopnop2002 commented 2 years ago

https://www.elegoo.com/products/elegoo-2-8-inches-tft-touch-screen

Looking at this picture, it looks like there are no pins for the touch screen.

There is no Chip Select to enable the touch screen.

ciobania commented 2 years ago

If you scroll down on that page, it does display a pinout picture, describing what each pin does. There is a Chip Select option, which is LCD_CS, WiringPi number 8, in your pin.conf file, and that's how I have it wired as well. Is that what needs to be used?

The Arduino code I have from the CD, is using 2 analog pins, and two digital pins to drive the touch screen.

I'm new to all this, 8bit parallel pins, and what gets sent where, etc. I don't even know where to start learning it, to be honest.

Right now I'm trying to mount this TFT touch screen to my homemade thermostat.

nopnop2002 commented 2 years ago

The Arduino code I have from the CD, is using 2 analog pins, and two digital pins to drive the touch screen.

You need to parse the Arduino code in the CD.

This library supports SPI-Touch Sensor.

The following pins are required for the SPI-Touch Sensor. pins

Looking at the pictures, I don't know where these pins are.

ciobania commented 2 years ago

Interesting. The board I use does not have an SPI interface, and I thought the library and pin setup accounts for that, whjich it did to a degree, and it allowed me to get my screen to display something, apart from the touch screen. Most of the boards you presented in the photos, have no PEN pinout, apart from the one configured towards the end of it.

./xpt doesn't work either, and I assume from your comment that it may be because of the SPI missing interface, or the "PEN" pin. I am familiar with SPI and I2C, and it is the first time I'm being introduced to the 8bit-16bit interfaces. I've been stuck at this for about 1 week, and only your instructions made some sense, and allowed me to get some output onto the screen.

Do you know if the touch screens generally only work on the SPI interface, or is it a hardware implementation depending on the model/brand/company that produces them? (I always assumed that these will use common interfaces: i.e. i2c, spi, usb, etc) Ultimately, if nothing comes out of it, I guess I'll have to buy a new touch screen for my needs. In all fairness, when I bought this few years back it was intended to use with Arduino, and now I'm in need of a similar device, with same features, but different hardware support. The Arduino library provided uses 2 analog pins, and 2 digital pins as a way to map the X+, Y+, X- and Y-. Any info you might have that can help me out figure what I'm missing, or how to make it work is very much appreciated.

Thanks for your help! I'll try to see if I missed something else.

nopnop2002 commented 2 years ago

I want to know how the Arduino code controls the touch sensor.

If you have the arduino code in your repository, I can see it.

ciobania commented 2 years ago

I want to know how the Arduino code controls the touch sensor.

If you have the arduino code in your repository, I can see it.

Give me few minutes to upload it somewhere.

ciobania commented 2 years ago

have a read here: https://github.com/ciobania/el-sm-04-tft-touch-screen-docs this is the entire CD documentation. The relevant parts are in here: https://github.com/ciobania/el-sm-04-tft-touch-screen-docs/blob/main/Example04-Touch/tftpaint/tftpaint.ino https://github.com/ciobania/el-sm-04-tft-touch-screen-docs/tree/main/Install%20libraries/TouchScreen

nopnop2002 commented 2 years ago

I saw the Arduino code. This code uses analogRead (). This is a specification called "4-wire resistive touch screen". Analog input is not possible with Raspberry Pi.

If you want to use the touch sensor with Pi, you need a TFT with xpt2046.

ciobania commented 2 years ago

If you want to use the touch sensor with Pi, you need a TFT with xpt2046.

Can you point me to one such display, or provide some names/brands? How would I know if I'm purchasing the right thing (TFT with XPT2046)?

Thank you

nopnop2002 commented 2 years ago

I have this one. But I don't know if you can buy the same.

ili9341-16bit-2

ciobania commented 2 years ago

I searched for it, and couldn't find it. I have the one I posted with 8bit parallel interface, and just got another one with SPI interface, which I'm yet to make it work with Raspberry. So I'm stuck.

One thing I was considering was to get an analogue to digital sensor for raspberry, however I wonder if its possible to use/configure the arduino code from the docs I shared.

The idea is that the analog pins are used in order to have the posibility to use the other pins for something else, and not because the display is providing the data through analog. Maybe I'm wrong but thats what I understood from the docs

nopnop2002 commented 2 years ago

Yes. You are right.

The pins for the 4-wire resist touch screen are shared with the LCD control pins.

Analog pins are used not only because the display provides data via analog, but also to control the LCD. The pins on the 4-wire resist touch screen are used to switch between input and output.

ciobania commented 2 years ago

I'll keep digging around, and see if I can get anywhere this week with any of the two displays.

I'm not too familiar with C/C++ so it's harder for me to understand how it all works.

Thanks again for your feedback, and help with it! Much appreciated!

ciobania commented 2 years ago

I'm closing this as I was able to use a different screen, with dtoverlays.

Unable to use this repository, to drive my version screen, unfortunately.

Thank you for your help and feedback!