This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
changeLabelXPos()
Mammad900 edited this page Feb 28, 2021
·
1 revision
Changes the X position of a label (moves a label to left or right)
- page (
int
) : The number of the page which contains the label - index (
int
) : Index of the label relative to it's containing page. - value (
uint16_t
) : The new X position for the label
Nothing
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)
}
When a new device is added (onNewDeviceDetected is called), the label is moved to the right and a button is made visible.
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.