Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ciobania opened this issue Nov 27, 2021 · 14 comments
Closed

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

ciobania opened this issue Nov 27, 2021 · 14 comments

Comments

@ciobania
Copy link

ciobania commented Nov 27, 2021

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
Copy link
Owner

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
Copy link
Author

ciobania commented Nov 28, 2021

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
Copy link
Owner

nopnop2002 commented Nov 28, 2021

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
Copy link
Author

ciobania commented Nov 28, 2021

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

@nopnop2002
Copy link
Owner

nopnop2002 commented Nov 28, 2021

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
Copy link
Author

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
Copy link
Owner

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

ili9341-16bit-2

@ciobania
Copy link
Author

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
Copy link
Owner

nopnop2002 commented Nov 29, 2021

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
Copy link
Author

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants