Before aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Marcussacapuces91/doc-TFT_eSPI/llms.txt
Use this file to discover all available pages before exploring further.
TFT_eSPI_Button can be drawn it must be initialised with geometry, colours, and a label. Two initialisation variants exist: initButton() positions the button by its centre point, which is convenient when you already know where you want the middle of the button to sit; initButtonUL() positions it by its upper-left corner, which is more natural when you are laying out a grid of buttons from a fixed origin. Once initialised, drawButton() renders the button at any time — call it again with inverted = true to show a visual pressed state.
initButton()
Initialises the button using the centre coordinate (x, y).
Pointer to the
TFT_eSPI display instance the button should be drawn on. Pass &tft when your display object is named tft.Horizontal centre of the button in screen pixels.
Vertical centre of the button in screen pixels.
Width of the button in pixels.
Height of the button in pixels.
16-bit RGB565 colour for the button border. Use any
TFT_* colour constant or a value from color565().16-bit RGB565 background fill colour for the button body.
16-bit RGB565 colour for the label text rendered inside the button.
Null-terminated C string to display as the button label. The string is copied internally so it is safe to pass a stack buffer.
Integer size multiplier for the built-in bitmap font.
1 = 6×8 px per character, 2 = 12×16 px, and so on.initButtonUL()
Identical to initButton() but positions the button by its upper-left corner (x1, y1) instead of its centre. All other parameters have the same meaning.
Pointer to the
TFT_eSPI display instance.Horizontal coordinate of the left edge of the button in screen pixels.
Vertical coordinate of the top edge of the button in screen pixels.
Width of the button in pixels.
Height of the button in pixels.
16-bit RGB565 border colour.
16-bit RGB565 background fill colour.
16-bit RGB565 label text colour.
Null-terminated label string.
Font size multiplier.
setLabelDatum()
Adjusts where the label text is anchored inside the button, relative to the button centre, and which text alignment datum is used.
Horizontal pixel offset to shift the label from the button centre. Positive values move the label right.
Vertical pixel offset to shift the label from the button centre. Positive values move the label down.
Text alignment datum constant — one of the
*_DATUM values (e.g. MC_DATUM, TL_DATUM). Defaults to MC_DATUM (middle-centre). See the Datum Constants reference for all values.drawButton()
Renders the button on the display. Call this after initButton() / initButtonUL() and again any time the visual state should update.
When
true, the fill and outline colours are swapped, producing a visually “pressed” appearance. Defaults to false (normal state).If non-empty, this string is rendered as the label instead of the one supplied to
initButton(). Useful for updating a button’s text on the fly without reinitialising it. Defaults to "" (use the stored label).