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
276 stars 212 forks source link

Touch Screen library assumes 10 bit A/D? #39

Open professorwade opened 1 year ago

professorwade commented 1 year ago

Question: I noticed a number of 1024 and 1023 in the TouchScreen library and wonder if it is related to an assumption of a 10 bit A/D (i.e. Arduino 8-bit)? I am using the library with a SAMD51 part (Grand Central) and notice that the values tend to be much higher on the pressure.

https://github.com/adafruit/Adafruit_TouchScreen/blob/28e6e744982825d679f543b70480d31e457363b3/TouchScreen.cpp#L155

MaitrePoulier commented 1 year ago

I came to the exact same conclusion for the ESP32-S2 wich have an ADC of 13 bits. If you chage the 6 instances of the number 1023 with the #bits^2 (8191 in my case) it should work.

ladyada commented 1 year ago

probably best to just set the adc resolution in the examples before use - wanna try that? https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogreadresolution/

MaitrePoulier commented 1 year ago

The problem with analogreadresolution() is that is work only with the: Zero, Due & MKR Family, not the ESP32-S2

ScruffR commented 1 year ago

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