Label¶
The label is an output element and displays a formatted text. It is a function and only manages display.
Configure¶
Ensure the GUI library is included and initialised according to the configuration procedure.
As a function, the label element requires no configuration.
Use¶
1 2 3 4 5 6 |
|
dLabel()
displays the label.
The required parameters are
-
The first line specifies the vector coordinates: top-left coordinates x-y then width and height in pixels;
-
The second line contains the text to be displayed;
-
The third line sets the text colour and the background colour.
The optional parameters are
- The fourth line is optional and specifies the horizontal and vertical formatting:
Value | Horizontal | Vertical |
---|---|---|
-1 | Left | Bottom |
0 | Centre | Middle |
+1 | Right | Top |
Default is 0
, 0
for centre-middle.
- The fifth line is optional: the size of the font, by default
fontSizeAutomatic
for automatic.
If fontSizeAutomatic
is set, smaller fonts are checked to display the whole text. Otherwise, the text is truncated.
- The sixth line is optional and performs partial flush in local delegate mode.
Example¶
This is the core of the code from example GUI_Label.ino
.
void displayLabel()
{
myScreen.setOrientation(myOrientation);
uint16_t x, y, dx, dy;
x = myScreen.screenSizeX();
y = myScreen.screenSizeY();
dx = x / 3;
dy = y / 4;
myGUI.delegatePartial(false);
dLabel(0, 0, x, dy, "Label", myColours.black, myColours.white, -1, 1, fontLarge);
drawNext();
myScreen.flushFast();
char * stringH[] = {"Left", "Centre", "Right"};
char * stringV[] = {"Bottom", "Middle", "Top"};
for (int8_t i = -1; i < 2; i++)
{
for (int8_t j = -1; j < 2; j++)
{
dLabel(dx + i * dx, dy + j * dy + dy, dx, dy, formatString(" %s % s ", stringH[i + 1], stringV[j + 1]), myColours.black, myColours.white, i, j, fontSmall, true);
}
}
for (int8_t k = 0; k < 3; k++)
{
myScreen.dLine(0, dy + k * dy, x, 1, myColours.grey);
myScreen.dLine(dx * k, dy, 1, dy * 3, myColours.grey);
}
// Grid
myScreen.dLine(0, y - 1, x, 1, myColours.grey);
myScreen.dLine(x - 1, dy, 1, dy * 3, myColours.grey);
myScreen.flushFast();
myGUI.delegatePartial(true);
while (!checkNext())
{
delay(10);
}
}