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

changeLabelXPos()

Mammad900 edited this page Feb 28, 2021 · 1 revision

changeLabelXPos(page, index, value)

Summary

Changes the X position of a label (moves a label to left or right)

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 X position for the label

Returns

Nothing

Example

void onNewDeviceDetected(deviceInfo* devI){
    deviceCount++;
    changeLabelXPos(PAGE_LIST,PAGE_LIST_STATUS,deviceCount*60+10); //Move the label to right so it is beside 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 the right and a button is made visible.

Source

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

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

Clone this wiki locally