Functions for Text Areas. More…
Public Member Functions | |
gText (uint8_t x1, uint8_t y1, uint8_t columns, uint8_t rows, Font_t font, textMode mode=DEFAULT_SCROLLDIR) | |
gText (predefinedArea selection, textMode mode=DEFAULT_SCROLLDIR) | |
gText (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, textMode mode=DEFAULT_SCROLLDIR) | |
TEXT FUNCTIONS | |
uint8_t | CharWidth (uint8_t c) |
void | ClearArea (void) |
void | CursorTo (int8_t column) |
void | CursorTo (uint8_t column, uint8_t row) |
void | CursorToXY (uint8_t x, uint8_t y) |
uint8_t | DefineArea (predefinedArea selection, textMode mode=DEFAULT_SCROLLDIR) |
uint8_t | DefineArea (uint8_t x1, uint8_t y1, uint8_t columns, uint8_t rows, Font_t font, textMode mode=DEFAULT_SCROLLDIR) |
uint8_t | DefineArea (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, textMode mode=DEFAULT_SCROLLDIR) |
void | DrawString (char *str, uint8_t x, uint8_t y) |
void | DrawString_P (PGM_P str, uint8_t x, uint8_t y) |
void | EraseTextLine (uint8_t row) |
void | EraseTextLine (eraseLine_t type=eraseTO_EOL) |
void | Printf (const char *format,…) |
void | Printf_P (const char *format,…) |
void | printFlash (FLASHSTRING str) |
void | printFlashln (FLASHSTRING str) |
void | PrintNumber (long n) |
int | PutChar (uint8_t c) |
void | Puts (char *str) |
void | Puts_P (PGM_P str) |
void | SelectFont (Font_t font, uint8_t color=BLACK, FontCallback callback=ReadPgmData) |
void | SetFontColor (uint8_t color) |
void | SetTextMode (textMode mode) |
uint16_t | StringWidth (const char *str) |
uint16_t | StringWidth_P (PGM_P str) |
void | write (uint8_t c) |
Protected Member Functions | |
void | GotoXY (uint8_t x, uint8_t y) |
void | Init (uint8_t invert=false) |
uint8_t | ReadData (void) |
void | SetDot (uint8_t x, uint8_t y, uint8_t color) |
void | SetPixels (uint8_t x, uint8_t y, uint8_t x1, uint8_t y1, uint8_t color) |
void | WriteData (uint8_t data) |
Static Protected Attributes | |
static lcdCoord | Coord |
static uint8_t | Inverted |
Functions for Text Areas.
A text area acts like a terminal monitor and text output is displayed within the confines of a rectangle given in the DefineArea command. All of the following text area functions operate on a user defined text area.
uint8_t CharWidth | ( | uint8_t | c | ) |
Returns the pixel width of a character
c | character to be sized |
void ClearArea | ( | void | ) |
Clear text area with the current font background color and home the cursor to upper left corner of the text area.
void CursorTo | ( | int8_t | column | ) |
Positions cursor to a character based column on the current row.
column | specifies the horizontal position |
Column is a 0 based character position based on the size of the currently selected font.
If column is negative then the column position is relative to the current cursor position.
void CursorTo | ( | uint8_t | column, | |
uint8_t | row | |||
) |
Positions cursor to a character based column and row.
column | specifies the horizontal position | |
row | specifies the vertical position |
Column and Row are zero based character positions and are relative the the upper left corner of the text area base on the size of the currently selected font.
While intended for fixed width fonts, positioning will work for variable width fonts.
When variable width fonts are used, the column is based on assuming a width of the widest character.
void CursorToXY | ( | uint8_t | x, | |
uint8_t | y | |||
) |
Positions cursor to a X,Y position
x | specifies the horizontal location | |
y | specifies the vertical location |
X & Y are zero based pixel coordinates and are relative to the upper left corner of the text area.
uint8_t DefineArea | ( | predefinedArea | selection, | |
textMode | mode = DEFAULT_SCROLLDIR | |||
) |
Define a predefined generic text area
selection | a value from predefinedArea | |
mode | constants SCROLL_DOWN and SCROLL_UP control scroll direction |
Defines a text area using a selection form a set of predefined areas.
The area within the newly defined text area is intentionally not cleared.
mode is an optional parameter and defaults to normal/up scrolling
uint8_t DefineArea | ( | uint8_t | x, | |
uint8_t | y, | |||
uint8_t | columns, | |||
uint8_t | rows, | |||
Font_t | font, | |||
textMode | mode = DEFAULT_SCROLLDIR | |||
) |
Define a Text area by columns and rows
x | X coordinate of upper left corner | |
y | Y coordinate of upper left corner | |
columns | number of text columns | |
rows | number of text rows | |
font | a font definition | |
mode | constants SCROLL_DOWN and SCROLL_UP control scroll direction |
Defines a text area sized to hold columns characters across and rows characters tall. It is properly sized for the specified font.
The area within the newly defined text area is intentionally not cleared.
While intended for fixed width fonts, sizing will work for variable width fonts.
When variable width fonts are used, the column is based on assuming a width of the widest character.
x,y is an absolute coordinate and is relateive to the 0,0 origin of the display.
mode is an optional parameter and defaults to normal/up scrolling
uint8_t DefineArea | ( | uint8_t | x1, | |
uint8_t | y1, | |||
uint8_t | x2, | |||
uint8_t | y2, | |||
textMode | mode = DEFAULT_SCROLLDIR | |||
) |
Define a text area by absolute coordinates
x1 | X coordinate of upper left corner | |
y1 | Y coordinate of upper left corner | |
x2 | X coordinate of lower right corner | |
y2 | Y coordinate of lower right corner | |
mode | constants SCROLL_DOWN and SCROLL_UP control scroll direction |
Defines a text area based on absolute coordinates. The pixel coordinates for the text area are inclusive so x2,y2 is the lower right pixel of the text area.
x1,y1 and x2,y2 are an absolute coordinates and are relateive to the 0,0 origin of the display.
The area within the newly defined text area is intentionally not cleared.
mode is an optional parameter and defaults to normal/up scrolling
void DrawString | ( | char * | str, | |
uint8_t | x, | |||
uint8_t | y | |||
) |
output a character string at x,y coordinate
str | pointer to a null terminated character string | |
x | specifies the horizontal location | |
y | specifies the vertical location |
Outputs all the characters in the string to the text area. X & Y are zero based pixel coordinates and are relative to the upper left corner of the text area.
See PutChar() for a full description of how characters are written to the text area.
void DrawString_P | ( | PGM_P | str, | |
uint8_t | x, | |||
uint8_t | y | |||
) |
output a program memory character string at x,y coordinate
str | pointer to a null terminated character string stored in program memory | |
x | specifies the horizontal location | |
y | specifies the vertical location |
Outputs all the characters in the string to the text area. X & Y are zero based pixel coordinates and are relative to the upper left corner of the text area.
See PutChar() for a full description of how characters are written to the text area.
void EraseTextLine | ( | uint8_t | row | ) |
Erase Text Line
row | row # of text to earase |
Erases a line of text and moves the cursor to the begining of the line. Rows are zero based so the top line/row of a text area is 0.
void EraseTextLine | ( | eraseLine_t | type = eraseTO_EOL |
) |
Erase in Line
type | type of line erase |
Erases all or part of a line of text depending on the type of erase specified.
If type is not specified it is assumed to be eraseTO_EOL
The cursor position does not change.
void GotoXY | ( | uint8_t | x, | |
uint8_t | y | |||
) | [protected, inherited] |
set current x,y coordinate on display device
x | X coordinate | |
y | Y coordinate |
Sets the current pixel location to x,y. x and y are relative to the 0,0 origin of the display which is the upper left most pixel on the display.
Reimplemented in glcd.
void Init | ( | uint8_t | invert = false |
) | [protected, inherited] |
Low level h/w initialization of display and AVR pins
invert | specifices whether display is in normal mode or inverted mode. |
This should only be called by other library code.
It does all the low level hardware initalization of the display device.
The optional invert parameter specifies if the display should be run in a normal mode, dark pixels on light background or inverted, light pixels on a dark background.
To specify dark pixels use the define NON-INVERTED and to use light pixels use the define INVERTED
Upon completion of the initialization, the entire display will be cleared and the x,y postion will be set to 0,0
Reimplemented in glcd.
void Printf | ( | const char * | format, | |
… | ||||
) |
print formatted data
format | string that contains text or optional embedded format tags | |
… | Depending on the format string, the function may expect a sequence of additional arguments. |
Writes a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format. The format string supports all standard printf() formating % tags.
void Printf_P | ( | const char * | format, | |
… | ||||
) |
print formatted data
format | string in AVR progmem that contains text or optional embedded format tags | |
… | Depending on the format string, the function may expect a sequence of additional arguments. |
See gText::Printf() for full details.
void printFlash | ( | FLASHSTRING | str | ) |
print a flash based string
str | pointer to a null terminated character string stored in program memory |
void printFlashln | ( | FLASHSTRING | str | ) |
print a flash based string
str | pointer to a null terminated character string stored in program memory |
The string is output followed by a newline.
void PrintNumber | ( | long | n | ) |
Legacy function to print a number
n | is the number to print |
int PutChar | ( | uint8_t | c | ) |
output a character
c | the character to output |
If the character will not fit on the current text line inside the text area, the text position is wrapped to the next line. This might be the next lower or the next higher line depending on the scroll direction.
If there is not enough room to fit a full line of new text after wrapping, the entire text area will be scrolled to make room for a new line of text. The scroll direction will be up or down depending on the scroll direction for the text area.
void Puts | ( | char * | str | ) |
output a character string
str | pointer to a null terminated character string. |
Outputs all the characters in the string to the text area. See PutChar() for a full description of how characters are written to the text area.
void Puts_P | ( | PGM_P | str | ) |
output a program memory character string
str | pointer to a null terminated character string stored in program memory |
Outputs all the characters in the string to the text area. See PutChar() for a full description of how characters are written to the text area.
uint8_t ReadData | ( | void | ) | [inline, protected, inherited] |
read a data byte from display device memory
Reimplemented in glcd.
void SelectFont | ( | Font_t | font, | |
uint8_t | color = BLACK , |
|||
FontCallback | callback = ReadPgmData | |||
) |
Select a Font and font color
font | a font definition | |
color | can be WHITE or BLACK and defaults to black | |
callback | optional font read routine |
Selects the font definition as the current font for the text area.
All subsequent printing functions will use this font.
Font definitions from included font definition files are stored in program memory You can have as many fonts defines as will fit in program memory up to 64k and can switch between them with this function.
If the optional callback argument is ommitted, a default routine is selected that assumes that the font is in program memory (flash).
void SetDot | ( | uint8_t | x, | |
uint8_t | y, | |||
uint8_t | color | |||
) | [protected, inherited] |
set pixel at x,y to the given color
x | X coordinate, a value from 0 to GLCD.Width-1 | |
y | Y coordinate, a value from 0 to GLCD.Heigh-1 | |
color | WHITE or BLACK |
Sets the pixel at location x,y to the specified color. x and y are relative to the 0,0 origin of the display which is the upper left corner. Requests to set pixels outside the range of the display will be ignored.
Reimplemented in glcd.
void SetFontColor | ( | uint8_t | color | ) |
void SetPixels | ( | uint8_t | x, | |
uint8_t | y, | |||
uint8_t | x2, | |||
uint8_t | y2, | |||
uint8_t | color | |||
) | [protected, inherited] |
set an area of pixels
x | X coordinate of upper left corner | |
y | Y coordinate of upper left corner | |
x2 | X coordinate of lower right corner | |
y2 | Y coordinate of lower right corner | |
color | sets the pixels an area bounded by x,y to x2,y2 inclusive to the specified color. |
The width of the area is x2-x + 1. The height of the area is y2-y+1
Reimplemented in glcd.
void SetTextMode | ( | textMode | mode | ) |
Select a font color
mode | text area mode |
Currently mode is a scroll direction
uint16_t StringWidth | ( | const char * | str | ) |
Returns the pixel width of a string
str | pointer to string stored in RAM |
uint16_t StringWidth_P | ( | PGM_P | str | ) |
Returns the pixel width of a character
str | pointer to string stored in program memory |
void write | ( | uint8_t | c | ) |
output a character to the text area
c | the character to output |
This method is needed for the Print base class
Reimplemented from glcd_Device.
void WriteData | ( | uint8_t | data | ) | [protected, inherited] |
Write a byte to display device memory
data | date byte to write to memory |
The data specified is written to glcd memory at the current x,y position. If the y location is not on a byte boundary, the write is fragemented up into multiple writes.
Reimplemented in glcd.