Loading...
Searching...
No Matches
canvas.h File Reference

GUI: Canvas API. More...

#include <stdint.h>
#include <stddef.h>
#include <gui/icon_animation.h>
#include <gui/icon.h>

Go to the source code of this file.

Data Structures

struct  CanvasFontParameters
 Font parameters. More...
 

Typedefs

typedef struct Canvas Canvas
 Canvas anonymous structure.
 

Enumerations

enum  Color { ColorWhite = 0x00 , ColorBlack = 0x01 , ColorXOR = 0x02 }
 Color enumeration.
 
enum  Font {
  FontPrimary , FontSecondary , FontKeyboard , FontBigNumbers ,
  FontTotalNumber
}
 Fonts enumeration.
 
enum  Align {
  AlignLeft , AlignRight , AlignTop , AlignBottom ,
  AlignCenter
}
 Alignment enumeration.
 
enum  CanvasOrientation { CanvasOrientationHorizontal , CanvasOrientationHorizontalFlip , CanvasOrientationVertical , CanvasOrientationVerticalFlip }
 Canvas Orientation.
 
enum  CanvasDirection { CanvasDirectionLeftToRight , CanvasDirectionTopToBottom , CanvasDirectionRightToLeft , CanvasDirectionBottomToTop }
 Font Direction.
 
enum  IconFlip { IconFlipNone , IconFlipHorizontal , IconFlipVertical , IconFlipBoth }
 Icon flip.
 
enum  IconRotation { IconRotation0 , IconRotation90 , IconRotation180 , IconRotation270 }
 Icon rotation.
 

Functions

void canvas_reset (Canvas *canvas)
 Reset canvas drawing tools configuration.
 
void canvas_commit (Canvas *canvas)
 Commit canvas.
 
size_t canvas_width (const Canvas *canvas)
 Get Canvas width.
 
size_t canvas_height (const Canvas *canvas)
 Get Canvas height.
 
size_t canvas_current_font_height (const Canvas *canvas)
 Get current font height.
 
const CanvasFontParameterscanvas_get_font_params (const Canvas *canvas, Font font)
 Get font parameters.
 
void canvas_clear (Canvas *canvas)
 Clear canvas.
 
void canvas_set_color (Canvas *canvas, Color color)
 Set drawing color.
 
void canvas_set_font_direction (Canvas *canvas, CanvasDirection dir)
 Set font swap Argument String Rotation Description.
 
void canvas_invert_color (Canvas *canvas)
 Invert drawing color.
 
void canvas_set_font (Canvas *canvas, Font font)
 Set drawing font.
 
void canvas_set_custom_u8g2_font (Canvas *canvas, const uint8_t *font)
 Set custom drawing font.
 
void canvas_draw_str (Canvas *canvas, int32_t x, int32_t y, const char *str)
 Draw string at position of baseline defined by x, y.
 
void canvas_draw_str_aligned (Canvas *canvas, int32_t x, int32_t y, Align horizontal, Align vertical, const char *str)
 Draw aligned string defined by x, y.
 
uint16_t canvas_string_width (Canvas *canvas, const char *str)
 Get string width.
 
size_t canvas_glyph_width (Canvas *canvas, uint16_t symbol)
 Get glyph width.
 
void canvas_draw_bitmap (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, const uint8_t *compressed_bitmap_data)
 Draw bitmap picture at position defined by x,y.
 
void canvas_draw_icon_ex (Canvas *canvas, int32_t x, int32_t y, const Icon *icon, IconRotation rotation)
 Draw icon at position defined by x,y with rotation and flip.
 
void canvas_draw_icon_animation (Canvas *canvas, int32_t x, int32_t y, IconAnimation *icon_animation)
 Draw animation at position defined by x,y.
 
void canvas_draw_icon (Canvas *canvas, int32_t x, int32_t y, const Icon *icon)
 Draw icon at position defined by x,y.
 
void canvas_draw_xbm (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, const uint8_t *bitmap)
 Draw XBM bitmap.
 
void canvas_draw_xbm_ex (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, IconRotation rotation, const uint8_t *bitmap_data)
 Draw rotated XBM bitmap.
 
void canvas_draw_dot (Canvas *canvas, int32_t x, int32_t y)
 Draw dot at x,y.
 
void canvas_draw_box (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw box of width, height at x,y.
 
void canvas_draw_frame (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw frame of width, height at x,y.
 
void canvas_draw_line (Canvas *canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
 Draw line from x1,y1 to x2,y2.
 
void canvas_draw_circle (Canvas *canvas, int32_t x, int32_t y, size_t radius)
 Draw circle at x,y with radius r.
 
void canvas_draw_disc (Canvas *canvas, int32_t x, int32_t y, size_t radius)
 Draw disc at x,y with radius r.
 
void canvas_draw_triangle (Canvas *canvas, int32_t x, int32_t y, size_t base, size_t height, CanvasDirection dir)
 Draw triangle with given base and height lengths and their intersection coordinate.
 
void canvas_draw_glyph (Canvas *canvas, int32_t x, int32_t y, uint16_t ch)
 Draw glyph.
 
void canvas_set_bitmap_mode (Canvas *canvas, bool alpha)
 Set transparency mode.
 
void canvas_draw_rframe (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, size_t radius)
 Draw rounded-corner frame of width, height at x,y, with round value radius.
 
void canvas_draw_rbox (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, size_t radius)
 Draw rounded-corner box of width, height at x,y, with round value raduis.
 

Detailed Description

GUI: Canvas API.

Function Documentation

◆ canvas_clear()

void canvas_clear ( Canvas * canvas)

Clear canvas.

Parameters
canvasCanvas instance

◆ canvas_commit()

void canvas_commit ( Canvas * canvas)

Commit canvas.

Send buffer to display

Parameters
canvasCanvas instance

◆ canvas_current_font_height()

size_t canvas_current_font_height ( const Canvas * canvas)

Get current font height.

Parameters
canvasCanvas instance
Returns
height in pixels.

◆ canvas_draw_bitmap()

void canvas_draw_bitmap ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
const uint8_t * compressed_bitmap_data )

Draw bitmap picture at position defined by x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthwidth of bitmap
heightheight of bitmap
compressed_bitmap_datacompressed bitmap data

◆ canvas_draw_box()

void canvas_draw_box ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw box of width, height at x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthbox width
heightbox height

◆ canvas_draw_circle()

void canvas_draw_circle ( Canvas * canvas,
int32_t x,
int32_t y,
size_t radius )

Draw circle at x,y with radius r.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
radiusradius

◆ canvas_draw_disc()

void canvas_draw_disc ( Canvas * canvas,
int32_t x,
int32_t y,
size_t radius )

Draw disc at x,y with radius r.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
radiusradius

◆ canvas_draw_dot()

void canvas_draw_dot ( Canvas * canvas,
int32_t x,
int32_t y )

Draw dot at x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate

◆ canvas_draw_frame()

void canvas_draw_frame ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw frame of width, height at x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthframe width
heightframe height

◆ canvas_draw_glyph()

void canvas_draw_glyph ( Canvas * canvas,
int32_t x,
int32_t y,
uint16_t ch )

Draw glyph.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
chcharacter

◆ canvas_draw_icon()

void canvas_draw_icon ( Canvas * canvas,
int32_t x,
int32_t y,
const Icon * icon )

Draw icon at position defined by x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
iconIcon instance

◆ canvas_draw_icon_animation()

void canvas_draw_icon_animation ( Canvas * canvas,
int32_t x,
int32_t y,
IconAnimation * icon_animation )

Draw animation at position defined by x,y.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
icon_animationIconAnimation instance

◆ canvas_draw_icon_ex()

void canvas_draw_icon_ex ( Canvas * canvas,
int32_t x,
int32_t y,
const Icon * icon,
IconRotation rotation )

Draw icon at position defined by x,y with rotation and flip.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
iconIcon instance
rotationIconRotation

◆ canvas_draw_line()

void canvas_draw_line ( Canvas * canvas,
int32_t x1,
int32_t y1,
int32_t x2,
int32_t y2 )

Draw line from x1,y1 to x2,y2.

Parameters
canvasCanvas instance
x1x1 coordinate
y1y1 coordinate
x2x2 coordinate
y2y2 coordinate

◆ canvas_draw_rbox()

void canvas_draw_rbox ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
size_t radius )

Draw rounded-corner box of width, height at x,y, with round value raduis.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthbox width
heightbox height
radiusbox corner radius

◆ canvas_draw_rframe()

void canvas_draw_rframe ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
size_t radius )

Draw rounded-corner frame of width, height at x,y, with round value radius.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthframe width
heightframe height
radiusframe corner radius

◆ canvas_draw_str()

void canvas_draw_str ( Canvas * canvas,
int32_t x,
int32_t y,
const char * str )

Draw string at position of baseline defined by x, y.

Parameters
canvasCanvas instance
xanchor point x coordinate
yanchor point y coordinate
strC-string

◆ canvas_draw_str_aligned()

void canvas_draw_str_aligned ( Canvas * canvas,
int32_t x,
int32_t y,
Align horizontal,
Align vertical,
const char * str )

Draw aligned string defined by x, y.

Align calculated from position of baseline, string width and ascent (height of the glyphs above the baseline)

Parameters
canvasCanvas instance
xanchor point x coordinate
yanchor point y coordinate
horizontalhorizontal alignment
verticalvertical alignment
strC-string

◆ canvas_draw_triangle()

void canvas_draw_triangle ( Canvas * canvas,
int32_t x,
int32_t y,
size_t base,
size_t height,
CanvasDirection dir )

Draw triangle with given base and height lengths and their intersection coordinate.

Parameters
canvasCanvas instance
xx coordinate of base and height intersection
yy coordinate of base and height intersection
baselength of triangle side
heightlength of triangle height
dirCanvasDirection triangle orientation

◆ canvas_draw_xbm()

void canvas_draw_xbm ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
const uint8_t * bitmap )

Draw XBM bitmap.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
[in]widthbitmap width
[in]heightbitmap height
bitmappointer to XBM bitmap data

◆ canvas_draw_xbm_ex()

void canvas_draw_xbm_ex ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
IconRotation rotation,
const uint8_t * bitmap_data )

Draw rotated XBM bitmap.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
[in]widthbitmap width
[in]heightbitmap height
[in]rotationbitmap rotation
bitmap_datapointer to XBM bitmap data

◆ canvas_get_font_params()

const CanvasFontParameters * canvas_get_font_params ( const Canvas * canvas,
Font font )

Get font parameters.

Parameters
canvasCanvas instance
fontFont
Returns
pointer to CanvasFontParameters structure

◆ canvas_glyph_width()

size_t canvas_glyph_width ( Canvas * canvas,
uint16_t symbol )

Get glyph width.

Parameters
canvasCanvas instance
[in]symbolcharacter
Returns
width in pixels

◆ canvas_height()

size_t canvas_height ( const Canvas * canvas)

Get Canvas height.

Parameters
canvasCanvas instance
Returns
height in pixels.

◆ canvas_invert_color()

void canvas_invert_color ( Canvas * canvas)

Invert drawing color.

Parameters
canvasCanvas instance

◆ canvas_reset()

void canvas_reset ( Canvas * canvas)

Reset canvas drawing tools configuration.

Parameters
canvasCanvas instance

◆ canvas_set_bitmap_mode()

void canvas_set_bitmap_mode ( Canvas * canvas,
bool alpha )

Set transparency mode.

Parameters
canvasCanvas instance
alphatransparency mode

◆ canvas_set_color()

void canvas_set_color ( Canvas * canvas,
Color color )

Set drawing color.

Parameters
canvasCanvas instance
colorColor

◆ canvas_set_custom_u8g2_font()

void canvas_set_custom_u8g2_font ( Canvas * canvas,
const uint8_t * font )

Set custom drawing font.

Parameters
canvasCanvas instance
fontPointer to u8g2 const uint8_t* font array

◆ canvas_set_font()

void canvas_set_font ( Canvas * canvas,
Font font )

Set drawing font.

Parameters
canvasCanvas instance
fontFont

◆ canvas_set_font_direction()

void canvas_set_font_direction ( Canvas * canvas,
CanvasDirection dir )

Set font swap Argument String Rotation Description.

Parameters
canvasCanvas instance
dirDirection font

◆ canvas_string_width()

uint16_t canvas_string_width ( Canvas * canvas,
const char * str )

Get string width.

Parameters
canvasCanvas instance
strC-string
Returns
width in pixels.

◆ canvas_width()

size_t canvas_width ( const Canvas * canvas)

Get Canvas width.

Parameters
canvasCanvas instance
Returns
width in pixels.