Looking for help to use Adafruit Touch Screen Library

Hi there !
Is there any tutorial to use the Adafruit touch screen library Or any tutorial which provides complete information about the functions and keywords for this library...?

Any documentation also helps...

Thanks in Advance..

Surely you can just run the examples that come with the library.

That is why God invented Library examples for you.

David.

Respected Sir,

I have tried the example given with it but I haven't understood the code completely.

I was asking for any tutorial or any complete documentation about the function which can I use to write my own code.

Thanks for taking the time to reply on this thread.

Go on. The touchscreendemo.ino is pretty easy to read. So is touchscreendemoshield.ino

Of course it is much harder if English is not your first language.

Please quote the statements that you do not understand.
Then we can help you.

David.

Thanks, Sir for again replying.
Yes Sir, I doesn't use English as my first language so I have some problems to understand it and it may be possible I may not able to express my views completely so please avoid grammatical mistakes.

I was now understanding the Adafruit touch screen library examples.
But I was stuck with your library's button_simple.ino example. :sweat_smile:

It was very thankful to you If you provide some hint or any kind of help by explaining a bit these lines.

Following lines, I was not understanding-

Line 17
Adafruit_GFX_Button on_btn, off_btn;

Line 55 and 56
 on_btn.initButton(&tft,  60, 200, 100, 40, WHITE, CYAN, BLACK, "ON", 2);
 off_btn.initButton(&tft, 180, 200, 100, 40, WHITE, CYAN, BLACK, "OFF", 2);

Line 67 and 68
    on_btn.press(down && on_btn.contains(pixel_x, pixel_y));
    off_btn.press(down && off_btn.contains(pixel_x, pixel_y));

I was also not understanding the concept of pressure for the touch screen terms, why it was considered as z coordinate?

Hope you help or provide some documentation Or tutorial link to read.

Line 17

Adafruit_GFX_Button on_btn, off_btn;

The Adafruit_GFX library contains a class called Adafruit_GFX_Button
It declares two Buttons

Line 55 and 56

 on_btn.initButton(&tft,  60, 200, 100, 40, WHITE, CYAN, BLACK, "ON", 2);
 off_btn.initButton(&tft, 180, 200, 100, 40, WHITE, CYAN, BLACK, "OFF", 2);

This describes the position, shape, colour, text, text size of each Button.

Line 67 and 68

    on_btn.press(down && on_btn.contains(pixel_x, pixel_y));
    off_btn.press(down && off_btn.contains(pixel_x, pixel_y));

The Adafruit_GFX_Button class has several useful methods.
It is no good just looking for a Touch "press". The "press" must be within the button perimeter.

Different applications might want to know when you press a button, hold a button, release a button.
Think about your PC keyboard. You want to detect single keys. Sometimes you want a key to repeat.

I was also not understanding the concept of pressure for the touch screen terms, why it was considered as z coordinate?

That is just the way that libraries have named it. X, Y are intuitive. i.e. everyone can understand the X, Y position on a graph.
Z is often used as a "third" coordinate in a 3-dimensional graph. Libraries can distinguish between "light pressure" and "regular touch pressure"

Just try the touchscreendemo.ino example. You can see how the library returns different X, Y, Z values.

I post a link to Overview | Adafruit GFX Graphics Library | Adafruit Learning System in the library how_to file.

There are Tutorials to show how to draw a circle or rectangle. There do not seem to be any Tutorials to show how to use Adafruit_GFX_Button

David.

1 Like