Soft Button Library for 2.8" TFT LCD

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
owendelong
 
Posts: 78
Joined: Fri Feb 10, 2012 4:25 am

Soft Button Library for 2.8" TFT LCD

Post by owendelong »

One of the things I wanted to be able to do with my TFTLCD Touch Screen was have virtual buttons.

In order to do that, I wrote a softButton Library. Now that I've debugged it to the point of working (at least in initial tests), I've posted it to GitHub:

https://github.com/owendelong/Adafruit- ... ft-Buttons

It's based on someone else's LGPL code, so as far as I'm concerned, LGPL is a perfectly fine license for the resulting code as well.

The README provides some documentation.

@Adafruit -- If you would like to add this library to your "supported" TFTLCD touchscreen offerings, you are welcome to do so. Please just preserve the authorship attributions.

I hope others find this useful.

jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Post by jjbridw »

For someone who is relatively new to programming is there some sort of "key" that might help me understand the arguments inside the "softButton" parenthesis?

Thanks,

User avatar
owendelong
 
Posts: 78
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

Post by owendelong »

Well, I thought the README file (look under Calling sequence:) did that.

&tft is a pointer to (& means address of) an Adafruit TFTLCD object (created when you instantiated the 2.8" TFTLCD display library)

&ts is a pointer to an Adafruit TouchScreen object (created when you instantiated the 2.8" TFTLCD TouchScreen Library)

XP, XM, YP, and YM are the pin numbers for X+,X-, Y+, and Y-, respectively. The same arguments had to be passed to the TouchScreen library, so, you should have them relatively handy.

X and Y are the X and Y coordinates on the display of the upper left corner of the virtual button.

W and H are the Width and Height (in pixels) of the virtual button.

Note that X and Y (and W and H) include the area of the button used for beveling, specifically a 3-pixel wide border, so you should draw the button from X+3,Y+3 to (X+W-4, Y+H-4). Otherwise, part of your image will get overwritten by the beveling process.

C is the background color for the button. This is used in the beveling algorithm. Usually it will be the output of tft.Color565(r,g,b).

M is optional. If you specify it, it will set the button mode of operation. You can use B_Name.setMode() at any time to change the mode. If you don't specify a mode here or with setMode, then it defaults to ONESHOT.

If that doesn't give you what you need, then send me a PM and I'll try to help you.

jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Post by jjbridw »

I apologize, I have not been able to view the README file on my mac, I keep getting errors. I'll try some more, but thanks for the info.

User avatar
owendelong
 
Posts: 78
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

Post by owendelong »

If you go here:

https://github.com/owendelong/Adafruit- ... ft-Buttons

It should be readily visible.

The library and the README were developed on a Mac (I'm a fellow Mac person), so, your problems aren't Mac specific.

jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Post by jjbridw »

Actually it's on my inexperience with a Mac. I'm a new Mac user, it's a while new world. Love the Mac though and don't think I can ever go back :D

User avatar
owendelong
 
Posts: 78
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

Post by owendelong »

No worries. Hopefully the textedit pointer or the web browser worked for you. Best of luck. Let me know how it works out.

Owen

JQ21
 
Posts: 4
Joined: Mon Jan 28, 2013 4:30 pm

Re: Soft Button Library for 2.8" TFT LCD

Post by JQ21 »

Hi Owendelong,

I'm trying to make a button on the same touch screen move a stepper motor. I have little to no experience with Arduino at all. But I'm trying to use the files you posted on github to create a button. But I'm not sure what the format of the button is suppose to be like.

For example, when you have softButton B_Name(&tft, &ts, XP, XM, YP, YM, X, Y, W, H, C[, M]); am I suppose to put a value or something for each of those inside one bracket? What do you mean by pointer for &tft and &ts?

Do you have an example of a very simple button? (The arrow one did not work for me)

Thank you.

-JQ

User avatar
owendelong
 
Posts: 78
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

Post by owendelong »

JQ, did you read the previous posts?

Did you read the README file?

I'm not trying to be unresponsive or obnoxious here, but your question is virtually identical to the initial question from jjbridw.

The README file is readily visible on GitHub through the web interface.

There is even a link to it in my March 3, 2012 5:03 PM post in this thread.

If that doesn't get you going, please let me know and I will try to assist you further.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”