adafruit / Adafruit_TouchScreen

Arduino library for 4-wire resistive touchscreens
http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=333
Other
271 stars 209 forks source link

Adapt for ADC resolution on ESP32 #15

Open lukasfischer83 opened 5 years ago

lukasfischer83 commented 5 years ago

Arduino board: ESP32 Hi, I just noticed a small bug on ESP32, which has 12bit ADC resolution. The driver works as expected if analogReadResolution(10); is called before using getPoint(). Otherwhise, as expected, it does not ;). So maybe you could implement a check on the resolution and change the calculations (1023 is hardcoded in some lines) or simply right-shift the adc results by two if ESP32 is defined. Cheers, Lukas

Ryan-obl commented 5 years ago

Good catch, thank goodness I found your post (and your simple solution) in time!

Now the Adafruit touchscreen works like a charm on my ESP32!

LeonidKokhnovich commented 5 years ago

@lukasfischer83 @Ryan-obl Hey! I wonder what pins do you use on ESP32 for Xp, Xm, Yp and Ym? It doesn't seem to work for me.

Psycho-0 commented 5 years ago

This edit works, I would refrain from using inputonly pins for xxyy measurements. This led to unusable results in my tests.

Ryan-obl commented 5 years ago

@lukasfischer83 @Ryan-obl Hey! I wonder what pins do you use on ESP32 for Xp, Xm, Yp and Ym? It doesn't seem to work for me.

Hey @LeonidKokhnovich , I would use any pins that has any of the ESP32's ADCs on it, which naturally would depend on which board your ESP32 is on.

For instance, I'm using the ESP32 DevKitC v4, whose pinout can be found at: https://components101.com/microcontrollers/esp32-devkitc

Cheers, Ryan

dumtux commented 3 years ago

Arduino board: ESP32 Hi, I just noticed a small bug on ESP32, which has 12bit ADC resolution. The driver works as expected if analogReadResolution(10); is called before using getPoint(). Otherwhise, as expected, it does not ;). So maybe you could implement a check on the resolution and change the calculations (1023 is hardcoded in some lines) or simply right-shift the adc results by two if ESP32 is defined. Cheers, Lukas

This was so much helpful. I struggled with ESP32 touchscreen issue. The touchpoint values were strange. I thought some other circuits are interfering electric signals and so ESP32 is reading wrong values. But it was ADC resolution issue. I realized that after reading this. Thanks again!

ScruffR commented 10 months ago

I just filed a pull-request to solve that problem https://github.com/adafruit/Adafruit_TouchScreen/pull/43