Skip to content


The table is an input element and displays a table with multiple columns and lines.



Ensure the GUI library is included and initialised according to the configuration procedure.

Table myTable(&myGUI);

The constructor Table() creates a table and sets the link to the GUI myGUI.

Legacy version 5

table myTable;
The constructor table() creates a table.

myTable.dDefine(dx / 2, dy, dx * 4, dy * 4, 
    4, 3);

dDefine() defines the table with vector coordinates.

The required parameters are

  • The first line specifies the vector coordinates: top-left coordinates x-y then width and height in pixels.

The optional parameter is

  • The second line is optional and specifies the numbers of columns and lines, by default four columns and three lines.

By default, the table is not enabled.



drawInitial() draws the initial table with empty cells.

setState() defines whether touch is enabled for the element.


  • stateDisabled or false for touch disabled;
  • stateEnabled or true for touch enabled.


Use literals instead of values for upward compatibility.

By default, the table is not enabled.


if (myTable.check())
    uint8_t indexColumn, indexLine;
    myTable.getIndex(indexColumn, indexLine);

    myTable.draw(indexColumn, indexLine,, patternSquare);

check() polls the touch controller and returns true if the table is pressed.

An optional parameter defines the mode of how the element is checked:

  • checkNormal for normal check mode;
  • checkInstant for instant check mode.

Default mode is normal check mode.

In normal check mode, the element raises the event when the finger is released from the element. Additionally, the element goes through a cinematic sequence.

Start, press, release

In instant check mode, the element raises the event when the finger touches the element. No cinematic sequence is performed.

Start, press

The application note Optimise GUI speed provides more details on the cinematic sequences of each check mode.

getIndex() provides the indexes of the column and the line previously touched. The indexes start at 0.

draw() displays the cell at the column and line indexes with two optional parameters: colour and pattern.

The defaults options are black for colour and solid square for pattern.

Available patterns are:

  • patternCircle for empty circle;
  • patternCircleSolid for solid circle;
  • patternSquare for empty square; and
  • patternSquareSolid for solid square.


This is the core of the code from example GUI_Table.ino.

void displayTable()
    uint16_t x, y, dx, dy;

    x = myScreen.screenSizeX();
    y = myScreen.screenSizeY();
    dx = x / 5;
    dy = y / 5;


    myGUI.dLabel(0, 0, x, dy, "Table",, myColours.white, -1, 1, fontLarge);

    const uint8_t maxColumn = 4;
    const uint8_t maxLine = 3;
    Table myTable(&myGUI);
    myTable.dDefine(dx / 2, dy, dx * 4, dy * 4, maxColumn, maxLine);
    uint16_t colours[maxColumn][maxLine];
    for (uint8_t i = 0; i < maxColumn; i++)
        for (uint8_t j = 0; j < maxLine; j++)
            colours[i][j] = myColours.white;


    uint8_t indexColumn, indexLine;
    while (!checkNext())
        if (myTable.check())
            myTable.getIndex(indexColumn, indexLine);

            if (colours[indexColumn][indexLine] == myColours.white)
                colours[indexColumn][indexLine] = myColours.grey;
            else if (colours[indexColumn][indexLine] == myColours.grey)
                colours[indexColumn][indexLine] =;
            else if (colours[indexColumn][indexLine] ==
                colours[indexColumn][indexLine] = myColours.white;

            myTable.draw(indexColumn, indexLine, colours[indexColumn][indexLine]);