Please be aware of all shipping deadlines before placing your order - we cannot guarantee orders will arrive before Christmas!

Soft Button Library for 2.8" TFT LCD
Moderators: adafruit_support_bill, adafruit

Soft Button Library for 2.8" TFT LCD

by owendelong on Sun Feb 26, 2012 12:27 am

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.
owendelong
 
Posts: 58
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

by jjbridw on Sat Mar 03, 2012 1:23 pm

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,
jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

by owendelong on Sat Mar 03, 2012 8:33 pm

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.
owendelong
 
Posts: 58
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

by jjbridw on Sat Mar 03, 2012 8:56 pm

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.
jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

by owendelong on Sat Mar 03, 2012 9:03 pm

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.
owendelong
 
Posts: 58
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

by jjbridw on Sat Mar 03, 2012 10:46 pm

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
jjbridw
 
Posts: 3
Joined: Fri Feb 24, 2012 3:31 pm

Re: Soft Button Library for 2.8" TFT LCD

by owendelong on Sun Mar 04, 2012 12:26 am

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

Owen
owendelong
 
Posts: 58
Joined: Fri Feb 10, 2012 4:25 am

Re: Soft Button Library for 2.8" TFT LCD

by JQ21 on Mon Jan 28, 2013 4:39 pm

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
JQ21
 
Posts: 4
Joined: Mon Jan 28, 2013 4:30 pm

Re: Soft Button Library for 2.8" TFT LCD

by owendelong on Wed Oct 16, 2013 8:22 pm

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.
owendelong
 
Posts: 58
Joined: Fri Feb 10, 2012 4:25 am