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

Soft Button Library for 2.8" TFT LCD

Postby owendelong » Sat Feb 25, 2012 11:27 pm

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: 51
Joined: Fri Feb 10, 2012 3:25 am

Re: Soft Button Library for 2.8" TFT LCD

Postby jjbridw » Sat Mar 03, 2012 12: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 2:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Postby owendelong » Sat Mar 03, 2012 7: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: 51
Joined: Fri Feb 10, 2012 3:25 am

Re: Soft Button Library for 2.8" TFT LCD

Postby jjbridw » Sat Mar 03, 2012 7: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 2:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Postby owendelong » Sat Mar 03, 2012 8: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: 51
Joined: Fri Feb 10, 2012 3:25 am

Re: Soft Button Library for 2.8" TFT LCD

Postby jjbridw » Sat Mar 03, 2012 9: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 2:31 pm

Re: Soft Button Library for 2.8" TFT LCD

Postby owendelong » Sat Mar 03, 2012 11:26 pm

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: 51
Joined: Fri Feb 10, 2012 3:25 am

Re: Soft Button Library for 2.8" TFT LCD

Postby JQ21 » Mon Jan 28, 2013 3: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 3:30 pm


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

Who is online

Users browsing this forum: No registered users and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]