mikroSDK Reference Manual
Basic Library Configuration

Basic Library Configuration API Reference. More...

Functions list

void gl_set_driver (gl_driver_t *driver)
 Sets the driver to the active state and enables drawing on whole display. More...
 
void gl_clear (gl_color_t color)
 Paint whole display. More...
 
void gl_clear_inside_borders (gl_color_t color)
 Paint display within crop borders. More...
 
bool gl_set_crop_borders (gl_coord_t left, gl_coord_t right, gl_coord_t top, gl_coord_t bottom)
 Initialize borders for drawing on display. More...
 
void gl_set_font (const uint8_t *font)
 Initialize the active font. More...
 
void gl_set_font_orientation (gl_font_orientation_t orientation)
 Sets the active font orientation. More...
 
void gl_set_pen (gl_color_t color, uint16_t width)
 Sets the active pen width and color. More...
 
void gl_set_pen_color (gl_color_t color)
 Sets the active pen's color. More...
 
void gl_set_pen_width (uint16_t width)
 Sets the active pen width. More...
 
void gl_set_inner_pen (uint16_t width_inside_object)
 Sets width of inner part of active pen. More...
 
uint16_t gl_get_inner_pen ()
 Returns the inner width of active pen. More...
 
void gl_set_outer_pen (uint16_t width_outside_object)
 Sets width of outer part of active pen. More...
 
uint16_t gl_get_outer_pen ()
 Returns the outer width of active pen. More...
 
void gl_set_brush_style (gl_brush_style_t style)
 Sets active brush style. More...
 
void gl_set_brush_color (gl_color_t color)
 Sets active brush color. More...
 
void gl_set_brush_color_from (gl_color_t color)
 Sets the active start color. More...
 
void gl_set_brush_color_to (gl_color_t color)
 Sets the active end color. More...
 
void gl_set_font_background_color (gl_color_t background)
 Sets the active background color for texts. More...
 
void gl_set_font_background (bool enable)
 Sets active indicator for text background. More...
 
uint16_t gl_get_screen_width ()
 Returns the width of the display. More...
 
uint16_t gl_get_screen_height ()
 Returns the height of the display. More...
 

Detailed Description

It has the active state that can be changed by using this header's function. Active state stores all information needed in drawing time for concluding on wich of various ways the drawing should be performed. The order of setting active state in most case is not important, but there are some exceptions. For example it is the best to first set driver. Also there are default values for the most of variables. But driver must be set by user.

The list of variables in active state :

Function Documentation

◆ gl_set_driver()

void gl_set_driver ( gl_driver_t driver)

Sets the driver to the active state and enables drawing on whole display. The given driver should contain information about display's width and height and, the most important, pointer to funciton for drawing one rectangle into the display. If driver is NULL any future drawing will not be executed and the old one will be forgotten (but not deleted).

Parameters
[in]driverthe driver that will be set as active. See gl_driver_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// no driver is set, so any function that needs it's information is ignored
gl_set_pen(GL_ORANGE, 2); // not ingored
gl_draw_line(-30, 150, 75, 350); // ignored
// prepare display for drawing
gl_set_driver(&driver);
gl_clear(GL_WHITE); // not ingored
gl_draw_circle(55, 50, 15); // not ignored
// remove display, and again everything that needs it's information will be ignored
gl_set_driver(NULL);
gl_draw_line(55, 40, gl_get_screen_width() - 30, 30); // ignored
// set driver again to enable drawing
gl_set_driver(&driver);
gl_draw_circle(55, 100, 15); // not ignored
}

◆ gl_clear()

void gl_clear ( gl_color_t  color)

Paint whole display with color. Borders set by user using gl_set_crop_borders will be ignored.

Parameters
[in]colorThe color that is used for painting. See gl_color_t definition for detailed explanation.
Returns
Nothing.
See also
gl_clear_inside_borders

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
for ( ; ; )
{
gl_clear(GL_WHITE); // white
gl_clear(GL_GREEN); // green
gl_clear(GL_HEX2COLOR(0xff0000)); // red
gl_clear(GL_RGB2COLOR(0,0,0)); // black
}
}

◆ gl_clear_inside_borders()

void gl_clear_inside_borders ( gl_color_t  color)

Paint display with color within crop borders. Only portion of the screen covered by crop borders will cleared with color. See gl_set_crop_borders for details on setting crop borders.

Parameters
[in]colorThe color that is used for painting. See gl_color_t definition for detailed explanation.
Returns
Nothing.
Precondition
The driver must be before because of drawing.
See also
gl_clear

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
// same as gl_clear(GL_YELLOW);
// clear only part of display
for ( ; ; )
{
}
}

◆ gl_set_crop_borders()

bool gl_set_crop_borders ( gl_coord_t  left,
gl_coord_t  right,
gl_coord_t  top,
gl_coord_t  bottom 
)

Initialize borders for drawing on display by calculating the intersection of display's borders and rectangle determined by left, top, bottom and right and change borders of active state to calculated ones. It affects every future drawing by cropping every part of the text or object which cross the set borders. If rectangle between left, top, bottom and right coordinates is completely out of display or left is greater then right or top is greater then bottom, then state will be same as if function was called with 0, 0, display_height, display_width, and whole display is available for future drawing. Every border is given by its coordinate. Left and right is given by x-axis and top and bottom by y-axis. Function accepts values for a rectangle that has no area, in that case no future drawings will be visible. By default, crop borders are set to make entire screen visible. See gl_coord_t definition for detailed explanation.

Parameters
[in]leftLeft border.
[in]topTop border.
[in]bottomBottom border.
[in]rightRight border.
Returns
If the driver is not set returns false, otherwise returns true.
Precondition
The driver must be set first since only after that the dimension (borders) of display is known.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// when function is called before driver is set, then function returns false
if(gl_set_crop_borders(100, 200, 100, 200) != false )
return; // will not exit
// set driver
gl_set_driver(&driver);
if(gl_set_crop_borders(100, 200, 100, 200) != true )
return; // will not exit
gl_set_pen_width(0); // turn off pen.
/* valid parametars handling */
gl_set_crop_borders(125,175, 125, 175);
gl_draw_rect(150, 150, 50,50); // cropped, only top left qarter is visible
gl_draw_rect(100, 100, 50,50); // cropped, only bottom right qarter is visible
/* invalid parametars handling */
// when some coordinates are out of display, then they are corrected
gl_set_crop_borders(200, 3000, 200, 1000); // bottom and right corrected
gl_draw_rect(50, 50, 50, 50); // not drawn
gl_set_crop_borders(-1, 3, 0, 3); // invalid params, negative coord, left is corrected
gl_draw_rect(150, 50, 50, 50); // not_drawn
gl_set_crop_borders(10, 9, 0, 10); // invalid params, 'left' is more to the right than 'right', full screen visible
gl_draw_rect(250, 50, 50, 50); // drawn
gl_set_crop_borders(0, 300, 300, 0); // invalid params, 'top' is more to the bottom than 'bottom', full screen visible
gl_draw_rect(350, 50, 50, 50); // drawn
// when parameters are completly out of display, then full screen is visible
gl_draw_rect(50, 150, 50, 50); // drawn
// when parameters represent a rectangle with no area, then nothing will be drawn
gl_set_crop_borders(250,250, 150,250); // non existant crop frame
gl_draw_rect(250, 150, 50, 50); // drawn
gl_set_crop_borders(350,400,150,150); // non existant crop frame
gl_draw_rect(350, 150, 50, 50); // not drawn
}

◆ gl_set_font()

void gl_set_font ( const uint8_t *  font)

Initialize the active font to font. Active font is used for every text drawing.

Parameters
[in]fontThe font generated by NECTO Studio.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
#include "conversions.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void print_size(gl_size_t size, gl_coord_t y)
{
char str_buff[10];
uint16_to_str(size.width,str_buff);
gl_draw_text(str_buff, size.width+50, y);
uint16_to_str(size.height, str_buff);
gl_draw_text(str_buff, size.width+50+40, y);
}
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// when font is not set, text is ignored and text has no size
gl_draw_text("Ignored Text", 50, 50);
gl_size_t size_no_font = gl_get_text_dimensions("Ignored Text");
// when font is set, text visible and text has size
gl_set_font(test_font); // set font
gl_draw_text("Hello world", 50, 80);
gl_size_t size_with_font = gl_get_text_dimensions("Hello World");
// font can be removed, then again text is ignored and text has no size
gl_set_font(NULL); // remove font
gl_draw_text("Back to invisible", 50, 110);
gl_size_t size_removed_font = gl_get_text_dimensions("Back to invisible");
// print sizes
gl_set_font(test_font); // set font again
print_size(size_no_font, 50);
print_size(size_with_font, 80);
print_size(size_removed_font, 110);
}

◆ gl_set_font_orientation()

void gl_set_font_orientation ( gl_font_orientation_t  orientation)

Sets the active font orientation to orientation. Active font orientation determines direction of string and characters inside string whenever text is drawn. Default font orientation is horizontal.

Parameters
[in]orientationthe font orientation. See gl_set_font_orientation definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_font(test_font); // set font
// default horizontal orientation
// x y coords are top left of text block, text goes to the left
gl_draw_text("Default horizontal", 0, 0);
// vertical orientation
// x y coords are bottom left of text block, text goes upwards
gl_draw_text("Vertical text", 0, 200);
// vertical column orientation
// x y coords are top left of text block, text goes downwards
gl_draw_text("Column text", 30, 30);
// back to horizontal
gl_draw_text("Vertical text", 60, 200);
}

◆ gl_set_pen()

void gl_set_pen ( gl_color_t  color,
uint16_t  width 
)

Sets the active pen width to width and its color to color. This affects every future drawing of shape by displaying pen so that one half of pen's width cover shape, and the rest of width is drew on the outside of shape.If the shape is less then inner part of pen, the rest of inner pen will just be ignored, it wont afect outer pen to change. Default pen color is red and pen width is 1 pixel.

Parameters
[in]colorthe color of the pen. See gl_color_t definition for detailed explanation.
[in]widththe width of the pen.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// use default pen
gl_draw_circle(50, 50, 20);
gl_draw_rect(183, 50, 20, 30);
gl_draw_rect_rounded(316, 50, 20, 30, 10);
gl_draw_arc(449, 50, 20, 0, 90);
gl_draw_line(582, 25, 620, 75);
gl_draw_point(715, 50);
// change pen color and width, this will set inner and outer pen to 1/2 of width given
gl_draw_circle(50, 150, 20);
gl_draw_rect(183, 150, 20, 30);
gl_draw_rect_rounded(316, 150, 20, 30, 10);
gl_draw_arc(449, 150, 20, 0, 90);
gl_draw_line(582, 125, 620, 175);
gl_draw_point(715, 150);
// set pen with generated colors, when width is odd number outer pen will be greater then inner for 1px
gl_set_pen(GL_HEX2COLOR(0x888888), 5);
gl_draw_circle(50, 250, 20);
gl_draw_rect(183, 250, 20, 30);
gl_draw_rect_rounded(316, 250, 20, 30, 10);
gl_draw_arc(449, 250, 20, 0, 90);
gl_draw_line(582, 225, 620, 275);
gl_draw_point(715, 250);
// when pen is a lot larger then shape surface, all surface will be covered by inner pen, and whole shape will be framed with outer pen
gl_set_pen(GL_RGB2COLOR(100,255,100), 40);
gl_draw_circle(50, 350, 20);
gl_draw_rect(183, 350, 20, 30);
gl_draw_rect_rounded(316, 350, 20, 30, 10);
gl_draw_arc(449, 350, 20, 0, 90);
gl_draw_line(582, 325, 620, 400);
gl_draw_point(715, 350);
}

◆ gl_set_pen_color()

void gl_set_pen_color ( gl_color_t  color)

Sets the active pen's color to color. This affects every future drawing of shape by painting pen in given color if pen width is not zero.

Parameters
[in]colorThe color of the pen. See gl_color_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_pen_width(10); // set pen width to demonstrate pen color
// use default pen color
gl_draw_circle(50, 50, 20);
gl_draw_rect(183, 50, 20, 30);
gl_draw_rect_rounded(316, 50, 20, 30, 10);
gl_draw_arc(449, 50, 20, 0, 90);
gl_draw_line(582, 25, 620, 75);
gl_draw_point(715, 50);
// change pen color using an alias
gl_draw_circle(50, 150, 20);
gl_draw_rect(183, 150, 20, 30);
gl_draw_rect_rounded(316, 150, 20, 30, 10);
gl_draw_arc(449, 150, 20, 0, 90);
gl_draw_line(582, 125, 620, 175);
gl_draw_point(715, 150);
// change pen color using hex value
gl_draw_circle(50, 250, 20);
gl_draw_rect(183, 250, 20, 30);
gl_draw_rect_rounded(316, 250, 20, 30, 10);
gl_draw_arc(449, 250, 20, 0, 90);
gl_draw_line(582, 225, 620, 275);
gl_draw_point(715, 250);
// change pen color using rgb values
gl_draw_circle(50, 350, 20);
gl_draw_rect(183, 350, 20, 30);
gl_draw_rect_rounded(316, 350, 20, 30, 10);
gl_draw_arc(449, 350, 20, 0, 90);
gl_draw_line(582, 325, 620, 400);
gl_draw_point(715, 350);
}

◆ gl_set_pen_width()

void gl_set_pen_width ( uint16_t  width)

Sets the active pen width to width. This affects every future drawing of shape by displaying pen so that one half of pen's width cover shape, and the rest of pen is drew on the outside of shape.

Parameters
[in]widththe width of the pen.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// use default pen width
gl_draw_circle(50, 50, 20);
gl_draw_rect(183, 50, 20, 30);
gl_draw_rect_rounded(316, 50, 20, 30, 10);
gl_draw_arc(449, 50, 20, 0, 90);
gl_draw_line(582, 25, 620, 75);
gl_draw_point(715, 50);
// change pen color and width, this will set inner and outer pen to 1/2 of width given
gl_draw_circle(50, 150, 20);
gl_draw_rect(183, 150, 20, 30);
gl_draw_rect_rounded(316, 150, 20, 30, 10);
gl_draw_arc(449, 150, 20, 0, 90);
gl_draw_line(582, 125, 620, 175);
gl_draw_point(715, 150);
// when width is odd number outer pen will be greater then inner for 1px
gl_draw_circle(50, 250, 20);
gl_draw_rect(183, 250, 20, 30);
gl_draw_rect_rounded(316, 250, 20, 30, 10);
gl_draw_arc(449, 250, 20, 0, 90);
gl_draw_line(582, 225, 620, 275);
gl_draw_point(715, 250);
// when pen is a lot larger then shape surface, all surface will be covered by inner pen, and whole shape will be framed with outer pen
gl_draw_circle(50, 350, 20);
gl_draw_rect(183, 350, 20, 30);
gl_draw_rect_rounded(316, 350, 20, 30, 10);
gl_draw_arc(449, 350, 20, 0, 90);
gl_draw_line(582, 325, 620, 400);
gl_draw_point(715, 350);
}

◆ gl_set_inner_pen()

void gl_set_inner_pen ( uint16_t  width_inside_object)

Sets width of inner part of active pen to width_inside_object. The old width of the pen drew on the outside of shape stays the same, ie. only width of inner part of shape is changed to given value. This affects every drawing of shape in the future. If the shape is less then inner part of pen, the rest of inner pen will just be ignored, it wont afect outer pen to change.

Parameters
[in]width_inside_objectthe width of inner pen, ie. part of pen that overlaps shape.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// default inner pen is 0 (what is visible is outer pen, et. pen that does not cover the shape)
gl_draw_circle(30, 30, 20);
// same inner pen
gl_draw_circle(30, 80, 20);
// change inner pen, this will increase pen over the shape
gl_draw_circle(80, 30, 20);
// when inner pen is greater then shape's surface, the size of shape wont change
gl_draw_circle(80, 80, 20);
// reset both outer and inner pen width
gl_draw_circle(130, 30, 20);
// reset width again
gl_draw_circle(180, 30, 20);
}

◆ gl_get_inner_pen()

uint16_t gl_get_inner_pen ( )

Returns the inner width of active pen.

Returns
the active pen's inner width, ie. part of pen that overlaps shape.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_pen_color(GL_YELLOW); // set pen yellow
/* green color is used to show right branch */
// default inner pen is 0
if (gl_get_inner_pen() == 0)
else
gl_draw_circle(100, 100, 20 );
// sanity check
if (gl_get_inner_pen() == 12)
else
gl_draw_circle(200, 100, 20 );
// check inner pen set by gl_set_pen_width
gl_set_pen_width(10); // even number: x/2
if (gl_get_inner_pen() == 5)
else
gl_draw_circle(300, 100, 20);
// check inner pen set by gl_set_pen (equivalent to one set with gl_set_pen_width)
gl_set_pen(GL_YELLOW, 27); // odd nubmer: (x-1)/2
if (gl_get_inner_pen() == 13)
else
gl_draw_circle(400, 100, 20);
}

◆ gl_set_outer_pen()

void gl_set_outer_pen ( uint16_t  width_outside_object)

Sets width of outer part of active pen to width_outside_object. The old width of the pen drew on the inside of shape stays the same, ie. only width of outer part of shape is changed to given value. This affects every drawing of shape in the future.If the shape is less then inner part of pen, the rest of inner pen will just be ignored, it won't affect outer pen to change.

Parameters
[in]width_outside_objectthe width of outer pen, ie. part of pen that doesn't overlap shape.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// default outer pen is 1 (what is visible is only outer pen, et. pen that does not cover the shape)
gl_draw_circle(30, 30, 20);
// same outer pen
gl_draw_circle(30, 100, 20);
// change outer pen, this will increase overall shape size
gl_draw_circle(100, 30, 20);
// outer pen can dramaticly increase shape size
gl_draw_circle(100, 100, 20);
// reset both outer and inner pen width
gl_draw_circle(170, 30, 20);
// reset width again
gl_draw_circle(240, 30, 20);
}

◆ gl_get_outer_pen()

uint16_t gl_get_outer_pen ( )

Returns the outer width of active pen.

Returns
the width of outer pen, ie. part of pen that doesn't overlap shape.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_pen_color(GL_YELLOW); // set pen yellow
/* green color is used to show right branch */
// default outer pen is 1
if (gl_get_outer_pen() == 1)
else
gl_draw_circle(100, 100, 20);
// sanity check
if (gl_get_outer_pen() == 12)
else
gl_draw_circle(200, 100, 20);
// check inner pen set by gl_set_pen_width
gl_set_pen_width(10); // even number: x/2
if (gl_get_outer_pen() == 5)
else
gl_draw_circle(300, 100, 20);
// check inner pen set by gl_set_pen (equivalent to one set with gl_set_pen_width)
gl_set_pen(GL_YELLOW, 27); // odd nubmer: (x+1)/2
if (gl_get_outer_pen() == 14)
else
gl_draw_circle(400, 100, 20);
}

◆ gl_set_brush_style()

void gl_set_brush_style ( gl_brush_style_t  style)

Sets active brush style to style. This affects every drawing in the future. By setting brush style its determined how shapes will be collored. Default style is GL_BRUSH_STYLE_FILL

Parameters
[in]stylea style for painting shapes. See gl_brush_style_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// default brush style with default colors
gl_draw_circle(30, 50, 20);
// default brush style with red brush
gl_draw_circle(30, 100, 20);
// left-right gradient with default gradient colors
gl_draw_circle(80, 50, 20);
// top-down gradient with default gradient colors
gl_draw_circle(130, 50, 20);
// left-right gradient with custom gradient colors
gl_draw_circle(80, 100, 20);
// top-down gradient with default gradient colors
gl_draw_circle(130, 100, 20);
// none style for brush (any color is ignored)
gl_draw_circle(180, 50, 20);
gl_draw_circle(200, 50, 20);
// the function affects only 2D shapes
gl_draw_line(10, 300, 110, 300); // not affected
gl_draw_point(10, 310); // not affected
}

◆ gl_set_brush_color()

void gl_set_brush_color ( gl_color_t  color)

Sets active brush color to color. This affects every drawing in the future when brush style if GL_BRUSH_STYLE_FILL. Default brush color is yellow.

Parameters
[in]colorthe color for painting non gradient style. See gl_color_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_pen_width(0); // turn off pen
gl_set_font(test_font);
/* shapes with no pen */
// default color
gl_draw_arc(20, 20, 20, 0, 80);
// color set with alias
gl_draw_circle(80, 20, 20);
// color set with HEX value
gl_draw_rect(140, 20, 20, 40);
// color set with RGB values
gl_draw_rect_rounded(200,20,30,50,5);
/* shapes with pen */
// outer pen does not cover brush painted surface
gl_draw_arc(20, 100, 20, 0, 80);
gl_draw_circle(80, 100, 20);
gl_draw_rect(140, 100, 20, 40);
gl_draw_rect_rounded(200,100,30,50,2);
// inner pen does cover brush painted surface
gl_draw_arc(20, 180, 20, 0, 80);
gl_draw_circle(80, 180, 20);
gl_draw_rect(140, 180, 20, 40);
gl_draw_rect_rounded(200,180,30,50,2);
// when inner pen is large enough, brush surface may completely be overpainted
gl_draw_arc(20, 290, 20, 0, 80);
gl_draw_circle(110, 290, 20);
gl_draw_rect(200, 290, 20, 40);
gl_draw_rect_rounded(290,290,30,50,2);
/* shapes that do not use brush */
gl_draw_line(20,370,50,430);
gl_draw_point(80,380);
// text also does not use brush
gl_draw_char('a', 140, 370);
gl_draw_text("Hello World", 190, 370);
}

◆ gl_set_brush_color_from()

void gl_set_brush_color_from ( gl_color_t  color)

Sets the active start color to color. The active start color is used whenever a drawing of shape with some of gradient style is performed. Default color is white.

Parameters
[in]colordetermines the color from which the gradient starts. See gl_color_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// default 'from color' is white
gl_draw_rect(5,10,40,80);
// set lime start
gl_draw_rect(50,10,40,80);
// 'from color' iz used only for gradient painting
gl_draw_rect(5,110,40,80); // lime color is ignored
gl_draw_rect(50,110,40,80); // lime color is ignored
gl_draw_rect(100,110,40,80); // lime color is used
gl_draw_rect(150,110,40,80); // lime color is used
}

◆ gl_set_brush_color_to()

void gl_set_brush_color_to ( gl_color_t  color)

Sets the active end color to color. The active end color is used whenever drawing of shape with some of gradient style is performed. Default color is black.

Parameters
[in]colordetermines the color with which the gradient ends. See gl_color_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
// default 'to color' is black
gl_draw_rect(5,10,40,80);
// set lime end
gl_draw_rect(50,10,40,80);
// 'to color' iz used only for gradient painting
gl_draw_rect(5,110,40,80); // lime color is ignored
gl_draw_rect(50,110,40,80); // lime color is ignored
gl_draw_rect(100,110,40,80); // lime color is used
gl_draw_rect(150,110,40,80); // lime color is used
}

◆ gl_set_font_background_color()

void gl_set_font_background_color ( gl_color_t  background)

Sets the active background color for texts to background. This will affect drawing text only if background is enabled. To enable drawing use gl_set_font_background. Default background color is white.

Parameters
[in]backgroundthe color of the background of character. See gl_color_t definition for detailed explanation.
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_font(test_font); // set font
// default background is off
gl_draw_text("No background", 10,0);
// enable background, use default color
gl_draw_text("Background", 10,30);
// set background and foreground color but disable background
gl_draw_text("No background again", 10, 60);
// show new background
gl_draw_text("New background", 10, 90);
// more colors
gl_draw_text("Newer background", 10, 120);
gl_draw_text("The newest background", 10, 150);
}

◆ gl_set_font_background()

void gl_set_font_background ( bool  enable)

Sets active indicator for text background to enable. Font background is disabled by default.

Parameters
[in]enablethe indicator for determining if background behind character should be painted.
See also
gl_set_font_background_color
Returns
Nothing.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_font(test_font); // set font
// default background is off
gl_draw_text("No background", 10, 0);
// enable background, use default color
gl_draw_text("Background", 10, 30);
// set background and foreground color but disable background
gl_draw_text("No background again", 10, 60);
// show new background
gl_draw_text("New background", 10, 90);
}

◆ gl_get_screen_width()

uint16_t gl_get_screen_width ( )

Returns the width of the display.

Returns
If the driver is not set returns zero, otherwise returns the width of the active display indicated by driver.
Precondition
The driver must be set first since only after that the dimension of display is known.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
#include "conversions.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
char str_buff[10];
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// driver is not set, screen width is 0,0
uint16_t screen_width_no_driver = gl_get_screen_width();
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
// actual screen width
uint16_t screen_width_with_driver = gl_get_screen_width();
// draw width values to screen
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_font(test_font); // set font
// result before setting driver
uint16_to_str(screen_width_no_driver, str_buff);
gl_draw_text("before driver is set:", 10, 0);
gl_draw_text(str_buff, 160,0 ); // draw 0
// result after setting driver
uint16_to_str(screen_width_with_driver, str_buff);
gl_draw_text("after driver is set:", 10, 20);
gl_draw_text(str_buff, 158, 20); // draw actual width
}

◆ gl_get_screen_height()

uint16_t gl_get_screen_height ( )

Returns the height of the display.

Returns
If the driver is not set returns zero, otherwise returns the height of the active display indicated by driver.
Precondition
The driver must be set first since only after that the dimension of display is known.

Example

#include "gl.h"
#include "board.h"
#include "tft8.h"
#include "resource.h"
#include "conversions.h"
static gl_driver_t driver;
static tft8_cfg_t tft_cfg;
void main()
{
char str_buff[10];
// initialize driver
TFT8_MAP_PINOUTS_16BIT(tft_cfg);
tft_cfg.board = &TFT_BOARD_7_CAPACITIVE;
tft8_init(&tft_cfg, &driver);
// when driver is not set, screen height is 0,0
uint16_t screen_height_no_driver = gl_get_screen_height();
// prepare display for drawing
gl_set_driver(&driver); // set initialized driver
// actual screen height
uint16_t screen_height_with_driver = gl_get_screen_height();
// draw width result to screen
gl_clear(GL_CHARLESTON_GREEN); // clear display
gl_set_font(test_font); // set font
// result before setting driver
uint16_to_str(screen_height_no_driver, str_buff );
gl_draw_text("before driver is set:", 10, 0 );
gl_draw_text(str_buff, 160,0 ); // draw 0
// result after setting driver
uint16_to_str(screen_height_with_driver, str_buff );
gl_draw_text("after driver is set:", 10, 20);
gl_draw_text(str_buff, 158, 20); // draw actual height
}
GL_FONT_VERTICAL_COLUMN
Definition: gl_types.h:87
gl_set_pen_color
void gl_set_pen_color(gl_color_t color)
Sets the active pen's color.
GL_BRUSH_STYLE_GRADIENT_TOP_DOWN
Definition: gl_types.h:61
GL_BLUE
Definition: gl_colors.h:101
gl_size_t::height
gl_uint_t height
Definition: gl_types.h:121
gl_set_font_background_color
void gl_set_font_background_color(gl_color_t background)
Sets the active background color for texts.
uint16_to_str
void uint16_to_str(uint16_t input, char *output)
Converts uint16_t to string.
gl_set_font_orientation
void gl_set_font_orientation(gl_font_orientation_t orientation)
Sets the active font orientation.
GL_LIME
Definition: gl_colors.h:174
gl_set_font
void gl_set_font(const uint8_t *font)
Initialize the active font.
gl_driver_t
The context structure for storing driver configuration.
Definition: gl_types.h:145
gl_set_brush_color
void gl_set_brush_color(gl_color_t color)
Sets active brush color.
GL_GREEN
Definition: gl_colors.h:147
GL_RED
Definition: gl_colors.h:212
GL_FONT_HORIZONTAL
Definition: gl_types.h:85
GL_CHARLESTON_GREEN
Definition: gl_colors.h:246
gl_draw_rect
void gl_draw_rect(gl_coord_t top_left_x, gl_coord_t top_left_y, gl_uint_t width, gl_uint_t height)
Draw a rectangle on display.
GL_YELLOW
Definition: gl_colors.h:238
gl_set_brush_color_from
void gl_set_brush_color_from(gl_color_t color)
Sets the active start color.
GL_ORANGE
Definition: gl_colors.h:197
gl_draw_text
void gl_draw_text(const char *__generic text, gl_coord_t x, gl_coord_t y)
Write a text on display.
GL_PINK
Definition: gl_colors.h:207
gl_set_pen_width
void gl_set_pen_width(uint16_t width)
Sets the active pen width.
gl_get_inner_pen
uint16_t gl_get_inner_pen()
Returns the inner width of active pen.
gl_get_screen_height
uint16_t gl_get_screen_height()
Returns the height of the display.
gl_set_driver
void gl_set_driver(gl_driver_t *driver)
Sets the driver to the active state and enables drawing on whole display.
gl_draw_char
void gl_draw_char(char ch, gl_coord_t x, gl_coord_t y)
Write a single character on a display.
conversions.h
Conversion function prototypes.
gl_draw_line
void gl_draw_line(gl_coord_t x1, gl_coord_t y1, gl_coord_t x2, gl_coord_t y2)
Draw a line on the display.
gl_get_screen_width
uint16_t gl_get_screen_width()
Returns the width of the display.
gl_set_crop_borders
bool gl_set_crop_borders(gl_coord_t left, gl_coord_t right, gl_coord_t top, gl_coord_t bottom)
Initialize borders for drawing on display.
gl_get_outer_pen
uint16_t gl_get_outer_pen()
Returns the outer width of active pen.
gl_clear_inside_borders
void gl_clear_inside_borders(gl_color_t color)
Paint display within crop borders.
gl_coord_t
int16_t gl_coord_t
Definition: gl_types.h:102
gl_set_font_background
void gl_set_font_background(bool enable)
Sets active indicator for text background.
GL_BRUSH_STYLE_GRADIENT_LEFT_RIGHT
Definition: gl_types.h:62
gl_size_t::width
gl_uint_t width
Definition: gl_types.h:120
GL_HEX2COLOR
#define GL_HEX2COLOR(hex)
Definition: gl_colors.h:60
gl_set_brush_style
void gl_set_brush_style(gl_brush_style_t style)
Sets active brush style.
gl_clear
void gl_clear(gl_color_t color)
Paint whole display.
GL_RGB2COLOR
#define GL_RGB2COLOR(r, g, b)
Definition: gl_colors.h:65
gl_set_brush_color_to
void gl_set_brush_color_to(gl_color_t color)
Sets the active end color.
GL_BRUSH_STYLE_NONE
Definition: gl_types.h:59
GL_FONT_VERTICAL
Definition: gl_types.h:86
GL_BRUSH_STYLE_FILL
Definition: gl_types.h:60
gl_draw_rect_rounded
void gl_draw_rect_rounded(gl_coord_t top_left_x, gl_coord_t top_left_y, gl_uint_t width, gl_uint_t height, gl_uint_t radius)
Draw a rounded rectangle on display.
gl_set_pen
void gl_set_pen(gl_color_t color, uint16_t width)
Sets the active pen width and color.
gl_set_outer_pen
void gl_set_outer_pen(uint16_t width_outside_object)
Sets width of outer part of active pen.
GL_DARK_GREEN
Definition: gl_colors.h:118
GL_BLACK
Definition: gl_colors.h:99
GL_PURPLE
Definition: gl_colors.h:210
gl.h
Graphics Library.
gl_draw_circle
void gl_draw_circle(gl_coord_t x0, gl_coord_t y0, gl_uint_t radius)
Draw a circle on display.
gl_get_text_dimensions
gl_size_t gl_get_text_dimensions(const char *__generic text)
Calculate text dimension.
gl_draw_arc
void gl_draw_arc(gl_coord_t x, gl_coord_t y, gl_uint_t radius, gl_angle_t start, gl_angle_t end)
Draw an arc on display.
gl_set_inner_pen
void gl_set_inner_pen(uint16_t width_inside_object)
Sets width of inner part of active pen.
gl_size_t
The context structure for storing width and height in number of pixels on the screen.
Definition: gl_types.h:118
GL_WHITE
Definition: gl_colors.h:236
gl_draw_point
void gl_draw_point(gl_coord_t x, gl_coord_t y)
Draw a point on display.