PicoVGA  1.0-cmake
VGA/TV display on Raspberry Pico
Text Printing

Description

The functions for printing text are used to output text to the text frame buffer. Currently supported buffer formats are GF_ATEXT (text with color attribute) and GF_MTEXT (mono text).

Macros

#define PC_BLACK   0
 
#define PC_BLUE   1
 
#define PC_GREEN   2
 
#define PC_CYAN   3
 
#define PC_RED   4
 
#define PC_MAGENTA   5
 
#define PC_BROWN   6
 
#define PC_LTGRAY   7
 
#define PC_GRAY   8
 
#define PC_LTBLUE   9
 
#define PC_LTGREEN   10
 
#define PC_LTCYAN   11
 
#define PC_LTRED   12
 
#define PC_LTMAGENTA   13
 
#define PC_YELLOW   14
 
#define PC_WHITE   15
 
#define PC_COLOR(bg, fg)   (((bg)<<4)|(fg))
 
#define PC_FGCOLOR(color)   ((color) & 0b1111)
 
#define PC_BGCOLOR(color)   ((color) >> 4)
 
#define CHAR_CR   '\r'
 
#define CHAR_LF   '\n'
 
#define CHAR_TAB   '\t'
 
#define CHAR_FRAME   16
 Frame base.
 
#define FRAME_L   B0
 Frame left flag.
 
#define FRAME_U   B1
 Frame up flag.
 
#define FRAME_R   B2
 Frame right flag.
 
#define FRAME_D   B3
 Frame down flag.
 
#define CHAR_FRAME_FIRST   17
 First frame character.
 
#define CHAR_FRAME_LAST   31
 Last frame character.
 
#define CHAR_VLINE   (CHAR_FRAME|FRAME_U|FRAME_D)
 Vertical line.
 
#define CHAR_HLINE   (CHAR_FRAME|FRAME_L|FRAME_R)
 Horizontal line.
 

Functions

void PrintSetup (u8 *buf, int bufw, int bufh, int bufwb)
 Setup print service. More...
 
void PrintClear ()
 Clear the text buffer with the currently selected color.
 
void PrintHome ()
 Move the pointer to the beginning of the first line.
 
void PrintSetPos (int x, int y)
 Set print position. More...
 
void PrintAddPos (int x, int y)
 Shift relative print position. More...
 
void PrintSetCol (u8 col)
 Set print color (2x4 bits of colors) More...
 
void PrintChar0 (char ch)
 Print character, not using control characters. More...
 
void PrintChar (char ch)
 Print character, using control characters CR, LF, TAB. More...
 
void PrintSpc ()
 Print space character.
 
void PrintSpcTo (int pos)
 Printing spaces up to the specified position. More...
 
void PrintCharRep (char ch, int num)
 Print repeated character. More...
 
void PrintSpcRep (int num)
 Print repeated space. More...
 
void PrintText (const char *text)
 Print a string. More...
 
void PrintHLine (int x, int y, int w)
 Print horizontal line into screen, using current color. More...
 
void PrintVLine (int x, int y, int h)
 Print vertical line into screen, using current color. More...
 
void PrintFrame (int x, int y, int w, int h)
 Print frame, using current color. More...
 

Variables

u8 * PrintBuf
 
int PrintBufW
 
int PrintBufH
 
int PrintBufWB
 
int PrintX
 
int PrintY
 
u8 PrintCol
 

Function Documentation

◆ PrintSetup()

void PrintSetup ( u8 *  buf,
int  bufw,
int  bufh,
int  bufwb 
)

Setup print service.

Initialization of the text printing service. The function is passed a pointer to the text frame buffer and its dimensions. If the line length in bytes is less than twice the width, the mono text format GF_MTEXT is selected, otherwise the format with the GF_ATEXT attributes is used. This function is automatically called when the video mode is initialized using the Video() function.

Parameters
bufPointer to buffer
bufwBuffer width in characters
bufhBuffer height in characters
bufwbBuffer width in bytes (if bufwb < 2*bufw, use mono text)

◆ PrintSetPos()

void PrintSetPos ( int  x,
int  y 
)

Set print position.

Parameters
xColumn position
yRow position

◆ PrintAddPos()

void PrintAddPos ( int  x,
int  y 
)

Shift relative print position.

Parameters
xAdd column position
yAdd row position

◆ PrintSetCol()

void PrintSetCol ( u8  col)

Set print color (2x4 bits of colors)

Parameters
colColor - Use the PC_COLOR macro

◆ PrintChar0()

void PrintChar0 ( char  ch)

Print character, not using control characters.

Parameters
chCharacter to print

◆ PrintChar()

void PrintChar ( char  ch)

Print character, using control characters CR, LF, TAB.

Parameters
chCharacter to print

◆ PrintSpcTo()

void PrintSpcTo ( int  pos)

Printing spaces up to the specified position.

Parameters
posPosition

◆ PrintCharRep()

void PrintCharRep ( char  ch,
int  num 
)

Print repeated character.

Parameters
chCharacter
numNumber of times to repeat

◆ PrintSpcRep()

void PrintSpcRep ( int  num)

Print repeated space.

Parameters
numNumber of times to repeat

◆ PrintText()

void PrintText ( const char *  text)

Print a string.

Parameters
textString to print

◆ PrintHLine()

void PrintHLine ( int  x,
int  y,
int  w 
)

Print horizontal line into screen, using current color.

Horizontal line drawing. Line drawing characters with code 17 to 31 are used for drawing, as overridden in the PicoVGA library fonts. When drawing, the line is combined with the characters already in the print buffer so that the lines are properly joined and overlapped. The function does not treat overflows outside the allowed display range.

Note
Must not stretch outside valid range
Parameters
xColumn position
yRow position
wWidth of line

◆ PrintVLine()

void PrintVLine ( int  x,
int  y,
int  h 
)

Print vertical line into screen, using current color.

Vertical line drawing. Line drawing characters with code 17 to 31 are used for drawing, as overridden in the PicoVGA library fonts. When drawing, the line is combined with the characters already in the print buffer so that the lines are properly joined and overlapped. The function does not treat overflows outside the allowed display range.

Note
Must not stretch outside valid range
Parameters
xColumn position
yRow position
hHeight of line

◆ PrintFrame()

void PrintFrame ( int  x,
int  y,
int  w,
int  h 
)

Print frame, using current color.

Parameters
xColumn position
yRow position
wWidth of line
hHeight of line