DrawIconArray()

back to FEHIcon

Description

This is a powerful but complex function that is used to setup and draw an array of icons. It takes a previously declared array of Icon instances along with parameters to define the array’s shape (defined by rows and columns), position (defined by top, bottom, left, and right margins), labels (defined by an array of strings), and colors for the border and text. The strength of this function is in creating and defining many icons at once in a combined structure, similar to a kind of menu system.

Note that the example below simply shows how to draw a menu. For example, it does not show how to determine if a particular icon is pressed. Refer to the member functions of the Icon class for information on interacting with individual icons after the array has been drawn.

Syntax

FEHIcon::DrawIconArray(Icon icon[], int rows, int cols, int top, int bot, int left, int right, char labels[][20], unsigned int col, unsigned int txtcol);

Parameters

icon[]: array of instances of the Icon class; even if just a single icon is used, it must be declared as an array of size 1 in order to use it with this function
rows: integer number of rows for the array of icons
cols: integer number of columns for the array of icons
top: integer number of pixels from the top of the LCD to the top of the icon array (top margin)
bot: integer number of pixels from the bottom of the LCD to the bottom of the icon array (bottom margin)
left: integer number of pixels from the left of the LCD to the left of the icon array (left margin)
right: integer number of pixels from the right of the LCD to the right of the icon array (right margin)
labels[][20]: array of character strings for the labels for all the icons in the array; the labels will be used in order from left to right across a row of icons and then down to the next row
col: color designation for border of icon array (see LCDColors.h)
txtcol: color designation for text of icon array labels (see LCDColors.h)

Returns

None.

Examples

#include <FEHLCD.h>

int main(void)
{
    // declare an array of four icons called menu
    FEHIcon::Icon menu[4];

    // define the four menu labels
    char menu_labels[4][20] = {"START","PASSWORD","CREDITS","QUIT"};

    // draw the menu in a 2 by 2 array with top and bottom
    // margins of 10 and left and right margins of 5
    // with the menu labels, gold borders, and green text
    FEHIcon::DrawIconArray(menu, 2, 2, 10, 10, 5, 5, menu_labels, GOLD, GREEN);
}