draw.c File Reference

Various utilities for drawings (characters, ..). More...

Go to the source code of this file.

Functions

void DRAW_SetCharMagniCoeff (mag_t Coeff)
mag_t DRAW_GetCharMagniCoeff (void)
color_t DRAW_GetTextColor (void)
void DRAW_SetTextColor (color_t Color)
color_t DRAW_GetBGndColor (void)
void DRAW_SetBGndColor (color_t Color)
void DRAW_Clear (void)
void DRAW_SetLogoBW (void)
void DRAW_SetImage (const color_t *imageptr, coord_t x, coord_t y, coord_t width, coord_t height)
 Draw a color bitmap at the provided coordinates.
void DRAW_SetImageSel (const color_t *imageptr, coord_t x, coord_t y, coord_t width, coord_t height, color_t oldBgndColor, color_t newBgndColor)
 Draw a color bitmap at the provided coordinates, with selected background color.
void DRAW_SetImageBW (const u8 *imageptr, coord_t x, coord_t y, coord_t width, coord_t height)
 Draw a monochrome bitmap at the provided coordinates.
void DRAW_DisplayVbat (coord_t x, coord_t y)
void DRAW_DisplayTime (coord_t x, coord_t y)
void DRAW_DisplayStringWithMode (coord_t x, coord_t y, const u8 *ptr, len_t len, bool mode, enumset_t align)
void DRAW_DisplayString (coord_t x, coord_t y, const u8 *ptr, len_t len)
void DRAW_DisplayStringInverted (coord_t x, coord_t y, const u8 *ptr, len_t len)
void DRAW_SetDefaultColor (void)
void DRAW_Line (coord_t x1, coord_t y1, coord_t x2, coord_t y2, color_t color)
void DRAW_Putc (u8 Ascii)
void DRAW_Puts (const u8 *ptr)
void DRAW_SetCursorPos (coord_t x, coord_t y)
ret_t DRAW_GetCursorPos (void)
void DRAW_SetCursorMargin (coord_t lx, coord_t rx, coord_t hy, coord_t ly)
void DRAW_GetCursorMargin (coord_t *lx, coord_t *rx, coord_t *hy, coord_t *ly)
void DRAW_Circle (coord_t CENTER_x, coord_t CENTER_y, coord_t RADIUS_r, color_t Color, color_t Fill_Color, bool Fill, bool Circle)
void DRAW_Ellipse (coord_t CENTER_x, coord_t CENTER_y, coord_t RADIUS_a, coord_t RADIUS_b, color_t Color, color_t Fill_Color, bool Fill, bool Ellipse)
void DRAW_Polygon (coord_t *points, u16 NUM_Points, color_t Line_Color)

Detailed Description

Author:
FL
IB
Date:
07/2007
Version:
4.0 Add Open4 Primer
Date:
10/2009

Definition in file draw.c.


Function Documentation

void DRAW_Circle ( coord_t  CENTER_x,
coord_t  CENTER_y,
coord_t  RADIUS_r,
color_t  Color,
color_t  Fill_Color,
bool  Fill,
bool  Circle 
)

Definition at line 1432 of file draw.c.

void DRAW_Clear ( void   ) 

Clear the LCD display. Draw Battery and background image if main display.

Definition at line 581 of file draw.c.

void DRAW_DisplayString ( coord_t  x,
coord_t  y,
const u8 *  ptr,
len_t  len 
)

This function is used to display a character string (ALL_SCREEN u8 max) at given X, Y coordinates on the LCD display.

Parameters:
[in] x The horizontal coordinate of the string.
[in] y The vertical coordinate of the string.
[in] *ptr Pointer to the string.
[in] len String length i.e., number of characters to display.
Note:
Characters are displayed as 7x14 pixels blocks.
Warning:
The (0x0) point in on the low left corner.
The input string must be null-terminated.

Definition at line 1096 of file draw.c.

void DRAW_DisplayStringInverted ( coord_t  x,
coord_t  y,
const u8 *  ptr,
len_t  len 
)

This function is used to display a character string (ALL_SCREEN char max) at given X, Y coordinates on the LCD display, with inverted colors.

Parameters:
[in] x The horizontal coordinate of the string.
[in] y The vertical coordinate of the string.
[in] *ptr Pointer to the string.
[in] len String length i.e., number of characters to display.
Note:
Characters are displayed as 7x14 pixels blocks.
Warning:
The (0x0) point in on the low left corner.
The input string must be null-terminated.

Definition at line 1122 of file draw.c.

void DRAW_DisplayStringWithMode ( coord_t  x,
coord_t  y,
const u8 *  ptr,
len_t  len,
bool  mode,
enumset_t  align 
)

This function is used to display a character string at given X, Y coordinates on the LCD display. Note: This function is the user interface to use the LCD driver.

Parameters:
[in] x The horizontal coordinate of the string.
[in] y The vertical coordinate of the string.
[in] *ptr Pointer to the string.
[in] len String length i.e., number of characters to display: if 0 = len(string), if ALL_SCREEN = width screen.
[in] mode Display mode: 0 normal, 1 inverted colors.
[in] align Alignment mode: 0 normal, 1 centered.
Note:
The string length is automatic is set to 0.
Warning:
The (0x0) point in on the low left corner.
The input string must be null-terminated.
See also:
DRAW_DisplayString
DRAW_DisplayStringInverted

Definition at line 1005 of file draw.c.

void DRAW_DisplayTime ( coord_t  x,
coord_t  y 
)

This function is used to display time in ascii on LCD

Parameters:
[in] x The horizontal coordinate of the displayed string.
[in] y The vertical coordinate of the display string.
Warning:
The (0x0) point in on the low left corner.

Definition at line 940 of file draw.c.

void DRAW_DisplayVbat ( coord_t  x,
coord_t  y 
)

This function is used to display vbat in ascii

Parameters:
[in] x The horizontal coordinate of the displayed string.
[in] y The vertical coordinate of the display string.
Warning:
The (0x0) point in on the low left corner.

Definition at line 906 of file draw.c.

void DRAW_Ellipse ( coord_t  CENTER_x,
coord_t  CENTER_y,
coord_t  RADIUS_a,
coord_t  RADIUS_b,
color_t  Color,
color_t  Fill_Color,
bool  Fill,
bool  Ellipse 
)

Definition at line 1529 of file draw.c.

color_t DRAW_GetBGndColor ( void   ) 

Return current background color.

Returns:
The current RGB color used for the background.

Definition at line 547 of file draw.c.

mag_t DRAW_GetCharMagniCoeff ( void   ) 

Return the current magnifying value for the characters

Returns:
Current magnifying value.

Definition at line 493 of file draw.c.

void DRAW_GetCursorMargin ( coord_t *  lx,
coord_t *  rx,
coord_t *  hy,
coord_t *  ly 
)

This function is used to get the current margins for the cursor. This position is used by the DRAW_putc and DRAW_Puts functions.

Parameters:
[out] *lx X current left margin in pixels.
[out] *rx X current right margin in pixels.
[out] *hy Y current high margin in pixels.
[out] *ly Y current low margin in pixels.
Warning:
The (0x0) point in on the low left corner.

Definition at line 1399 of file draw.c.

ret_t DRAW_GetCursorPos ( void   ) 

This function is used to get the current position of the cursor.

Returns:
The current cursor position in pixels with X in the LSB and Y in the MSB.
Warning:
The (0x0) point in on the low left corner.

Definition at line 1331 of file draw.c.

color_t DRAW_GetTextColor ( void   ) 

Return current text color.

Returns:
The current RGB color used to draw text.

Definition at line 511 of file draw.c.

void DRAW_Line ( coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2,
color_t  color 
)

Draw a line on the LCD screen. Optimized for horizontal/vertical lines, and use the Bresenham algorithm for other cases.

Parameters:
[in] x1 The x-coordinate of the first line endpoint.
[in] x2 The x-coordinate of the second line endpoint.
[in] y1 The y-coordinate of the first line endpoint.
[in] y2 The y-coordinate of the second line endpoint.
[in] color The line color.
Note:
This function is just a wrapper with limit checking

Definition at line 1165 of file draw.c.

void DRAW_Polygon ( coord_t *  points,
u16  NUM_Points,
color_t  Line_Color 
)

Definition at line 1653 of file draw.c.

void DRAW_Putc ( u8  Ascii  ) 

Display at current coordinates the provided ASCII character with the current text and background colors and with the current magnify coefficient.

Parameters:
[in] Ascii The ASCII code of the character to display.
Ascii must be higher than 31 and lower than 255. '
' managed as CRLF.
Note:
If the low Y margin is reached, the text is scrolled into the window defined by the X and Y margins
See also:
DRAW_SetCursorMargin

Definition at line 1213 of file draw.c.

void DRAW_Puts ( const u8 *  ptr  ) 

This function is used to display a character string at current coordinates on the LCD display. Note: This function is the user interface to use the LCD driver.

Parameters:
[in] *ptr Pointer to the string.
Note:
Characters are displayed as 7x14 pixels blocks.
Warning:
The (0x0) point in on the low left corner.
See also:
DRAW_DisplayString
DRAW_DisplayStringInverted

Definition at line 1271 of file draw.c.

void DRAW_SetBGndColor ( color_t  Color  ) 

Set current background color

Parameters:
[in] Color The new RGB color for background.

Definition at line 565 of file draw.c.

void DRAW_SetCharMagniCoeff ( mag_t  Coeff  ) 

Set the magnifying value for the characters (should be 1 or 2)

Parameters:
[in] Coeff The new magnifying coefficent.

Definition at line 475 of file draw.c.

void DRAW_SetCursorMargin ( coord_t  lx,
coord_t  rx,
coord_t  hy,
coord_t  ly 
)

This function is used to set the current margins for the cursor. This position is used by the DRAW_putc and DRAW_Puts functions.

Parameters:
[in] lx X new left margin in pixels.
[in] rx X new right margin in pixels.
[in] hy Y new high margin in pixels.
[in] ly Y new low margin in pixels.
Warning:
The (0x0) point in on the low left corner.

Definition at line 1355 of file draw.c.

void DRAW_SetCursorPos ( coord_t  x,
coord_t  y 
)

This function is used to set the current position of the cursor. This position is used by the DRAW_putc and DRAW_Puts functions.

Parameters:
[in] x X new position in pixels.
[in] y Y new position in pixels.
Warning:
The (0x0) point in on the low left corner.

Definition at line 1301 of file draw.c.

void DRAW_SetDefaultColor ( void   ) 

Reset text and background colors to their default values.

Definition at line 1139 of file draw.c.

void DRAW_SetImage ( const color_t *  imageptr,
coord_t  x,
coord_t  y,
coord_t  width,
coord_t  height 
)

The provided bitmap is made width * height 2 byte words. Each 2 byte word contains the RGB color of a pixel.

Parameters:
[in] imageptr A pointer to an array of width * height 2 byte words.
[in] x The horizontal coordinate of the low left corner of the bitmap.
[in] y The vertical coordinate of the low left corner of the bitmap.
[in] width The bitmap width.
[in] height The bitmap height.
Warning:
The (0x0) point in on the low left corner.

Definition at line 643 of file draw.c.

void DRAW_SetImageBW ( const u8 *  imageptr,
coord_t  x,
coord_t  y,
coord_t  width,
coord_t  height 
)

The provided bitmap is made of width * height bits where a set bit means a pixel drawn in the current text color, whereas an unset bit means a pixel drawn in the current background color.

Parameters:
[in] imageptr A pointer to an array of width * height bits.
[in] x The horizontal coordinate of the low left corner of the bitmap.
[in] y The vertical coordinate of the low left corner of the bitmap.
[in] width The bitmap width.
[in] height The bitmap height.
Warning:
The (0x0) point in on the low left corner.

Definition at line 853 of file draw.c.

void DRAW_SetImageSel ( const color_t *  imageptr,
coord_t  x,
coord_t  y,
coord_t  width,
coord_t  height,
color_t  oldBgndColor,
color_t  newBgndColor 
)

The provided bitmap is made width * height 2 byte words. Each 2 byte word contains the RGB color of a pixel. All pixels with the oldBgndColor are replaced with the newBgndColor

Parameters:
[in] imageptr A pointer to an array of width * height 2 byte words.
[in] x The horizontal coordinate of the low left corner of the bitmap.
[in] y The vertical coordinate of the low left corner of the bitmap.
[in] width The bitmap width.
[in] height The bitmap height.
[in] oldBgndColor The color of the background to replace.
[in] newBgndColor The new color.
Warning:
The (0x0) point in on the low left corner.

Definition at line 672 of file draw.c.

void DRAW_SetLogoBW ( void   ) 

Draw the butterfly logo

Definition at line 617 of file draw.c.

void DRAW_SetTextColor ( color_t  Color  ) 

Set current text color.

Parameters:
[in] Color The new RGB color used when drawing text.

Definition at line 529 of file draw.c.