This module has the interface for drawing fonts and 2D primitives like lines.
NOTE: This is limited demo API and not a comprehensive 2D drawing library
Files | |
| file | draw2d.h |
| Font and 2D Drawing API. | |
Data Structures | |
| struct | Draw2D_FontProperty |
| struct | Draw2D_BmpProperty |
| struct | Draw2D_BufInfo |
| Buffer information into which font and 2d primitives will be draw. More... | |
| struct | Draw2D_FontPrm |
| Font parameters. More... | |
| struct | Draw2D_BmpPrm |
| Bitmap parameters. More... | |
| struct | Draw2D_LinePrm |
| Line draw parameters. More... | |
| struct | Draw2D_RegionPrm |
| Region Params. More... | |
Functions | |
| int32_t | Draw2D_create (Draw2D_Handle *pCtx) |
| Create a context for drawing. More... | |
| int32_t | Draw2D_delete (Draw2D_Handle pCtx) |
| Delete a previously created drawing context. More... | |
| int32_t | Draw2D_setBufInfo (Draw2D_Handle pCtx, Draw2D_BufInfo *pBufInfo) |
| Associated a drawing buffer with a drawing context. More... | |
| void | Draw2D_updateBufAddr (Draw2D_Handle pCtx, uint8_t **bufAddr) |
| Update drawing buffer. More... | |
| int32_t | Draw2D_clearBuf (Draw2D_Handle pCtx) |
| Fill buffer with transperency color. More... | |
| int32_t | Draw2D_drawString (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, char *str, Draw2D_FontPrm *pPrm) |
| Draw string of character into the drawing buffer. More... | |
| int32_t | Draw2D_drawString_rot (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, char *str, Draw2D_FontPrm *pPrm, uint32_t rotate) |
| Draw string of character into the drawing buffer. More... | |
| int32_t | Draw2D_clearString (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, uint32_t stringLength, Draw2D_FontPrm *pPrm) |
| Clear a area equal to stringLength in the drawing buffer. More... | |
| int32_t | Draw2D_getFontProperty (Draw2D_FontPrm *pPrm, Draw2D_FontProperty *pProp) |
| Get properties of a given font. More... | |
| int32_t | Draw2D_getBmpProperty (Draw2D_BmpPrm *pPrm, Draw2D_BmpProperty *pProp) |
| Get properties of a given bitmap. More... | |
| int32_t | Draw2D_drawLine (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, uint32_t endX, uint32_t endY, Draw2D_LinePrm *pPrm) |
| Draw a line in the drawing buffer. More... | |
| int32_t | Draw2D_drawRect (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, uint32_t width, uint32_t height, Draw2D_LinePrm *pPrm) |
| Draw a rectangle in the drawing buffer. More... | |
| int32_t | Draw2D_clearRegion (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, uint32_t width, uint32_t height) |
| Clear a region in the drawing buffer with transperency color. More... | |
| int32_t | Draw2D_fillRegion (Draw2D_Handle pCtx, Draw2D_RegionPrm *prm) |
| Draw a region in the drawing buffer with custom color. More... | |
| void | Draw2D_drawPixel (Draw2D_Handle pCtx, uint32_t px, uint32_t py, uint32_t color, uint32_t colorFormat) |
| Draw pixel of a given color. More... | |
| int32_t | Draw2D_drawBmp (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, Draw2D_BmpPrm *pPrm) |
| Draw a bitmap into the drawing buffer. More... | |
| int32_t | Draw2D_drawBmp_rot (Draw2D_Handle pCtx, uint32_t startX, uint32_t startY, Draw2D_BmpPrm *pPrm, uint32_t rotate) |
| Draw a bitmap into the drawing buffer. More... | |
| int32_t | Draw2D_insertBmp (Draw2D_Handle pCtx, char *input_file, int32_t startX, int32_t startY) |
| Draw a bitmap from BMP file at a specified display buffer location. More... | |
| int32_t | Draw2D_insertBmpFromMemory (Draw2D_Handle pCtx, void *buf, uint32_t buf_size, int32_t startX, int32_t startY) |
| Draw a bitmap from BMP file (pre-copied at a memory location) at a specified display buffer location. More... | |
| void | Draw2D_setFontColor (uint16_t colorText, uint16_t colorBorder, uint16_t colorBg) |
| Sets a global color to use for fonts in RGB565 format. More... | |
| void | Draw2D_resetFontColor () |
| Restore font to default. More... | |
| static uint32_t | Draw2D_floor (uint32_t val, uint32_t align) |
| Initialize In queue parameters of a link. More... | |
Typedefs | |
| typedef void * | Draw2D_Handle |
| Draw 2D object handle. More... | |
Macros | |
| #define | DRAW2D_MAX_PLANES (3) |
| #define | RGB888_TO_RGB565(r, g, b) ((((uint32_t)(r>>3) & 0x1F) << 11) | (((uint32_t)(g>>2) & 0x3F) << 5) | (((uint32_t)(b>>3) & 0x1F))) |
| Macro that converts RGB888 to RGB565. More... | |
| #define | RGB888_TO_BGRA444(r, g, b, a) ((((uint32_t)(r>>4) & 0xF) << 0) | (((uint32_t)(g>>4) & 0xF) << 4) | (((uint32_t)(b>>4) & 0xF)<<8)| (((uint32_t)(a>>4) & 0xF)<<12)) |
| #define | DRAW2D_TRANSPARENT_COLOR (RGB888_TO_RGB565(0, 0, 0)) |
| #define | DRAW2D_TRANSPARENT_COLOR_FORMAT (DRAW2D_DF_BGR16_565) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_0 (0) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_1 (1) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_2 (2) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_3 (3) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_4 (4) |
| #define | DRAW2D_BMP_IDX_TI_LOGO_5 (5) |
| #define | DRAW2D_BMP_IDX_DOF_COLOUR_MAP (6) |
| #define | DRAW2D_BMP_IDX_SDE_COLOUR_MAP (7) |
| #define DRAW2D_MAX_PLANES (3) |
| #define RGB888_TO_RGB565 | ( | r, | |
| g, | |||
| b | |||
| ) | ((((uint32_t)(r>>3) & 0x1F) << 11) | (((uint32_t)(g>>2) & 0x3F) << 5) | (((uint32_t)(b>>3) & 0x1F))) |
Macro that converts RGB888 to RGB565.
| #define RGB888_TO_BGRA444 | ( | r, | |
| g, | |||
| b, | |||
| a | |||
| ) | ((((uint32_t)(r>>4) & 0xF) << 0) | (((uint32_t)(g>>4) & 0xF) << 4) | (((uint32_t)(b>>4) & 0xF)<<8)| (((uint32_t)(a>>4) & 0xF)<<12)) |
| #define DRAW2D_TRANSPARENT_COLOR (RGB888_TO_RGB565(0, 0, 0)) |
| #define DRAW2D_TRANSPARENT_COLOR_FORMAT (DRAW2D_DF_BGR16_565) |
| #define DRAW2D_BMP_IDX_TI_LOGO_0 (0) |
| #define DRAW2D_BMP_IDX_TI_LOGO_1 (1) |
| #define DRAW2D_BMP_IDX_TI_LOGO_2 (2) |
| #define DRAW2D_BMP_IDX_TI_LOGO_3 (3) |
| #define DRAW2D_BMP_IDX_TI_LOGO_4 (4) |
| #define DRAW2D_BMP_IDX_TI_LOGO_5 (5) |
| #define DRAW2D_BMP_IDX_DOF_COLOUR_MAP (6) |
| #define DRAW2D_BMP_IDX_SDE_COLOUR_MAP (7) |
| typedef void* Draw2D_Handle |
Draw 2D object handle.
| enum Draw2D_DataFormat |
Enums for data format.
All data formats may not be supported by all links. For supported data formats please look link header file.
| int32_t Draw2D_create | ( | Draw2D_Handle * | pCtx | ) |
Create a context for drawing.
MUST be called before calling any other Draw2D API
| pCtx | [OUT] Created Draw 2D context |
| int32_t Draw2D_delete | ( | Draw2D_Handle | pCtx | ) |
Delete a previously created drawing context.
| pCtx | [IN] Draw 2D context |
| int32_t Draw2D_setBufInfo | ( | Draw2D_Handle | pCtx, |
| Draw2D_BufInfo * | pBufInfo | ||
| ) |
Associated a drawing buffer with a drawing context.
This API MUST be called after Draw2D_create() and before any drawing API
| pCtx | [IN] Draw 2D context |
| pBufInfo | [IN] Buffer information |
| void Draw2D_updateBufAddr | ( | Draw2D_Handle | pCtx, |
| uint8_t ** | bufAddr | ||
| ) |
Update drawing buffer.
This API can be used to update the buffer address when needed
| pCtx | [IN] Draw 2D context |
| bufAddr | [IN] Array of buffer addresses |
| int32_t Draw2D_clearBuf | ( | Draw2D_Handle | pCtx | ) |
Fill buffer with transperency color.
| pCtx | [IN] Draw 2D context |
| int32_t Draw2D_drawString | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| char * | str, | ||
| Draw2D_FontPrm * | pPrm | ||
| ) |
Draw string of character into the drawing buffer.
| pCtx | [IN] Draw 2D context |
| startX | [IN] X-position in the buffer |
| startY | [IN] Y-position in the buffer |
| str | [IN] Ascii string to draw |
| pPrm | [IN] Font to use when drawing, when set to NULL default properties used |
| int32_t Draw2D_drawString_rot | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| char * | str, | ||
| Draw2D_FontPrm * | pPrm, | ||
| uint32_t | rotate | ||
| ) |
Draw string of character into the drawing buffer.
| pCtx | [IN] Draw 2D context |
| startX | [IN] X-position in the buffer |
| startY | [IN] Y-position in the buffer |
| str | [IN] Ascii string to draw |
| pPrm | [IN] Font to use when drawing, when set to NULL default properties used |
| rotate | [IN] Set 1 to rotate |
| int32_t Draw2D_clearString | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| uint32_t | stringLength, | ||
| Draw2D_FontPrm * | pPrm | ||
| ) |
Clear a area equal to stringLength in the drawing buffer.
This is used to erase a string of previously written characters. Internal this draws the 'SPACE' stringLength times
| pCtx | [IN] Draw 2D context |
| startX | [IN] start X-position in the buffer |
| startY | [IN] start Y-position in the buffer |
| stringLength | [IN] Length of string to clear |
| pPrm | [IN] Font to use when drawing, when set to NULL default properties used |
| int32_t Draw2D_getFontProperty | ( | Draw2D_FontPrm * | pPrm, |
| Draw2D_FontProperty * | pProp | ||
| ) |
Get properties of a given font.
| pPrm | [IN] Font to use when drawing, when set to NULL default properties used |
| pProp | [OUT] Font properties like width x height, bpp etc |
| int32_t Draw2D_getBmpProperty | ( | Draw2D_BmpPrm * | pPrm, |
| Draw2D_BmpProperty * | pProp | ||
| ) |
Get properties of a given bitmap.
| pPrm | [IN] Bitmap to use when drawing, when set to NULL default properties used |
| pProp | [OUT] Bitmap properties like width x height, bpp etc |
| int32_t Draw2D_drawLine | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| uint32_t | endX, | ||
| uint32_t | endY, | ||
| Draw2D_LinePrm * | pPrm | ||
| ) |
Draw a line in the drawing buffer.
Currently only horizontal or vertical lines can be drawn So make sure endX or endY is equal to startX or startY
To clear a line, call the same API with color as transperency color in line properties
| pCtx | [IN] Draw 2D context |
| startX | [IN] start X-position in the buffer |
| startY | [IN] start Y-position in the buffer |
| endX | [IN] end X-position in the buffer |
| endY | [IN] end Y-position in the buffer |
| pPrm | [IN] Line properties to use when drawing, when set to NULL default properties used |
| int32_t Draw2D_drawRect | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| uint32_t | width, | ||
| uint32_t | height, | ||
| Draw2D_LinePrm * | pPrm | ||
| ) |
Draw a rectangle in the drawing buffer.
Internally uses Draw2D_drawLine() 4 times to draw the rectangle
To clear a rectangle, call the same API with color as transperency color in line properties
| pCtx | [IN] Draw 2D context |
| startX | [IN] start X-position in the buffer |
| startY | [IN] start Y-position in the buffer |
| width | [IN] width of rectangle in pixels |
| height | [IN] height of rectangle in lines |
| pPrm | [IN] Line properties to use when drawing, when set to NULL default properties used |
| int32_t Draw2D_clearRegion | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| uint32_t | width, | ||
| uint32_t | height | ||
| ) |
Clear a region in the drawing buffer with transperency color.
| pCtx | [IN] Draw 2D context |
| startX | [IN] start X-position in the buffer |
| startY | [IN] start Y-position in the buffer |
| width | [IN] width of region in pixels |
| height | [IN] height of region in lines |
| int32_t Draw2D_fillRegion | ( | Draw2D_Handle | pCtx, |
| Draw2D_RegionPrm * | prm | ||
| ) |
Draw a region in the drawing buffer with custom color.
| pCtx | [IN] Draw 2D context |
| prm | [IN] Region Parameters |
| void Draw2D_drawPixel | ( | Draw2D_Handle | pCtx, |
| uint32_t | px, | ||
| uint32_t | py, | ||
| uint32_t | color, | ||
| uint32_t | colorFormat | ||
| ) |
Draw pixel of a given color.
Representation of color in this function depends on the data format set during Draw2D_setBufInfo()
ex, 16-bit value for RGB565 data format
| pCtx | [IN] Draw 2D context |
| px | [IN] X-position in the buffer |
| py | [IN] Y-position in the buffer |
| color | [IN] Color used to draw the pixel |
| colorFormat | [IN] Color format of the color |
| int32_t Draw2D_drawBmp | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| Draw2D_BmpPrm * | pPrm | ||
| ) |
Draw a bitmap into the drawing buffer.
| pCtx | [IN] Draw 2D context |
| startX | [IN] X-position in the buffer |
| startY | [IN] Y-position in the buffer |
| pPrm | [IN] Bitmap to use when drawing, when set to NULL default properties used |
| int32_t Draw2D_drawBmp_rot | ( | Draw2D_Handle | pCtx, |
| uint32_t | startX, | ||
| uint32_t | startY, | ||
| Draw2D_BmpPrm * | pPrm, | ||
| uint32_t | rotate | ||
| ) |
Draw a bitmap into the drawing buffer.
| pCtx | [IN] Draw 2D context |
| startX | [IN] X-position in the buffer |
| startY | [IN] Y-position in the buffer |
| pPrm | [IN] Bitmap to use when drawing, when set to NULL default properties used |
| rotate | [IN] rotation angle, 0: 90 deg, 1: 180 deg, 2: 270 deg |
| int32_t Draw2D_insertBmp | ( | Draw2D_Handle | pCtx, |
| char * | input_file, | ||
| int32_t | startX, | ||
| int32_t | startY | ||
| ) |
Draw a bitmap from BMP file at a specified display buffer location.
| pCtx | [IN] Draw 2D context |
| input_file | [IN] input .BMP file name |
| startX | [IN] X position in display buffer |
| startY | [IN] Y position in display buffer |
| int32_t Draw2D_insertBmpFromMemory | ( | Draw2D_Handle | pCtx, |
| void * | buf, | ||
| uint32_t | buf_size, | ||
| int32_t | startX, | ||
| int32_t | startY | ||
| ) |
Draw a bitmap from BMP file (pre-copied at a memory location) at a specified display buffer location.
| pCtx | [IN] Draw 2D context |
| buf | [IN] .BMP file in memory location |
| buf_size | [IN] size of BMP file buffer |
| startX | [IN] X position in display buffer |
| startY | [IN] Y position in display buffer |
| void Draw2D_setFontColor | ( | uint16_t | colorText, |
| uint16_t | colorBorder, | ||
| uint16_t | colorBg | ||
| ) |
Sets a global color to use for fonts in RGB565 format.
| colorText | [IN] Color of text |
| colorBorder | [IN] Color of text border |
| colorBg | [IN] Color of text background |
| void Draw2D_resetFontColor | ( | ) |
Restore font to default.
|
inlinestatic |
Initialize In queue parameters of a link.
| val | [IN] Value to be rounded off |
| align | [IN] Value to which val to be rounded |