Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

changeLabelTextColor()

Mammad900 edited this page Sep 2, 2020 · 1 revision

changeLabelTextColor(page, index, value)

Summary

Changes the color of a label (e.g. a green label becomes red)

Parameters

  1. Page (int) : The number of the page which contains the label
  2. Index (int) : The index of the label relative to it's containing page.
  3. Value (uint16_t) : The new color for the label (a 16-bit RGB565 color value)

Returns

Nothing

Example

void displayError(String message){
   changeLabelText(PAGE_CONNECT, STATUS_LABEL, message);
   changeLabelTextColor(PAGE_CONNECT, STATUS_LABEL, TFT_RED); // TFT_RED is defined in MCUFRIEND_kbv library, but you should define PAGE_CONNECT and STATUS_LABEL yourself
}

Output

Source

void changeLabelTextColor(int page, int i, uint16_t val) {
    if (label_textColor[page][i] != val) {
        HCT
        label_textColor[page][i] = val;
        if (CurrentPage == page)
            drawlabel(page, i);
    }
}

Note: HCT is a macro for making the rest of the library aware that something has changed.

Clone this wiki locally