Arduino GLCD Library Version 3

gText Class Reference

Functions for Text Areas. More...

Inheritance diagram for gText:

List of all members.

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

The following text functions are available

uint8_t DefineArea (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, 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 (predefinedArea selection, textMode mode=DEFAULT_SCROLLDIR)
void SetTextMode (textMode mode)
void ClearArea (void)
void SelectFont (Font_t font, uint8_t color=BLACK, FontCallback callback=ReadPgmData)
void SetFontColor (uint8_t color)
int PutChar (uint8_t c)
void Puts (char *str)
void Puts (const String &str)
void Puts_P (PGM_P str)
void DrawString (char *str, uint8_t x, uint8_t y)
void DrawString (String &str, uint8_t x, uint8_t y)
void DrawString_P (PGM_P str, uint8_t x, uint8_t y)
void write (uint8_t c)
void CursorTo (uint8_t column, uint8_t row)
void CursorTo (int8_t column)
void CursorToXY (uint8_t x, uint8_t y)
uint8_t CharWidth (uint8_t c)
uint16_t StringWidth (const char *str)
uint16_t StringWidth_P (PGM_P str)
uint16_t StringWidth_P (String &str)
void EraseTextLine (eraseLine_t type=eraseTO_EOL)
void EraseTextLine (uint8_t row)
void PrintNumber (long n)
void printFlash (FLASHSTRING str)
void printFlashln (FLASHSTRING str)
void Printf (const char *format,...)
void Printf_P (const char *format,...)

Protected Member Functions

void GotoXY (uint8_t x, uint8_t y)
int 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

Detailed Description

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.


Member Function Documentation

uint8_t CharWidth ( uint8_t  c)

Returns the pixel width of a character

Parameters:
ccharacter to be sized
Returns:
The width in pixels of the given character including any inter-character gap pixels following the character when the character is rendered on the display.
Note:
The font for the character is the most recently selected font.
See also:
StringWidth()
StringWidth_P()
void ClearArea ( void  )

Clear text area with the current font background color and home the cursor to upper left corner of the text area.

See also:
DefineArea()
void CursorTo ( uint8_t  column,
uint8_t  row 
)

Positions cursor to a character based column and row.

Parameters:
columnspecifies the horizontal position
rowspecifies 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.

See also:
CursorToXY()
void CursorTo ( int8_t  column)

Positions cursor to a character based column on the current row.

Parameters:
columnspecifies 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.

Warning:
While intended only for fixed width fonts, cursor repositioning will be done for variable width fonts. When variable width fonts are used, the column is based on assuming a width of the widest character in the font. Because the widest character is used for the amount of cursor movement, the amount of cursor movement when using relative positioning will often not be consistent with the number characters previously rendered. For example, if a letter "l" was written and the cursor was reposisitioned with a -1, the amount backed up will be much larger than the width of the "l".
See also:
CursorToXY()
void CursorToXY ( uint8_t  x,
uint8_t  y 
)

Positions cursor to a X,Y position

Parameters:
xspecifies the horizontal location
yspecifies the vertical location

X & Y are zero based pixel coordinates and are relative to the upper left corner of the text area.

See also:
CursorTo()
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

Parameters:
x1X coordinate of upper left corner
y1Y coordinate of upper left corner
x2X coordinate of lower right corner
y2Y coordinate of lower right corner
modeconstants 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

Returns:
true with the given area selected if all the coordinates are valid, otherwise returns returns false with the area set to the full display
Note:
Upon creation of the text area, the cursor position for the text area will be set to x1, y1
See also:
ClearArea()
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

Parameters:
xX coordinate of upper left corner
yY coordinate of upper left corner
columnsnumber of text columns
rowsnumber of text rows
fonta font definition
modeconstants 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

Note:
Upon defining the text area, the cursor position for the text area will be set to x,y
See also:
ClearArea()
uint8_t DefineArea ( predefinedArea  selection,
textMode  mode = DEFAULT_SCROLLDIR 
)

Define a predefined generic text area

Parameters:
selectiona value from predefinedArea
modeconstants 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

Returns:
returns true if successful.
Note:
Upon defining the text area, the cursor position for the text area will be set to the upper left coordinate of the given predefined area
See also:
ClearArea()
predefinedArea
void DrawString ( char *  str,
uint8_t  x,
uint8_t  y 
)

output a character string at x,y coordinate

Parameters:
strString class string
xspecifies the horizontal location
yspecifies 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.

See also:
PutChar()
Puts()
Puts_P()
DrawString_P()
write()
void DrawString ( String &  str,
uint8_t  x,
uint8_t  y 
)

output a String class string at x,y coordinate

Parameters:
strpointer to a null terminated character string
xspecifies the horizontal location
yspecifies 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.

See also:
PutChar()
Puts()
Puts_P()
DrawString_P()
write()
void DrawString_P ( PGM_P  str,
uint8_t  x,
uint8_t  y 
)

output a program memory character string at x,y coordinate

Parameters:
strpointer to a null terminated character string stored in program memory
xspecifies the horizontal location
yspecifies 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.

See also:
PutChar()
Puts()
Puts_P()
DrawString()
write()
void EraseTextLine ( eraseLine_t  type = eraseTO_EOL)

Erase in Line

Parameters:
typetype 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.

See also:
ClearArea()
eraseLine_t
void EraseTextLine ( uint8_t  row)

Erase Text Line

Parameters:
rowrow # 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.

See also:
ClearArea()
void GotoXY ( uint8_t  x,
uint8_t  y 
) [protected, inherited]

set current x,y coordinate on display device

Parameters:
xX coordinate
yY 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.

int Init ( uint8_t  invert = false) [protected, inherited]

Low level h/w initialization of display and AVR pins

Parameters:
invertspecifices 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

Returns:
0 when successful or non zero error code when unsucessful

Upon successful completion of the initialization, the entire display will be cleared and the x,y postion will be set to 0,0

Note:
This function can be called more than once to re-initliaze the hardware.

Reimplemented in glcd.

void Printf ( const char *  format,
  ... 
)

print formatted data

Parameters:
formatstring 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.

Note:
By default printf() has no floating support in AVR enviornments. In order to enable this, a linker option must be changed. Currenly, the Arduino IDE does not support modifying the linker options.
See also:
Printf_P()
void Printf_P ( const char *  format,
  ... 
)

print formatted data

Parameters:
formatstring 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.

See also:
Printf()
void printFlash ( FLASHSTRING  str)

print a flash based string

Parameters:
strpointer to a null terminated character string stored in program memory
See also:
Puts_P()
void printFlashln ( FLASHSTRING  str)

print a flash based string

Parameters:
strpointer to a null terminated character string stored in program memory

The string is output followed by a newline.

See also:
Puts_P()
void PrintNumber ( long  n)

Legacy function to print a number

Parameters:
nis the number to print
See also:
print(n)
int PutChar ( uint8_t  c)

output a character

Parameters:
cthe 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.

See also:
Puts()
Puts_P()
write()
void Puts ( char *  str)

output a character string

Parameters:
strpointer 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.

See also:
PutChar()
Puts_P()
DrawString()
DrawString_P()
write()
void Puts ( const String &  str)

output a String class string

Parameters:
strString class 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.

See also:
PutChar()
Puts_P()
DrawString()
DrawString_P()
write()
void Puts_P ( PGM_P  str)

output a program memory character string

Parameters:
strpointer 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.

See also:
PutChar()
Puts()
DrawString()
DrawString_P()
write()
uint8_t ReadData ( void  ) [inline, protected, inherited]

read a data byte from display device memory

Returns:
the data byte at the current x,y position
Note:
the current x,y location is not modified by the routine. This allows a read/modify/write operation. Code can call ReadData() modify the data then call WriteData() and update the same location.
See also:
WriteData()

Reimplemented in glcd.

void SelectFont ( Font_t  font,
uint8_t  color = BLACK,
FontCallback  callback = ReadPgmData 
)

Select a Font and font color

Parameters:
fonta font definition
colorcan be WHITE or BLACK and defaults to black
callbackoptional 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).

Note:
When the display is initilized in normal mode, BLACK renders dark pixels on a white background and WHITE renders white pixels on black background; however, if the display is set to INVERTED mode all colors are inverted.
See also:
SetFontColor()
SetTextMode()
void SetDot ( uint8_t  x,
uint8_t  y,
uint8_t  color 
) [protected, inherited]

set pixel at x,y to the given color

Parameters:
xX coordinate, a value from 0 to GLCD.Width-1
yY coordinate, a value from 0 to GLCD.Heigh-1
colorWHITE 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.

Note:
If the display has been set to INVERTED mode then the colors will be automically reversed.

Reimplemented in glcd.

void SetFontColor ( uint8_t  color)

Select a font color

Parameters:
colorcan be WHITE or BLACK
See also:
SelectFont()
SetTextMode()
void SetPixels ( uint8_t  x,
uint8_t  y,
uint8_t  x2,
uint8_t  y2,
uint8_t  color 
) [protected, inherited]

set an area of pixels

Parameters:
xX coordinate of upper left corner
yY coordinate of upper left corner
x2X coordinate of lower right corner
y2Y coordinate of lower right corner
colorsets 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)

Set TextArea mode

Parameters:
modetext area mode

Currently mode is a scroll direction

  • SCROLL_UP
  • SCROLL_DOWN
See also:
SelectFont()
SetFontColor()
DefineArea()
uint16_t StringWidth ( const char *  str)

Returns the pixel width of a string

Parameters:
strpointer to string stored in RAM
Returns:
the width in pixels of the sum of all the characters in the the string pointed to by str.
See also:
CharWidth()
StringWidth_P()
uint16_t StringWidth_P ( PGM_P  str)

Returns the pixel width of a character

Parameters:
strpointer to string stored in program memory
Returns:
the width in pixels of the sum of all the characters in the the string pointed to by str.
See also:
CharWidth()
StringWidth()
uint16_t StringWidth_P ( String &  str)

Returns the pixel width of a character

Parameters:
strString class string
Returns:
the width in pixels of the sum of all the characters in the the string pointed to by str.
See also:
CharWidth()
StringWidth()
void write ( uint8_t  c)

output a character to the text area

Parameters:
cthe character to output

This method is needed for the Print base class

See also:
PutChar()

Reimplemented from glcd_Device.

void WriteData ( uint8_t  data) [protected, inherited]

Write a byte to display device memory

Parameters:
datadate 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.

Note:
the full behavior of this during split byte writes currently varies depending on a compile time define. The code can be configured to either OR in 1 data bits or set all the data bits. TRUE_WRITE controls this behavior.
the x,y address will not be the same as it was prior to this call. The y address will remain the aame but the x address will advance by one. This allows back to writes to write sequentially through memory without having to do additional x,y positioning.
See also:
ReadData()

Reimplemented in glcd.


The documentation for this class was generated from the following files:
 All Classes Functions Variables