Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Touch_getXY()

Mammad900 edited this page Aug 29, 2020 · 1 revision

Touch_getXY()

Summary

Reads touch screen data (it is a touch screen 'driver').

Updates pixel_x, pixel_y, and pixel_z values.
pixel_x and pixel_y contain the position of the touched area.
pixel_z contains the pressure. Pressure of ~800 means a slight touch and a pressure of 50 means a hard touch.

Parameters

None

Returns

If TFT screen is being touched, returns true. Else, returns false.

Example

void loop(){
    if(Touch_getXY()){
        int radius = map(pixel_z, 800, 50, 1, 10);
        tft.drawCircle(pixel_x,pixel_y,radius,TFT_WHITE);
    }
}

Output

Turns your hand into a marker.

Notes

Actually this function is written by the creator of MCUFRIEND_kbv library and exists in it's examples. I selected the best one (which existed in touch_shield_new) and added debouncing functionality to it

Clone this wiki locally