CircleOS  1
Functions
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. More...
 
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. More...
 
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. More...
 
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, char *ptr, len_t len, bool mode, enumset_t align)
 
void DRAW_DisplayString (coord_t x, coord_t y, char *ptr, len_t len)
 
void DRAW_DisplayStringInverted (coord_t x, coord_t y, char *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 
)

Function Name : DRAW_Circle() Description : Implementation of Bresenham's Circle variant algorithm

Parameters
[in]CENTER_xCircle Center x position
[in]CENTER_yCircle Center y position
[in]RADIUS_rCircle Radius
[in]ColorLine color of the Circle
[in]Fill_ColorBackground of the Circle
[in]FillDefines if the circle is filled
[in]CircleDefines if the circle is drawn
Returns
None

Definition at line 1449 of file draw.c.

void DRAW_Clear ( void  )

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

Definition at line 587 of file draw.c.

void DRAW_DisplayString ( coord_t  x,
coord_t  y,
char *  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]xThe horizontal coordinate of the string.
[in]yThe vertical coordinate of the string.
[in]*ptrPointer to the string.
[in]lenString 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 1113 of file draw.c.

void DRAW_DisplayStringInverted ( coord_t  x,
coord_t  y,
char *  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]xThe horizontal coordinate of the string.
[in]yThe vertical coordinate of the string.
[in]*ptrPointer to the string.
[in]lenString 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 1139 of file draw.c.

void DRAW_DisplayStringWithMode ( coord_t  x,
coord_t  y,
char *  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]xThe horizontal coordinate of the string.
[in]yThe vertical coordinate of the string.
[in]*ptrPointer to the string.
[in]lenString length i.e., number of characters to display: if 0 = len(string), if ALL_SCREEN = width screen.
[in]modeDisplay mode: 0 normal, 1 inverted colors.
[in]alignAlignment 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 1011 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]xThe horizontal coordinate of the displayed string.
[in]yThe vertical coordinate of the display string.
Warning
The (0x0) point in on the low left corner.

Definition at line 946 of file draw.c.

void DRAW_DisplayVbat ( coord_t  x,
coord_t  y 
)

This function is used to display vbat in ascii

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

Definition at line 912 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 
)

Function Name : DRAW_Ellipse() Description : This function draw an Ellipse

Parameters
[in]CENTER_xEllipse Center x position
[in]CENTER_yEllipse Center y position
[in]RADIUS_aEllipse Radius a
[in]RADIUS_bEllipse Radius b
[in]ColorLine color of the Circle
[in]Fill_ColorBackground of the Circle
[in]FillDefines if the Ellipse is filled
[in]EllipseDefines if the Ellipse is drawn
Returns
None

Definition at line 1546 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 553 of file draw.c.

mag_t DRAW_GetCharMagniCoeff ( void  )

Return the current magnifying value for the characters

Returns
Current magnifying value.

Definition at line 499 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]*lxX current left margin in pixels.
[out]*rxX current right margin in pixels.
[out]*hyY current high margin in pixels.
[out]*lyY current low margin in pixels.
Warning
The (0x0) point in on the low left corner.

Definition at line 1416 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 1348 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 517 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]x1The x-coordinate of the first line endpoint.
[in]x2The x-coordinate of the second line endpoint.
[in]y1The y-coordinate of the first line endpoint.
[in]y2The y-coordinate of the second line endpoint.
[in]colorThe line color.
Note
This function is just a wrapper with limit checking

Definition at line 1182 of file draw.c.

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

Function Name : DRAW_Polygon() Description : Function to draw a polygon with the given points

Parameters
[in]*pointsPointer to the points of the polygon
[in]NUM_PointsNumber of pointscolor of the line
[in]Line_ColorColor of the line.
Returns
None

Definition at line 1670 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]AsciiThe 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 1230 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]*ptrPointer 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 1288 of file draw.c.

void DRAW_SetBGndColor ( color_t  Color)

Set current background color

Parameters
[in]ColorThe new RGB color for background.

Definition at line 571 of file draw.c.

void DRAW_SetCharMagniCoeff ( mag_t  Coeff)

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

Parameters
[in]CoeffThe new magnifying coefficent.

Definition at line 481 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]lxX new left margin in pixels.
[in]rxX new right margin in pixels.
[in]hyY new high margin in pixels.
[in]lyY new low margin in pixels.
Warning
The (0x0) point in on the low left corner.

Definition at line 1372 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]xX new position in pixels.
[in]yY new position in pixels.
Warning
The (0x0) point in on the low left corner.

Definition at line 1318 of file draw.c.

void DRAW_SetDefaultColor ( void  )

Reset text and background colors to their default values.

Definition at line 1156 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]imageptrA pointer to an array of width * height 2 byte words.
[in]xThe horizontal coordinate of the low left corner of the bitmap.
[in]yThe vertical coordinate of the low left corner of the bitmap.
[in]widthThe bitmap width.
[in]heightThe bitmap height.
Warning
The (0x0) point in on the low left corner.

Definition at line 649 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]imageptrA pointer to an array of width * height bits.
[in]xThe horizontal coordinate of the low left corner of the bitmap.
[in]yThe vertical coordinate of the low left corner of the bitmap.
[in]widthThe bitmap width.
[in]heightThe bitmap height.
Warning
The (0x0) point in on the low left corner.

Definition at line 859 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]imageptrA pointer to an array of width * height 2 byte words.
[in]xThe horizontal coordinate of the low left corner of the bitmap.
[in]yThe vertical coordinate of the low left corner of the bitmap.
[in]widthThe bitmap width.
[in]heightThe bitmap height.
[in]oldBgndColorThe color of the background to replace.
[in]newBgndColorThe new color.
Warning
The (0x0) point in on the low left corner.

Definition at line 678 of file draw.c.

void DRAW_SetLogoBW ( void  )

Draw the butterfly logo

Definition at line 623 of file draw.c.

void DRAW_SetTextColor ( color_t  Color)

Set current text color.

Parameters
[in]ColorThe new RGB color used when drawing text.

Definition at line 535 of file draw.c.