Firmware SDK
twr_gfx

Graphics library. More...

Data Structures

struct  twr_gfx_caps_t
 Display size. More...
 
struct  twr_gfx_driver_t
 Display driver interface. More...
 
struct  twr_gfx_t
 Instance. More...
 

Enumerations

enum  twr_gfx_rotation_t {
  TWR_GFX_ROTATION_0 = 0 ,
  TWR_GFX_ROTATION_90 = 1 ,
  TWR_GFX_ROTATION_180 = 2 ,
  TWR_GFX_ROTATION_270 = 3
}
 Rotation. More...
 
enum  twr_gfx_round_corner_t {
  TWR_GFX_ROUND_CORNER_RIGHT_TOP = 0x01 ,
  TWR_GFX_ROUND_CORNER_RIGHT_BOTTOM = 0x02 ,
  TWR_GFX_ROUND_CORNER_LEFT_BOTTOM = 0x04 ,
  TWR_GFX_ROUND_CORNER_LEFT_TOP = 0x08
}
 

Functions

void twr_gfx_init (twr_gfx_t *self, void *display, const twr_gfx_driver_t *driver)
 Initialize button. More...
 
bool twr_gfx_display_is_ready (twr_gfx_t *self)
 Check if display driver is ready for commands. More...
 
twr_gfx_caps_t twr_gfx_get_caps (twr_gfx_t *self)
 Get Display capabilities. More...
 
void twr_gfx_clear (twr_gfx_t *self)
 Clear. More...
 
void twr_gfx_set_font (twr_gfx_t *self, const twr_font_t *font)
 Set font. More...
 
void twr_gfx_set_rotation (twr_gfx_t *self, twr_gfx_rotation_t rotation)
 Set rotation. More...
 
twr_gfx_rotation_t twr_gfx_get_rotation (twr_gfx_t *self)
 Get rotation. More...
 
void twr_gfx_draw_pixel (twr_gfx_t *self, int x, int y, uint32_t color)
 Draw pixel. More...
 
int twr_gfx_draw_char (twr_gfx_t *self, int left, int top, uint8_t ch, uint32_t color)
 Display draw char. More...
 
int twr_gfx_calc_char_width (twr_gfx_t *self, uint8_t ch)
 Calc width character. More...
 
int twr_gfx_draw_string (twr_gfx_t *self, int left, int top, char *str, uint32_t color)
 Display draw string. More...
 
int twr_gfx_calc_string_width (twr_gfx_t *self, char *str)
 Calc width string. More...
 
int twr_gfx_printf (twr_gfx_t *self, int left, int top, uint32_t color, char *format,...)
 Display string. More...
 
void twr_gfx_draw_line (twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
 Display draw line. More...
 
void twr_gfx_draw_rectangle (twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
 Display draw rectangle. More...
 
void twr_gfx_draw_fill_rectangle (twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
 Display draw fill rectangle. More...
 
void twr_gfx_draw_fill_rectangle_dithering (twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
 Display draw fill rectangle with a dithering pattern defined in the color parameter. More...
 
void twr_gfx_draw_fill_rectangle_dithering_color (twr_gfx_t *self, int x0, int y0, int x1, int y1, uint16_t pattern, uint32_t color_fg, uint32_t color_bg)
 Display draw fill rectangle with a dithering pattern defined in the pattern parameter, with the support for multicolor dithering. More...
 
void twr_gfx_draw_circle (twr_gfx_t *self, int x0, int y0, int radius, uint32_t color)
 Lcd draw circle, using Midpoint circle algorithm. More...
 
void twr_gfx_draw_fill_circle (twr_gfx_t *self, int x0, int y0, int radius, uint32_t color)
 Lcd draw fill circle, using Midpoint circle algorithm. More...
 
void twr_gfx_draw_round_corner (twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color)
 Lcd draw round corner, using Midpoint circle algorithm. More...
 
void twr_gfx_draw_fill_round_corner (twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color)
 Lcd draw fill round corner, using Midpoint circle algorithm. More...
 
bool twr_gfx_update (twr_gfx_t *self)
 Display update, send data. More...
 

Detailed Description

Graphics library.

Enumeration Type Documentation

◆ twr_gfx_rotation_t

Rotation.

Enumerator
TWR_GFX_ROTATION_0 

Rotation 0 degrees.

TWR_GFX_ROTATION_90 

Rotation 90 degrees.

TWR_GFX_ROTATION_180 

Rotation 180 degrees.

TWR_GFX_ROTATION_270 

Rotation 270 degrees.

Definition at line 46 of file twr_gfx.h.

◆ twr_gfx_round_corner_t

Enumerator
TWR_GFX_ROUND_CORNER_RIGHT_TOP 

Round corner right top.

TWR_GFX_ROUND_CORNER_RIGHT_BOTTOM 

Round corner right bottom.

TWR_GFX_ROUND_CORNER_LEFT_BOTTOM 

Round corner left bottom.

TWR_GFX_ROUND_CORNER_LEFT_TOP 

Round corner left top.

Definition at line 62 of file twr_gfx.h.

Function Documentation

◆ twr_gfx_calc_char_width()

int twr_gfx_calc_char_width ( twr_gfx_t self,
uint8_t  ch 
)

Calc width character.

Parameters
[in]selfInstance
Returns
Width of printed character

Definition at line 132 of file twr_gfx.c.

Referenced by twr_gfx_calc_string_width().

Here is the caller graph for this function:

◆ twr_gfx_calc_string_width()

int twr_gfx_calc_string_width ( twr_gfx_t self,
char *  str 
)

Calc width string.

Parameters
[in]selfInstance
[in]*strString to be printed
Returns
Width of printed string

Definition at line 162 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_clear()

void twr_gfx_clear ( twr_gfx_t self)

Clear.

Parameters
[in]selfInstance

Definition at line 22 of file twr_gfx.c.

Referenced by twr_module_lcd_clear(), and twr_module_lcd_init().

Here is the caller graph for this function:

◆ twr_gfx_display_is_ready()

bool twr_gfx_display_is_ready ( twr_gfx_t self)

Check if display driver is ready for commands.

Parameters
[in]selfInstance
Returns
true If ready
false If not ready

Definition at line 12 of file twr_gfx.c.

Referenced by twr_module_lcd_is_ready().

Here is the caller graph for this function:

◆ twr_gfx_draw_char()

int twr_gfx_draw_char ( twr_gfx_t self,
int  left,
int  top,
uint8_t  ch,
uint32_t  color 
)

Display draw char.

Parameters
[in]selfInstance
[in]leftPixels from left edge
[in]topPixels from top edge
[in]chChar to be printed
[in]color
Returns
Width of printed character

Definition at line 86 of file twr_gfx.c.

Referenced by twr_gfx_draw_string(), and twr_module_lcd_draw_char().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gfx_draw_circle()

void twr_gfx_draw_circle ( twr_gfx_t self,
int  x0,
int  y0,
int  radius,
uint32_t  color 
)

Lcd draw circle, using Midpoint circle algorithm.

Parameters
[in]selfInstance
[in]x0Center - pixels from left edge
[in]y0Center - pixels from top edge
[in]radiusIn pixels
[in]color

Definition at line 328 of file twr_gfx.c.

Referenced by twr_module_lcd_draw_circle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gfx_draw_fill_circle()

void twr_gfx_draw_fill_circle ( twr_gfx_t self,
int  x0,
int  y0,
int  radius,
uint32_t  color 
)

Lcd draw fill circle, using Midpoint circle algorithm.

Parameters
[in]selfInstance
[in]x0Center - pixels from left edge
[in]y0Center - pixels from top edge
[in]radiusIn pixels
[in]color

Definition at line 363 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_fill_rectangle()

void twr_gfx_draw_fill_rectangle ( twr_gfx_t self,
int  x0,
int  y0,
int  x1,
int  y1,
uint32_t  color 
)

Display draw fill rectangle.

Parameters
[in]selfInstance
[in]x0Pixels from left edge
[in]y0Pixels from top edge
[in]x1Pixels from left edge
[in]y1Pixels from top edge
[in]color

Definition at line 286 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_fill_rectangle_dithering()

void twr_gfx_draw_fill_rectangle_dithering ( twr_gfx_t self,
int  x0,
int  y0,
int  x1,
int  y1,
uint32_t  color 
)

Display draw fill rectangle with a dithering pattern defined in the color parameter.

Parameters
[in]selfInstance
[in]x0Pixels from left edge
[in]y0Pixels from top edge
[in]x1Pixels from left edge
[in]y1Pixels from top edge
[in]colorDithering mask, 16 bits define bit pattern in the 4 by 4 area

Definition at line 298 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_fill_rectangle_dithering_color()

void twr_gfx_draw_fill_rectangle_dithering_color ( twr_gfx_t self,
int  x0,
int  y0,
int  x1,
int  y1,
uint16_t  pattern,
uint32_t  color_fg,
uint32_t  color_bg 
)

Display draw fill rectangle with a dithering pattern defined in the pattern parameter, with the support for multicolor dithering.

Parameters
[in]selfInstance
[in]x0Pixels from left edge
[in]y0Pixels from top edge
[in]x1Pixels from left edge
[in]y1Pixels from top edge
[in]patternDithering mask, 16 bits define bit pattern in the 4 by 4 area
[in]color_fgColor used for the foreground of the rectangle
[in]color_bgColor used for the background of the rectangle

Definition at line 313 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_fill_round_corner()

void twr_gfx_draw_fill_round_corner ( twr_gfx_t self,
int  x0,
int  y0,
int  radius,
twr_gfx_round_corner_t  corner,
uint32_t  color 
)

Lcd draw fill round corner, using Midpoint circle algorithm.

Parameters
[in]selfInstance
[in]x0Center - pixels from left edge
[in]y0Center - pixels from top edge
[in]cornerposition
[in]radiusIn pixels
[in]color

Definition at line 442 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_line()

void twr_gfx_draw_line ( twr_gfx_t self,
int  x0,
int  y0,
int  x1,
int  y1,
uint32_t  color 
)

Display draw line.

Parameters
[in]selfInstance
[in]x0Pixels from left edge
[in]y0Pixels from top edge
[in]x1Pixels from left edge
[in]y1Pixels from top edge
[in]color

Definition at line 188 of file twr_gfx.c.

Referenced by twr_gfx_draw_fill_circle(), twr_gfx_draw_fill_round_corner(), twr_gfx_draw_rectangle(), and twr_module_lcd_draw_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gfx_draw_pixel()

void twr_gfx_draw_pixel ( twr_gfx_t self,
int  x,
int  y,
uint32_t  color 
)

Draw pixel.

Parameters
[in]selfInstance
[in]leftPixels from left edge
[in]topPixels from top edge
[in]color

Definition at line 42 of file twr_gfx.c.

Referenced by twr_gfx_draw_char(), twr_gfx_draw_circle(), twr_gfx_draw_fill_rectangle(), twr_gfx_draw_fill_rectangle_dithering(), twr_gfx_draw_fill_rectangle_dithering_color(), twr_gfx_draw_line(), twr_gfx_draw_round_corner(), twr_module_lcd_draw_image(), and twr_module_lcd_draw_pixel().

Here is the caller graph for this function:

◆ twr_gfx_draw_rectangle()

void twr_gfx_draw_rectangle ( twr_gfx_t self,
int  x0,
int  y0,
int  x1,
int  y1,
uint32_t  color 
)

Display draw rectangle.

Parameters
[in]selfInstance
[in]x0Pixels from left edge
[in]y0Pixels from top edge
[in]x1Pixels from left edge
[in]y1Pixels from top edge
[in]color

Definition at line 278 of file twr_gfx.c.

Referenced by twr_module_lcd_draw_rectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gfx_draw_round_corner()

void twr_gfx_draw_round_corner ( twr_gfx_t self,
int  x0,
int  y0,
int  radius,
twr_gfx_round_corner_t  corner,
uint32_t  color 
)

Lcd draw round corner, using Midpoint circle algorithm.

Parameters
[in]selfInstance
[in]x0Center - pixels from left edge
[in]y0Center - pixels from top edge
[in]cornerposition
[in]radiusIn pixels
[in]color

Definition at line 393 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_draw_string()

int twr_gfx_draw_string ( twr_gfx_t self,
int  left,
int  top,
char *  str,
uint32_t  color 
)

Display draw string.

Parameters
[in]selfInstance
[in]leftPixels from left edge
[in]topPixels from top edge
[in]*strString to be printed
[in]color
Returns
Width of printed string

Definition at line 152 of file twr_gfx.c.

Referenced by twr_gfx_printf(), and twr_module_lcd_draw_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_gfx_get_caps()

twr_gfx_caps_t twr_gfx_get_caps ( twr_gfx_t self)

Get Display capabilities.

Parameters
[in]selfInstance

Definition at line 17 of file twr_gfx.c.

◆ twr_gfx_get_rotation()

twr_gfx_rotation_t twr_gfx_get_rotation ( twr_gfx_t self)

Get rotation.

Parameters
[in]selfInstance
Returns
Rotation of display

Definition at line 37 of file twr_gfx.c.

Referenced by twr_module_lcd_get_rotation().

Here is the caller graph for this function:

◆ twr_gfx_init()

void twr_gfx_init ( twr_gfx_t self,
void *  display,
const twr_gfx_driver_t driver 
)

Initialize button.

Parameters
[in]selfInstance

Definition at line 3 of file twr_gfx.c.

Referenced by twr_module_lcd_init().

Here is the caller graph for this function:

◆ twr_gfx_printf()

int twr_gfx_printf ( twr_gfx_t self,
int  left,
int  top,
uint32_t  color,
char *  format,
  ... 
)

Display string.

Parameters
[in]selfInstance
[in]leftPixels from left edge
[in]topPixels from top edge
[in]color
[in]formatFormat string (printf style)
[in]...Optional format arguments
Returns
Width of printed string

Definition at line 173 of file twr_gfx.c.

Here is the call graph for this function:

◆ twr_gfx_set_font()

void twr_gfx_set_font ( twr_gfx_t self,
const twr_font_t font 
)

Set font.

Parameters
[in]selfInstance
[in]*fontFont

Definition at line 27 of file twr_gfx.c.

Referenced by twr_module_lcd_set_font().

Here is the caller graph for this function:

◆ twr_gfx_set_rotation()

void twr_gfx_set_rotation ( twr_gfx_t self,
twr_gfx_rotation_t  rotation 
)

Set rotation.

Parameters
[in]selfInstance
[in]rotationRotation of diplay

Definition at line 32 of file twr_gfx.c.

Referenced by twr_module_lcd_set_rotation().

Here is the caller graph for this function:

◆ twr_gfx_update()

bool twr_gfx_update ( twr_gfx_t self)

Display update, send data.

Parameters
[in]selfInstance
Returns
true On success
false On failure

Definition at line 491 of file twr_gfx.c.

Referenced by twr_module_lcd_update().

Here is the caller graph for this function: