ThingPulse / esp8266-weather-station-color

ESP8266 Weather Station in Color using ILI9341 TFT 240x320 display
https://thingpulse.com/product/esp8266-wifi-color-display-kit-2-4/
MIT License
565 stars 221 forks source link

False touch observed with no user input. Screens change randomly. #159

Closed atroph closed 1 year ago

atroph commented 1 year ago

------------------------ BUG REPORT -----------------------------------------

Expected behavior

The program will disregard any false touches and only register a touch when it meets a certain time threshold.

ex: The touch screen shall be touched continuously for 100ms in order for the touch to be registered as valid.

I have noticed that the IRQ line is exceptionally noisy and am wondering if there is some hardware filtering that is either missing, not working correctly, or this is normal behavior. This can be observed on the official kit by looking at the built-in LED on the uc module and noticing that it is continuously flashing at a very fast and dim rate. When the screen is touched the LED becomes brighter and is periodic in appearance until the touch is released.

Actual behavior

Actual touches register at a random value and only repeat at the interval set below at line 276.

Line 277 was added by me to trigger logic captures.

2022-12-05_11-20-44

It appears that a touch is registered when the IRQ line goes low for an amount of time that I can't seem to find in the code. If "noise" meets that threshold it'll show up as a false touch. Maybe a debounce timer needs to be tweaked? I'm more of a hardware person vs a software one.

500ms Touch screen constantly pressed. IRQ line is periodic and touch is registered every 500ms.

2022-12-05_11-19-47

1000ms Touch screen constantly pressed. IRQ line is periodic and touch is registered every 1000ms.

2022-12-05_11-18-55

False touch (notice the IRQ line at the top does not show a periodic waveform) Touch screen not touched, IRQ line has a low point with a maximum period of 17us, touch is registered.

2022-12-05_11-26-40

2022-12-05_11-55-21

Weather Station Color version

Using the master branch, latest version (Feb commits?). Tested with no changes made to the code with the exception of wifi settings and api key. Tested with city code, time zone changed, wifi settings and api key. Tested with "if (touchController.isTouched(500))" Tested with "if (touchController.isTouched(1000))"

Hardware

Hardware is official kit and observed on two different kits brand new out of the box.

------------------------ END BUG REPORT -------------------------------------

TiVoHomeUser commented 1 year ago

Not sure if this is what you are looking for. The screen pressure for the touchController.touched() is in the library XPT2046_Touchscreen.cpp line 25

define Z_THRESHOLD 400

atroph commented 1 year ago

Not sure if this is what you are looking for. The screen pressure for the touchController.touched() is in the library XPT2046_Touchscreen.cpp line 25 #define Z_THRESHOLD 400

That seems to have done it.

Changed the value to 800 for testing and the phantom touches have went away.

Captured about 30 mins of data without a single event.

Thanks!

2022-12-05_17-30-12

marcelstoer commented 1 year ago

Thank you @TiVoHomeUser!

Looks like people are shifting this Z-value in both directions - depending on their displays I guess.