0

Button label not show
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Button label not show

by andromeda92 on Mon Jan 28, 2019 1:16 pm

the code below don't show label on buttons.

Code: Select all | TOGGLE FULL SIZE
...
/* create 15 buttons, in classic candybar phone style */
char buttonlabels[15][5] = {"Send", "Clr", "End", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#" };

uint16_t buttoncolors[15] = {RA8875_MAGENTA, RA8875_CYAN, RA8875_RED,
                             RA8875_BLUE, RA8875_BLUE, RA8875_BLUE,
                             RA8875_BLUE, RA8875_BLUE, RA8875_BLUE,
                             RA8875_BLUE, RA8875_BLUE, RA8875_BLUE,
                             RA8875_GREEN, RA8875_BLUE, RA8875_GREEN};
...

 
  // With hardware accelleration this is instant
  tft.fillScreen(RA8875_BLACK);
 
   // create buttons
  for (uint8_t row=0; row<5; row++)
    {
      for (uint8_t col=0; col<3; col++)
      {
        buttons[col + row*3].initButton(&tft, BUTTON_X+col*(BUTTON_W+BUTTON_SPACING_X), BUTTON_Y+row*(BUTTON_H+BUTTON_SPACING_Y),    // x, y, w, h, outline, fill, text
                    BUTTON_W, BUTTON_H, RA8875_WHITE, buttoncolors[col+row*3], RA8875_WHITE,
                    buttonlabels[col + row*3], 0);
                 
        buttons[col + row*3].drawButton(false);
       
      }
  }

...



Any idea ?

RA8875 + 5" tft with resistive touchscreen from adafruit. library Adafruit_RA8875 1.04, Adafruit_GFX v1.3.6, arduino 1.8.8, teensy 3.6.

andromeda92
 
Posts: 8
Joined: Sun Jan 20, 2019 6:08 pm

Re: Button label not show

by andromeda92 on Fri Feb 01, 2019 1:55 pm

I resolved with code below

Code: Select all | TOGGLE FULL SIZE
void printLabel(Adafruit_RA8875 tft, int16_t x1, int16_t y1, uint16_t w, uint16_t h, uint16_t fillColor, uint16_t textcolor, char *label, uint8_t textsize)

  tft.textMode();
  tft.textSetCursor(x1 + (w/2) - (strlen(label) * 3 * textsize), y1 + (h/2) - (4 * textsize) );
  tft.textColor(textcolor, fillColor);
  tft.textEnlarge(0);
  tft.textWrite(label);
  tft.graphicsMode();
}

andromeda92
 
Posts: 8
Joined: Sun Jan 20, 2019 6:08 pm

Please be positive and constructive with your questions and comments.