Button CLASS - Ambercroft/TFT_eSPI GitHub Wiki

Button class

TFT_eSPI_Button CLASS

Button functions

initButton( TFT_eSPI *gfx, int16_t XC, int16_t YC, uint16_t W, uint16_t H, uint16_t OUTLINE_C, uint16_t FILL_C, uint16_t TEXT_C, char *TEXT, uint8_t TEXT_s);

Classic button has origin at the centre of the button. See initButtonUL.

  • XC, YC >> Origin is centre of button.
  • W, H >> Width & Height of button.
  • OUTLINE_C >> Colour to outline text.
  • FILL_C >> Fill colour.
  • TEXT_C >> Text colour.
  • TEXT >> " " or * to text.
  • TEXT_s >> Text size. 0 - 255

initButtonUL( TFT_eSPI *gfx, int16_t X1, int16_t Y1, uint16_t W, uint16_t H, uint16_t OUTLINE_C, uint16_t FILL_C, uint16_t TEXT_C, char *TEXT, uint8_t TEXT_s);

Updated button function. Origin is at upper left (UL).

  • X1, Y1 >> Origin at upper left.
  • W, H >> Width & Height of button.
  • OUTLINE_C >> Colour to outline text.
  • FILL_C >> Fill colour.
  • TEXT_C >> Text colour.
  • TEXT >> " " or * to text.
  • TEXT_s >> Text size. 0 - 255

setLabelDatum(int16_t x_delta, int16_t y_delta, uint8_t datum);

Adjust label datum. Is this perm?? just for buttons??

  • x_delta >>
  • y_delta >>
  • datum >>

drawButton(bool INVERT, String TEXT);

Draw the button once everything is setup.

  • INVERT >> TRUE, Swap the text and button colours.
  • TEXT >> Text to display on button.
    REF initButtonUL() initButton()

contains(int16_t X, int16_t Y);

  • X,Y >> Coordinates to check

Returns bool >> TRUE if in button area.

press(BOOL STATE);

Set the button to a state.
Records/remembers the last state.

  • STATE >> TRUE/FALSE

isPressed();

What is the state of the button?
Returns BOOL >> TRUE/FALSE ?? is pressed always TRUE ??

justPressed();

Was the button pressed since it was last checked?
Returns BOOL >> TRUE/FALSE

justReleased();

Was the button released since it was last checked?
Returns BOOL >> TRUE/FALSE


SORT ME

Put function here if uncertain the position to be placed on page.