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

Avoid division by zero #4

Open fukuchi opened 10 years ago

fukuchi commented 10 years ago

Hi,

Pressure value returned by getPoint() is always 0 in some environments. It is caused by a division-by-zero error.

138 float rtouch; 139 rtouch = z2; 140 rtouch /= z1; // = analogRead(_xm);

Here a quick hak: 140 rtouch /= (z1 + 1);