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

changeLabelYPos()

Mammad900 edited this page Feb 28, 2021 · 1 revision

changeLabelYPos(page, index, value)

Summary

Changes the Y position of a label (moves a label to bottom or top)

Parameters

  1. page (int) : The number of the page which contains the label
  2. index (int) : Index of the label relative to it's containing page.
  3. value (uint16_t) : The new Y position for the label

Returns

Nothing

Example

void onNewDeviceDetected(deviceInfo* devI){
    deviceCount++;
    changeLabelYPos(PAGE_LIST,PAGE_LIST_STATUS,deviceCount*50+10); //Move the label to bottom so it is below the last visible button.
    changeButtonProperty(PAGE_LIST,deviceCount,VISIBLE,true,false); //Make the button visible (false is used for compiler disambiguation)
    changeButtonProperty(PAGE_LIST,deviceCount,TEXT,devI->name,false); //Change button text (operator '->' is the same as '.' but is used in pointers)
}

Output

When a new device is added (onNewDeviceDetected is called), the label is moved to bottom and a button is made visible.

Source

void changeLabelYPos(int page, int i, uint16_t val) {
    if (label_Ypos[page][i] != val) {
        HCT
        if (CurrentPage == page) {
            undrawlabel(page, i);
            label_Ypos[page][i] = val;
            drawlabel(page, i);
        }
        else
            label_Ypos[page][i] = val;
    }
}

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

Clone this wiki locally