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)





Absolute path of icon file


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






void setup()


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


 int icons = 170;

 int gap = 47;

 int columns = 17;


 /* Start building a screen frame */



for (int i = 0 ; i < icons; i++) {

   int x = gap * (i % columns);

   int y = gap * (i / columns);


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

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



/* Display completed screen frame */




void loop() { }





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.





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