h. Loading Icons

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 03 - Displaying Bitmaps & Icons >

h. Loading Icons

This section shows how to load an icon file and get the handle that can be passed to the Bitmap() command along with (x,y) coordinate to draw an icon. The LoadIcon() command is used to load the icon file.

 

 

Command Prototype

 

uint16_t LoadIcon(const char* FileName, int16_t index)

 

Parameters

Description

FilenName

Absolute path of icon file

index

The value that is used to select a particular icon from the icon file

 

 

Code

 

 

void setup()

{

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

 /* Start building a screen frame */

 CleO.Start();

 

 for (int i = 0; i < 100; i++)

{

   int x = 40 * (i % 8);

   int y = 40 * (i / 8);

 

  /* first parameter - handle to icon random() % 900 - index in the bitmap (x, y) coordinate at which icons needs to be drawn */

   CleO.Bitmap(CleO.LoadIcon("@Icons/m36.ftico", i), x, y);

 }

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

In the above code snippet, after calling the LoadIcon() command to get the handle and passing it as a parameter to the Bitmap() command, the (x, y) coordinates are manipulated using the loop.

The random() command is used to select the random indices from the icon bitmap file.

Use the @ symbol only when performing the file operation from the eFlash and not from the SD Card.

 

Note: Users may not see the icons content if the background color is white.

 

 

Output

 

Here is the output displayed upon executing the above code snippet -

 

Tutorials03-LoadingICONs