Skip to content

Text


createText

  • Use: To create a Text element

  • Definition: createText(String text_data, long font_size, long x, long y, uint32_t fg_color, bool hasBackground, uint32_t bg_color , long padding_x , long padding_y, bool center_align_x, bool center_align_y, String id)

  • Parameters:

    • String text_data : The String of the Text to be displayed
    • long font_size : The font size of the Text in px
    • long x : The position of the Text from its top-left corner along x-axis (horizontal) of the screen in px
    • long y : The position of the Text from its top-left corner along y-axis (vertical) of the screen in px
    • uint32_t fg_color : The color of the Text to be displayed ( you can use the color() function to apply RGB values directly )
    • bool hasBackground : This flag should be set to true to set the background color of the Text
    • uint32_t bg_color : The color of the Background of the Text ( you can use the color() function to apply RGB values directly ). This will be only applied if hasBackground flag is set to true
    • long padding_x : The padding on left & right sides of the Text in px
    • long padding_y : The padding on top & bottom sides of the Text in px
    • bool center_align_x : This flag should be set to true for the Text to center-align horizontally
    • bool center_align_y : This flag should be set to true for the Text to center-align vertically
    • String id : ID of the Text element as a String
  • Returns: ID of the Text element as a String


createTextBox

  • Use: To create a Text Box (Multi-Line text) element

  • Definition: createTextBox(String text_data, long font_size, long x, long y, long w, long h, uint32_t text_color, bool hasBackground, uint32_t bg_color , long padding_x , long padding_y, bool center_align_x, bool center_align_y, String id)

  • Parameters:

    • String text_data : The String of the Text to be displayed
    • long font_size : The font size of the Text in px
    • long x : The position of the Text from its top-left corner along x-axis (horizontal) of the screen in px
    • long y : The position of the Text from its top-left corner along y-axis (vertical) of the screen in px
    • long w : The width of the Text Box in px
    • long h : The height of the Text Box in px
    • uint32_t text_color : The color of the Text to be displayed ( you can use the color() function to apply RGB values directly )
    • bool hasBackground : This flag should be set to true to set the background color of the Text
    • uint32_t bg_color : The color of the Background of the Text ( you can use the color() function to apply RGB values directly ). This will be only applied if hasBackground flag is set to true
    • long padding_x : The padding on left & right sides of the Text in px
    • long padding_y : The padding on top & bottom sides of the Text in px
    • bool center_align_x : This flag should be set to true for the Text to center-align horizontally
    • bool center_align_y : This flag should be set to true for the Text to center-align vertically
    • String id : ID of the Text element as a String
  • Returns: ID of the Text Box element as a String


updateText

  • Use: To update/change the text of a pre-created Text element

  • Definition: updateText(String id, String value)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • String value : The new value of the Text as a String
  • Returns: Nothing


updateTextColor

  • Use: To update/change the color of a pre-created Text element

  • Definition: updateTextColor(String id, uint32_t new_color)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • uint32_t new_color : The new color of the Text ( you can use the color() function to apply RGB values directly )
  • Returns: Nothing


updateTextFont

  • Use: To update/change the font of a pre-created Text element

  • Definition: updateTextFont(String id, Font font)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • Font font : The new font for the Text. You need to pass a pre-created font object to it
  • Returns: Nothing


addUnderline

  • Use: To add underline to a pre-created Text element

  • Definition: addUnderline(String id, uint32_t color)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • uint32_t color : The color for the underline ( you can use the color() function to apply RGB values directly )
  • Returns: Nothing


addStrikeThrough

  • Use: To add strike-through to a pre-created Text element

  • Definition: addStrikeThrough(String id, uint32_t color)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • uint32_t color : The color for the strike-through ( you can use the color() function to apply RGB values directly )
  • Returns: Nothing


setFontWeight

  • Use: To add strike-through to a pre-created Text element

  • Definition: setFontWeight(String id, int font_weight)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • int font_weight : The font-weight for the Text. Supported values are: 100,200,300,400,500,600,700,800,900
  • Returns: Nothing

Note

This feature depends on the font family & is only applicable if the font supports it.


setTextNormal

  • Use: To set the font-style of a pre-created Text element to Normal (Removes Bold & Italics Styles)

  • Definition: setTextNormal(String id)

  • Parameters:

    • String id : The ID of the pre-created Text element
  • Returns: Nothing


setTextBold

  • Use: To set the font-style of a pre-created Text element to Bold

  • Definition: setTextBold(String id)

  • Parameters:

    • String id : The ID of the pre-created Text element
  • Returns: Nothing


setTextItalic

  • Use: To set the font-style of a pre-created Text element to Italic

  • Definition: setTextItalic(String id)

  • Parameters:

    • String id : The ID of the pre-created Text element
  • Returns: Nothing


setTextAlignment

  • Use: To set the alignment of a pre-created Text element

  • Definition: setTextAlignment(String id, int alignment)

  • Parameters:

    • String id : The ID of the pre-created Text element
    • int alignment : The alignment of the Text. Supported values are: CENTER_ALIGN, LEFT_ALIGN, RIGHT_ALIGN, JUSTIFY_TEXT
  • Returns: Nothing