Adafruit_GFX Buttons

Post Reply
bdbell
Posts: 29
Joined: Tue Apr 28, 2015 7:35 am

Adafruit_GFX Buttons

Post by bdbell » Sun Jan 28, 2018 1:38 pm

I am working on a project using a STM32F103 and ILI9341 - I have been using Adafruit_GFX_AS.h & Adafruit_ILI9341_STM.h libraries which is working well. But I have a lot of buttons, and I am finding that using Utouch with the Adafruit library makes creating and monitoring button presses very cumbersome.

I was looking for a graphical button library and realized that the original Adafruit library has it built in, but it seems to be missing from the STM version. I tried to add the Buttons functions but ran into a lot of problems. I also tried to switch to the non-STM version, but my sketch has too many calls to functions that don't exist in this version....

for example here is how I am currently handling the buttons:

//draw the rounded rectangle
tft.drawRoundRect(0, 0, 320, 82, 5, BLUE);

//print the text label
tft.setTextColor(WHITE, NAVY);
tft.setTextSize(2);
tft.setCursor(39,116);
tft.print("Button 1");

//read the touch screen values and compare to x/y button positions
if ((y>=86) && (y<=166)) {
if (x<=158) {

//highlight the border to show it is being pressed
waitForIt(0, 86, 158, 80);

and then of course whatever the button function is....using the button function from the newer Adafruit_GFX library would make this a lot easier to deal with if I could just get it working with the STM version. In the past I have used Utouch with Ubuttons, but that requires UTFT and I don't really want to deal with that. So I am wondering if anyone has any suggestions for a button library, or is there a version of Adafruit_GFX_AS that includes the button functions?

User avatar
BennehBoy
Posts: 503
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Adafruit_GFX Buttons

Post by BennehBoy » Sun Jan 28, 2018 2:14 pm

What are the offending functions that are removed from the new stock library?
-------------------------------------
https://github.com/BennehBoy

bdbell
Posts: 29
Joined: Tue Apr 28, 2015 7:35 am

Re: Adafruit_GFX Buttons

Post by bdbell » Sun Jan 28, 2018 2:42 pm

BennehBoy wrote:
Sun Jan 28, 2018 2:14 pm
What are the offending functions that are removed from the new stock library?
the following are not available in the stock library;

int16_t drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size);
int16_t drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size);
int16_t drawChar(char c, int16_t x, int16_t y, int16_t size);
int16_t drawString(char *string, int16_t poX, int16_t poY, int16_t size);
int16_t drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size);
int16_t drawRightString(char *string, int16_t dX, int16_t poY, int16_t size);
int16_t drawFloat(float floatNumber,int16_t decimal,int16_t poX, int16_t poY, int16_t size);

User avatar
BennehBoy
Posts: 503
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Adafruit_GFX Buttons

Post by BennehBoy » Sun Jan 28, 2018 3:50 pm

None of those look like they offer any functionality over and above the .print function of the accompanying screen library, am I missing something?
-------------------------------------
https://github.com/BennehBoy

bdbell
Posts: 29
Joined: Tue Apr 28, 2015 7:35 am

Re: Adafruit_GFX Buttons

Post by bdbell » Sun Jan 28, 2018 5:11 pm

BennehBoy wrote:
Sun Jan 28, 2018 3:50 pm
None of those look like they offer any functionality over and above the .print function of the accompanying screen library, am I missing something?
no they don't, but they do offer an easier way to deal with them - and when you have ~2k lines of code using these functions the easier way would be to find a library that includes them - which is why I was asking

Post Reply