-
Notifications
You must be signed in to change notification settings - Fork 12
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
Visual glitches upon touch input #16
Comments
Hi, I just tried your sketch but it works without glitches for me. The only difference with my hardwired test setup is that the backlight pin of the display is directly connected to +3.3v and not to PIN 2. All the other connections are the same. I suspect it is a wiring problem... Maybe a loose connection ? How long are your wires, breadboard wires longer than 20/30cm do not work well with high SPI speed. You can try setting the SPI speed to 10Mhz just to see if it helps. It also looks like the touchscreen may be interfering with the display. Are you sure that T_CS is routed to PIN 4 on the Teensy ? With the sketch provided, the complete wiring should be:
What happens if you physically disconnect all the touchscreen pins (ie all the T_* ones) from the teensy and set PIN_TOUCH_IRQ and PIN_TOUCH_CS to 255 in the sketch ? Are there still glitches ? Finally, do you use the usual cheap red ILI9341 breakout board ? Some of those boards do not even have a touchscreen present even though the touch pins are still present on the PCB. Can you post a picture of your setup ? |
I tried it without the T_* pins and it seemed to not have any problems. I made sure that all connections were correct and I set the SPI speed to 10Mhz. The touch chip is soldered to the display breakout and the touch calibration wizard works just fine. Maybe it has something to do with how I'm powering it. The LED is being powered by pin 2 with a 110Ohm resistor. Maybe my unit is just defective. |
That is weird indeed.. I do not understand why it works with the touchscreen calibration demo and not the others sketches... I will try to replicate your exact setup on a breadboard this evening when I have some time. Two remarks:
|
I tried it with USB power and connected the backlight to a 3.3V pin (with the 110Ohm resistor) and it made no difference. Let me know if you have any more questions about my wiring. |
Thanks for the help! There is something that is still bothering me though. If the issue really is on the hardware side, why does the touch calibration demo have no issues? |
Yes, I do not really understand why the touch calibration demo works. However, it is worth noting that while doing performing calibration the driver is not using all the fancy features like DMA transfers, double buffering, vsync... This may make this mode of operation more resilient to failure/noise/temporary disconnection between the MCU and the display (e.g. if the signal on some lines SCK/MISO/MISO is shortly interrupted) and may enable it to recover... But that is just a guess. |
Now I have to figure out if the problem lies with the display itself or if my wiring is just not good. Do you think I should just try it with a different display, or are there other things that I should look out for with my wiring? |
I do not know the answer really :) My feeling is that, even if the wiring is inconsistent, your display is faulty anyway since pressing the screen always freeze/crashes the program... These display are very cheap (I usually buy them on aliexpress for a few euros) so I would simply get another one... |
Alright, I got a replacement display and I still have the exact same issues. Now I'm really confused :/ I wonder why it's the T_* pins specifically that cause problems. Any ideas? |
That is really weird... I have never had any problem with a Teensy 4 (I did burn a couple of them inadvertently but it was my fault and they just stopped working completely). Just in case, you can try resetting the teensy to it's default state by pressing the button on the board for about 15 second and then releasing it when the led starts to blink. I do not expect this will really help but it won't hurt and does not cost anything to try... As for the breadboard, I did get a faulty one once where some connections did not work. It took me some time to figure it out... Maybe yours also has some defects ? Can you use another one or at least change the position of the display on the breadboard? Finally, you may also try shorter breadboard wire. Long ones cause problem with high SPI rates. You should also lower the SPI rate to 10Mhz during testing... Apart from those generic advices, I cannot help much because I have never experienced these particular problems, sorry! Hopefully you will find what is wrong. |
I moved the display to the other half of the breadboard and it still has problems. The SPI speed is set to 10Mhz and all wires are <30cm. I wrote a test program for the Teensy that makes every pin alternate between high and low every 0.5s, and every pin seemed to work just fine. The two weirdest behaviors from this have been the fact that this only happens if the touch pins are connected, and that the touch calibration demo has no issues. I'm running out of ideas |
:( I am also running out of ideas... Do the problem still appears if you disconnect the touch_irq wire and set it to 255 in the code ? The IRQ pin is not mandatory to use the touchscreen. Also, what happens if you leave everything connected but set all touch related pin to 255 in the driver and add: pinmode(4, OUTPUT) before the begin() call to the driver to disable SPI communication with the touch device. More generally, you may test which touch pin/ wire causes problem. Also, when the screen freeze, what is the output on the serial monitor. Does the driver still print the stats periodically or does the program completely hang ? |
I don't think the program itself has ever frozen. What functionality am I missing out on if I don't use touch_irq, and do you have any idea why touch_irq specifically would cause problems? |
Good, seems like we are narrowing on the issue ! The IRQ pin is used by the display to indicate when the screen is being touched. When connected to the Teensy and registered within the ILI9341_T4 driver, it will trigger an interrupt which register the current time. In this way, when The IRQ pin can be connected to any (unused) pin on the Teensy. I find it surprising that the IRQ pin is the one causing troubles. Can you try whether the bug occurs in any of the following two cases ?
As you mention that the program itself has never frozen, what does serial output when the display stops working ? Does it keep outputting the periodic |
Sorry for the wait. Here is the output of
Could you elaborate on what exactly you want me to do for test case 2? |
Well, it is getting wierder... So if I understand correctly, the simple fact of connecting the TOUCH_IRQ pin make the screen freeze when the touchscreen is pressed and this happens even if the driver is not aware of the pin that TOUCH_IRQ is connected to (because you set it to 255 in the sketch) ? Then what happens if you move TOUCH_IRQ to some other pins on the teensy (you can any digital pin) ? Could you also add add a small resistor on this line (say in the range between 100Ohms and 1K) ? Can you please also try to add |
I think it might be important to note that not every touch will break the display. There seems to be a specific spot where it will be most likely to break when touched. It's also easier to trigger the glitches with my thumb, as opposed to the stylus (I think it might have something to do with a wider surface area?). The same behavior happens with the other display. I connected the touch_irq to pin 28 with a 110Ohm resistor. I don't think these steps made any difference in behavior. Here is the updated sketch: |
Is there anything else I can try, or do I just have to accept the additional SPI transactions? |
Well, I must admit I am running out of ideas ! I do not understand how connecting the the IRQ wire to the Teensy can have any effect at all if Also, the fact that the way the touchscreen is pressed matter hints at a hardware issue but then the freezing should also happen when the IRQ pin is completely left disconnected. Finally, the fact that the calibration sketch works without problem is also perplexing... Sorry I do not know how I can help much more. I just tested again with several ILI9341 screens and a T4 and a T4.1 but could not reproduce the issue on my side... |
Maybe a video of the issue will help? This is a recording of my Teensy running the exact sketch from the last gist: I don't get it either... Also, is it safe for me to connect the backlight to a digital pin on the Teensy again? I still get a very brief white flash when the backlight turns on. Is there a way to get the pixels to start black instead of white? |
I'm using a Teensy 4.1 with a display using the default pins.
Whenever I touch the center of the display, the screen starts having weird artifacts (colors inverted, image misaligned and repeated, flickering, and usually a white screen after the others).
Sometimes, I don't even need to touch the display (this usually happens if any pin other than PIN_BACKLIGHT is set to 255).
When this is the case, the display usually alternates between a white screen and another white screen with gray horizontal stripes.
This happens with every demo except for touch calibration.
The visual problems go away after rebooting (as long as you don't use touch again).
This is the sketch where the screen goes white if you touch the center:
https://gist.github.com/Volcano339/621a4a85d2d7d4b0491ddec014bf92fb
I don't know if this is a hardware issue or not, but the fact that the glitches go away after rebooting suggests to me that it is more likely a software issue.
If you think it is a hardware issue, feel free to ask questions about the hardware.
This might just be a simple hardware mistake.
Any help is appreciated!
The text was updated successfully, but these errors were encountered: