px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_gfx.h : Basic monochrome graphics library

Description

A basic monochrome (1 bit per pixel) graphics library.

File(s):

Tool to convert images and fonts: Ruison.com LCD Image Converter

Tool template files:

Tool preset file:

Data Structures

struct  px_gfx_img_t
 Image definition. More...
 
struct  px_gfx_font_t
 Font definition. More...
 
struct  px_gfx_area_t
 Area definition. More...
 
struct  px_gfx_view_port_t
 View port definition. More...
 

Typedefs

typedef int16_t px_gfx_xy_t
 Size definition of an X or Y coordinate. More...
 

Enumerations

enum  px_gfx_color_t
 Foreground and background color definitions. More...
 
enum  px_gfx_align_t {
  PX_GFX_ALIGN_V_TOP = 0x00 , PX_GFX_ALIGN_V_MID = 0x01 , PX_GFX_ALIGN_V_BOT = 0x02 , PX_GFX_ALIGN_H_LEFT = 0x00 ,
  PX_GFX_ALIGN_H_MID = 0x10 , PX_GFX_ALIGN_H_RIGHT = 0x20
}
 Alignment definition. More...
 
enum  px_gfx_xy_ref_t { PX_GFX_XY_REF_REL = 0 , PX_GFX_XY_REF_ABS }
 X Y coordinate reference. More...
 

Functions

void px_gfx_init (void)
 Initialise graphics library. More...
 
void px_gfx_buf_clear (void)
 Clear display buffer. More...
 
void px_gfx_draw (void)
 Redraw whole display using display buffer. More...
 
void px_gfx_draw_update (void)
 Update display with total area that has changed in display buffer. More...
 
bool px_gfx_update_area_get (px_gfx_area_t *area)
 Get total area of frame that has changed. More...
 
void px_gfx_draw_prop_reset (void)
 Reset drawing properties to default. More...
 
px_gfx_color_t px_gfx_color_fg_set (px_gfx_color_t color)
 Set the new foreground drawing color. More...
 
px_gfx_color_t px_gfx_color_bg_set (px_gfx_color_t color)
 Set the new background drawing color. More...
 
px_gfx_align_t px_gfx_align_set (px_gfx_align_t align)
 Set the new alignment. More...
 
void px_gfx_view_port_set (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t width, px_gfx_xy_t height, px_gfx_xy_ref_t xy_ref)
 Set a drawing view port. More...
 
void px_gfx_view_port_reset (void)
 Reset view port. More...
 
const px_gfx_font_tpx_gfx_font_set (const px_gfx_font_t *font)
 Set the new font. More...
 
void px_gfx_draw_pixel (px_gfx_xy_t x, px_gfx_xy_t y)
 Draw a pixel using the current foreground color. More...
 
void px_gfx_draw_line (px_gfx_xy_t x1, px_gfx_xy_t y1, px_gfx_xy_t x2, px_gfx_xy_t y2)
 Draw a line using the current foreground color. More...
 
void px_gfx_draw_line_hor (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t width)
 Draw a horizontal line using the current foreground color. More...
 
void px_gfx_draw_line_ver (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t height)
 Draw a vertical line using the current foreground color. More...
 
void px_gfx_draw_rect (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t width, px_gfx_xy_t height)
 Draw a rectangle using the current foreground color. More...
 
void px_gfx_draw_fill_fg (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t width, px_gfx_xy_t height)
 Draw a solid rectangular fill in the current foreground color. More...
 
void px_gfx_draw_fill_bg (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t width, px_gfx_xy_t height)
 Draw a solid rectangular fill in the current background color. More...
 
void px_gfx_draw_circ (px_gfx_xy_t x, px_gfx_xy_t y, px_gfx_xy_t radius)
 Draw a circle using the current foreground color. More...
 
void px_gfx_draw_img (px_gfx_xy_t x, px_gfx_xy_t y, const px_gfx_img_t *img)
 Draw a graphic image using the current foreground and background color. More...
 
void px_gfx_draw_char (px_gfx_xy_t x, px_gfx_xy_t y, char glyph)
 Draw a font character using the current foreground color. More...
 
void px_gfx_draw_str (px_gfx_xy_t x, px_gfx_xy_t y, const char *str)
 Draw a font string using the current foreground color. More...
 
void px_gfx_printf (px_gfx_xy_t x, px_gfx_xy_t y, const char *format,...)
 Draw a formatted font string using the current foreground color. More...
 

Convenience coordinate definitions

#define PX_GFX_X_MIN   0
 
#define PX_GFX_X_MID   (PX_GFX_DISP_SIZE_X / 2)
 
#define PX_GFX_X_MAX   (PX_GFX_DISP_SIZE_X - 1)
 
#define PX_GFX_Y_MIN   0
 
#define PX_GFX_Y_MID   (PX_GFX_DISP_SIZE_Y / 2)
 
#define PX_GFX_Y_MAX   (PX_GFX_DISP_SIZE_Y - 1)
 

Convenience alignment combination definitions

#define PX_GFX_ALIGN_TOP_LEFT   (px_gfx_align_t)(PX_GFX_ALIGN_V_TOP | PX_GFX_ALIGN_H_LEFT )
 
#define PX_GFX_ALIGN_TOP_MID   (px_gfx_align_t)(PX_GFX_ALIGN_V_TOP | PX_GFX_ALIGN_H_MID )
 
#define PX_GFX_ALIGN_TOP_RIGHT   (px_gfx_align_t)(PX_GFX_ALIGN_V_TOP | PX_GFX_ALIGN_H_RIGHT)
 
#define PX_GFX_ALIGN_MID   (px_gfx_align_t)(PX_GFX_ALIGN_V_MID | PX_GFX_ALIGN_H_MID )
 
#define PX_GFX_ALIGN_BOT_LEFT   (px_gfx_align_t)(PX_GFX_ALIGN_V_BOT | PX_GFX_ALIGN_H_LEFT )
 
#define PX_GFX_ALIGN_BOT_MID   (px_gfx_align_t)(PX_GFX_ALIGN_V_BOT | PX_GFX_ALIGN_H_MID )
 
#define PX_GFX_ALIGN_BOT_RIGHT   (px_gfx_align_t)(PX_GFX_ALIGN_V_BOT | PX_GFX_ALIGN_H_RIGHT)
 

Data Structure Documentation

◆ px_gfx_img_t

struct px_gfx_img_t

Image definition.

Definition at line 115 of file px_gfx.h.

◆ px_gfx_font_t

struct px_gfx_font_t

Font definition.

Definition at line 123 of file px_gfx.h.

◆ px_gfx_area_t

struct px_gfx_area_t

Area definition.

Definition at line 131 of file px_gfx.h.

Data Fields
px_gfx_xy_t x1 Left.
px_gfx_xy_t y1 Top.
px_gfx_xy_t x2 Right.
px_gfx_xy_t y2 Bottom.

◆ px_gfx_view_port_t

struct px_gfx_view_port_t

View port definition.

Definition at line 147 of file px_gfx.h.

Data Fields
px_gfx_xy_t x Left.
px_gfx_xy_t y Top.
px_gfx_xy_t width Width.
px_gfx_xy_t height Height.
px_gfx_xy_ref_t xy_ref Coordinate reference.

Typedef Documentation

◆ px_gfx_xy_t

typedef int16_t px_gfx_xy_t

Size definition of an X or Y coordinate.

Definition at line 71 of file px_gfx.h.

Enumeration Type Documentation

◆ px_gfx_color_t

Foreground and background color definitions.

Definition at line 84 of file px_gfx.h.

◆ px_gfx_align_t

Alignment definition.

Enumerator
PX_GFX_ALIGN_V_TOP 

Vertical (y) top.

PX_GFX_ALIGN_V_MID 

Vertical (y) middle.

PX_GFX_ALIGN_V_BOT 

Vertical (y) bottom.

PX_GFX_ALIGN_H_LEFT 

Horizontal (x) left.

PX_GFX_ALIGN_H_MID 

Horizontal (x) middle.

PX_GFX_ALIGN_H_RIGHT 

Horizontal (x) right.

Definition at line 93 of file px_gfx.h.

◆ px_gfx_xy_ref_t

X Y coordinate reference.

Enumerator
PX_GFX_XY_REF_REL 

Coordinate references are relative to view port.

PX_GFX_XY_REF_ABS 

Coordinate references are absolute (relative to display)

Definition at line 140 of file px_gfx.h.

Function Documentation

◆ px_gfx_init()

void px_gfx_init ( void  )

Initialise graphics library.

Definition at line 177 of file px_gfx.c.

◆ px_gfx_buf_clear()

void px_gfx_buf_clear ( void  )

Clear display buffer.

Definition at line 183 of file px_gfx.c.

◆ px_gfx_draw()

void px_gfx_draw ( void  )

Redraw whole display using display buffer.

Definition at line 190 of file px_gfx.c.

◆ px_gfx_draw_update()

void px_gfx_draw_update ( void  )

Update display with total area that has changed in display buffer.

Definition at line 197 of file px_gfx.c.

◆ px_gfx_update_area_get()

bool px_gfx_update_area_get ( px_gfx_area_t area)

Get total area of frame that has changed.

Parameters
areaPointer to structure to contain area that has changed
Return values
trueframe buffer has changed
falseframe buffer has stayed the same (no change)

Definition at line 206 of file px_gfx.c.

◆ px_gfx_draw_prop_reset()

void px_gfx_draw_prop_reset ( void  )

Reset drawing properties to default.

Definition at line 213 of file px_gfx.c.

◆ px_gfx_color_fg_set()

px_gfx_color_t px_gfx_color_fg_set ( px_gfx_color_t  color)

Set the new foreground drawing color.

Parameters
colorNew drawing color
Returns
px_gfx_color_t Old drawing color

Definition at line 218 of file px_gfx.c.

◆ px_gfx_color_bg_set()

px_gfx_color_t px_gfx_color_bg_set ( px_gfx_color_t  color)

Set the new background drawing color.

Parameters
colorNew drawing color
Returns
px_gfx_color_t Old drawing color

Definition at line 226 of file px_gfx.c.

◆ px_gfx_align_set()

px_gfx_align_t px_gfx_align_set ( px_gfx_align_t  align)

Set the new alignment.

Parameters
alignNew alignment
Returns
px_gfx_align_t Old alignment

Definition at line 234 of file px_gfx.c.

◆ px_gfx_view_port_set()

void px_gfx_view_port_set ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  width,
px_gfx_xy_t  height,
px_gfx_xy_ref_t  xy_ref 
)

Set a drawing view port.

Pixels outside the view port is clipped. Drawing coordinates can relative to the top left corner of the view port with the PX_GFX_XY_REF_REL option or absolute (relative to the top left corner of the display) using the PX_GFX_XY_REF_ABS option.

Parameters
xTop left X coordinate of view port
yTop left Y coordinate of view port
widthWidth of view port
heightHeight of view port
xy_refCoordinate are absolute (to display) or relative to view port

Definition at line 242 of file px_gfx.c.

◆ px_gfx_view_port_reset()

void px_gfx_view_port_reset ( void  )

Reset view port.

The view port is set to the whole display.

Definition at line 252 of file px_gfx.c.

◆ px_gfx_font_set()

const px_gfx_font_t * px_gfx_font_set ( const px_gfx_font_t font)

Set the new font.

Parameters
fontNew font
Returns
px_gfx_font_t * Old font

Definition at line 258 of file px_gfx.c.

◆ px_gfx_draw_pixel()

void px_gfx_draw_pixel ( px_gfx_xy_t  x,
px_gfx_xy_t  y 
)

Draw a pixel using the current foreground color.

Parameters
xX coordinate of pixel
yY coordinate of pixel

Definition at line 266 of file px_gfx.c.

◆ px_gfx_draw_line()

void px_gfx_draw_line ( px_gfx_xy_t  x1,
px_gfx_xy_t  y1,
px_gfx_xy_t  x2,
px_gfx_xy_t  y2 
)

Draw a line using the current foreground color.

Parameters
x1X coordinate of start point of the line
y1Y coordinate of start point of the line
x2X coordinate of end point of the line
y2Y coordinate of end point of the line

Definition at line 277 of file px_gfx.c.

◆ px_gfx_draw_line_hor()

void px_gfx_draw_line_hor ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  width 
)

Draw a horizontal line using the current foreground color.

Parameters
xX coordinate of left point of the line
yX coordinate of left point of the line
widthWidth of the line (right)

Definition at line 404 of file px_gfx.c.

◆ px_gfx_draw_line_ver()

void px_gfx_draw_line_ver ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  height 
)

Draw a vertical line using the current foreground color.

Parameters
xX coordinate of top point of the line
yX coordinate of top point of the line
heightHeight of the line (down)

Definition at line 421 of file px_gfx.c.

◆ px_gfx_draw_rect()

void px_gfx_draw_rect ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  width,
px_gfx_xy_t  height 
)

Draw a rectangle using the current foreground color.

Parameters
xX coordinate of top left point of rectangle
yY coordinate of top left point of rectangle
widthWidth of rectangle (right)
heightHeight of rectangle (down)

Definition at line 438 of file px_gfx.c.

◆ px_gfx_draw_fill_fg()

void px_gfx_draw_fill_fg ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  width,
px_gfx_xy_t  height 
)

Draw a solid rectangular fill in the current foreground color.

Parameters
xX coordinate of top left point of fill
yY coordinate of top left point of fill
widthWidth of fill (right)
heightHeight of fill (down)

Definition at line 446 of file px_gfx.c.

◆ px_gfx_draw_fill_bg()

void px_gfx_draw_fill_bg ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  width,
px_gfx_xy_t  height 
)

Draw a solid rectangular fill in the current background color.

Parameters
xX coordinate of top left point of fill
yY coordinate of top left point of fill
widthWidth of fill (right)
heightHeight of fill (down)

Definition at line 465 of file px_gfx.c.

◆ px_gfx_draw_circ()

void px_gfx_draw_circ ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
px_gfx_xy_t  radius 
)

Draw a circle using the current foreground color.

Parameters
xX coordinate of the circle center.
yX coordinate of the circle center.
radiusRadius of the circle.

Definition at line 484 of file px_gfx.c.

◆ px_gfx_draw_img()

void px_gfx_draw_img ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
const px_gfx_img_t img 
)

Draw a graphic image using the current foreground and background color.

Parameters
xX coordinate of image
yY coordinate of image
imgPointer to image structure

Definition at line 537 of file px_gfx.c.

◆ px_gfx_draw_char()

void px_gfx_draw_char ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
char  glyph 
)

Draw a font character using the current foreground color.

Parameters
xX coordinate of font character
yY coordinate of font character
glyphCharacter in font to draw

Definition at line 608 of file px_gfx.c.

◆ px_gfx_draw_str()

void px_gfx_draw_str ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
const char *  str 
)

Draw a font string using the current foreground color.

Parameters
xX coordinate of starting point of string
yY coordinate of starting point of string
strString to draw

Definition at line 641 of file px_gfx.c.

◆ px_gfx_printf()

void px_gfx_printf ( px_gfx_xy_t  x,
px_gfx_xy_t  y,
const char *  format,
  ... 
)

Draw a formatted font string using the current foreground color.

Parameters
xX coordinate of starting point of string
yY coordinate of starting point of string
formatFormat string

Definition at line 680 of file px_gfx.c.