VEX V5 C++ API
Public Member Functions | List of all members
vex::brain::lcd Class Reference

Use this class to write or draw to the brain's LCD screen. More...

Public Member Functions

 lcd ()
 
 ~lcd ()
 
void setCursor (int32_t row, int32_t col)
 Sets the cursor to the row and column number set in the parameters. More...
 
void setFont (fontType font)
 Sets the font type to be displayed on the Screen that is determined by the parameter. More...
 
void setPenWidth (uint32_t width)
 Sets the pen's width. More...
 
void setOrigin (int32_t x, int32_t y)
 Sets the origin of the screen to the parameters defined in the function. More...
 
int32_t column ()
 An integer that tracks the current cursor position's column, starting at 1. More...
 
int32_t row ()
 An integer that tracks the current cursor position's row, starting at 1. More...
 
template<class T >
void setPenColor (T color)
 
void setPenColor (const color &color)
 Sets the color of the pen to a specified color. More...
 
void setPenColor (const char *color)
 Sets the color of the pen to a specified color using a hex value. More...
 
void setPenColor (int hue)
 Sets the color of the pen to a specified color. More...
 
template<class T >
void setFillColor (T color)
 
void setFillColor (const color &color)
 Sets the default fill color for any subsequent draw command. More...
 
void setFillColor (const char *color)
 Sets the default fill color for any subsequent draw command. More...
 
void setFillColor (int hue)
 Sets the default fill color for any subsequent draw command. More...
 
int32_t getStringWidth (const char *cstr)
 Gets the width in pixels of the given string. More...
 
int32_t getStringHeight (const char *cstr)
 Gets the height in pixels of the given string. More...
 
template<class T >
void print (T value)
 Prints a number, string, or boolean. More...
 
void print (const char *format,...)
 
void print (char *format,...)
 
void printLine (int32_t number, const char *format,...)
 Prints a number, string, or boolean at a particular line, clearing the rest of the line. More...
 
void printAt (int32_t x, int32_t y, const char *format,...)
 Prints a number, string, or boolean at an x, y pixel location. More...
 
void printAt (int32_t x, int32_t y, bool bOpaque, const char *format,...)
 Prints a number, string, or boolean at an x, y pixel location with the ability to be transparent. More...
 
template<class T >
void clearScreen (T color)
 
void clearScreen (void)
 Clears the whole Screen to a default color or otherwise specified color. More...
 
void clearScreen (const color &color)
 Clears the whole Screen to a default color or otherwise specified color. More...
 
void clearScreen (const char *color)
 Clears the whole Screen to a default color or otherwise specified color. More...
 
void clearScreen (int hue)
 Clears the whole Screen to a default color or otherwise specified color. More...
 
template<class T1 , class C >
void clearLine (T1 number, C color)
 
void clearLine (int number, const color &color)
 Clears the specified line and sets it to a specified color. More...
 
void clearLine (int number, const char *color)
 Clears the specified line and sets it to a specified color. More...
 
void clearLine (int number, int hue)
 Clears the specified line and sets it to a specified color. More...
 
void clearLine (void)
 Clears the rest of the line from where the cursor is located. More...
 
void newLine (void)
 
void drawPixel (int x, int y)
 Draws a single pixel to the screen in the specified x and y location. More...
 
void drawLine (int x1, int y1, int x2, int y2)
 Draws a line connecting the two specified points in the parameters. More...
 
template<class T1 , class T2 , class T3 , class T4 , class C >
void drawRectangle (T1 x, T2 y, T3 width, T4 height, C color)
 
void drawRectangle (int x, int y, int width, int height)
 Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the current pen and fill color. More...
 
void drawRectangle (int x, int y, int width, int height, const color &color)
 Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified. More...
 
void drawRectangle (int x, int y, int width, int height, const char *color)
 Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified. More...
 
void drawRectangle (int x, int y, int width, int height, int hue)
 Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified. More...
 
template<class T1 , class T2 , class T3 , class C >
void drawCircle (T1 x, T2 y, T3 radius, C color)
 
void drawCircle (int x, int y, int radius)
 Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the current pen and fill color. More...
 
void drawCircle (int x, int y, int radius, const color &color)
 Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified. More...
 
void drawCircle (int x, int y, int radius, const char *color)
 Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified. More...
 
void drawCircle (int x, int y, int radius, int hue)
 Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified. More...
 
void drawBitmap (const bitmap &image, int x=0, int y=0)
 Draws a bitmap image on the screen. More...
 
void drawEyes (EyesIdT eyesId)
 Draws eye graphics on the screen. More...
 
int32_t xPosition ()
 Gets the last x location pressed on the screen. More...
 
int32_t yPosition ()
 Gets the last y location pressed on the screen. More...
 
bool pressing ()
 Gets the pressed status of the Screen. More...
 
bool render ()
 Switches to double buffering or renders back buffer to screen. More...
 
bool render (bool bVsyncWait, bool bRunScheduler=true)
 Switches to double buffering or renders back buffer to screen. More...
 
bool drawImageFromBuffer (uint8_t *buffer, int x, int y, int bufferLen)
 Draws an image on the screen using the contents of the memory buffer. More...
 
bool drawImageFromBuffer (uint32_t *buffer, int x, int y, int width, int height)
 Draws an image on the screen using the contents of the memory buffer. More...
 
bool drawImageFromFile (const char *name, int x, int y)
 Draws an image on the screen using a file on the SD Card as the source. More...
 

Detailed Description

Use this class to write or draw to the brain's LCD screen.

The LCD screen has a resolution of 480x240 pixels

Constructor & Destructor Documentation

◆ lcd()

vex::brain::lcd::lcd ( )

◆ ~lcd()

vex::brain::lcd::~lcd ( )
inline

Member Function Documentation

◆ setCursor()

void vex::brain::lcd::setCursor ( int32_t  row,
int32_t  col 
)

Sets the cursor to the row and column number set in the parameters.

Parameters
rowSets the row number for where the cursor is placed. 1 is the top row.
colSets the column number for where the cursor is placed. 1 is the left column.

◆ setFont()

void vex::brain::lcd::setFont ( fontType  font)

Sets the font type to be displayed on the Screen that is determined by the parameter.

Parameters
fontThe type of font that is displayed.

◆ setPenWidth()

void vex::brain::lcd::setPenWidth ( uint32_t  width)

Sets the pen's width.

Parameters
widthThis represents the width of the pen when drawing. A larger width equals a wider pen stroke.

◆ setOrigin()

void vex::brain::lcd::setOrigin ( int32_t  x,
int32_t  y 
)

Sets the origin of the screen to the parameters defined in the function.

Parameters
xThe x location of the origin.
yThe y location of the origin.

◆ column()

int32_t vex::brain::lcd::column ( )

An integer that tracks the current cursor position's column, starting at 1.

Returns
Returns an integer that tracks the current cursor position's column, starting at 1.

◆ row()

int32_t vex::brain::lcd::row ( )

An integer that tracks the current cursor position's row, starting at 1.

Returns
Returns an integer that tracks the current cursor position's row, starting at 1.

◆ setPenColor() [1/4]

template<class T >
void vex::brain::lcd::setPenColor ( color)
inline

◆ setPenColor() [2/4]

void vex::brain::lcd::setPenColor ( const color color)

Sets the color of the pen to a specified color.

Parameters
colorA color unit where colors can be defined as names.

◆ setPenColor() [3/4]

void vex::brain::lcd::setPenColor ( const char *  color)

Sets the color of the pen to a specified color using a hex value.

Parameters
colorA hexadecimal value that represents color.

◆ setPenColor() [4/4]

void vex::brain::lcd::setPenColor ( int  hue)

Sets the color of the pen to a specified color.

Parameters
hueThe integer represents the hue of the color.

◆ setFillColor() [1/4]

template<class T >
void vex::brain::lcd::setFillColor ( color)
inline

◆ setFillColor() [2/4]

void vex::brain::lcd::setFillColor ( const color color)

Sets the default fill color for any subsequent draw command.

Parameters
colorIn a color unit, colors can be defined as names.

◆ setFillColor() [3/4]

void vex::brain::lcd::setFillColor ( const char *  color)

Sets the default fill color for any subsequent draw command.

Parameters
colorA hexadecimal value that represents color.

◆ setFillColor() [4/4]

void vex::brain::lcd::setFillColor ( int  hue)

Sets the default fill color for any subsequent draw command.

Parameters
hueThe integer represents the hue of the color.

◆ getStringWidth()

int32_t vex::brain::lcd::getStringWidth ( const char *  cstr)

Gets the width in pixels of the given string.

Returns
Returns an integer that represents the width of the string in pixels.

◆ getStringHeight()

int32_t vex::brain::lcd::getStringHeight ( const char *  cstr)

Gets the height in pixels of the given string.

Returns
Returns an integer that represents the height of the string in pixels.

◆ print() [1/3]

template<class T >
void vex::brain::lcd::print ( value)
inline

Prints a number, string, or boolean.

Parameters
valueInformation to display on the screen.

◆ print() [2/3]

void vex::brain::lcd::print ( const char *  format,
  ... 
)
Parameters
formatThis is a reference to a char format that prints the value of variables.
...A variable list of parameters to insert into format string.

◆ print() [3/3]

void vex::brain::lcd::print ( char *  format,
  ... 
)

◆ printLine()

void vex::brain::lcd::printLine ( int32_t  number,
const char *  format,
  ... 
)

Prints a number, string, or boolean at a particular line, clearing the rest of the line.

Parameters
numberLine to print on, 1 is top line.
formatThis is a reference to a char format that prints the value of variables.
...A variable list of parameters to insert into format string.

◆ printAt() [1/2]

void vex::brain::lcd::printAt ( int32_t  x,
int32_t  y,
const char *  format,
  ... 
)

Prints a number, string, or boolean at an x, y pixel location.

Parameters
xThe x-coordinate at which to print a message on the screen.
yThe y-coordinate at which to print the baseline of the message on the screen.
formatA reference to a char format to print the value of variables.
...A variable list of parameters to insert into format string.

◆ printAt() [2/2]

void vex::brain::lcd::printAt ( int32_t  x,
int32_t  y,
bool  bOpaque,
const char *  format,
  ... 
)

Prints a number, string, or boolean at an x, y pixel location with the ability to be transparent.

Parameters
xThe x-coordinate at which to print a message on the screen.
yThe y-coordinate at which to print the baseline of the message on the screen.
bOpaqueIf set to false, the print will be transparent.
formatA reference to a char format to print the value of variables.
...A variable list of parameters to insert into format string.

◆ clearScreen() [1/5]

template<class T >
void vex::brain::lcd::clearScreen ( color)
inline

◆ clearScreen() [2/5]

void vex::brain::lcd::clearScreen ( void  )

Clears the whole Screen to a default color or otherwise specified color.

◆ clearScreen() [3/5]

void vex::brain::lcd::clearScreen ( const color color)

Clears the whole Screen to a default color or otherwise specified color.

Parameters
colorIn a color unit, colors can be defined as names.

◆ clearScreen() [4/5]

void vex::brain::lcd::clearScreen ( const char *  color)

Clears the whole Screen to a default color or otherwise specified color.

Parameters
colorA hexadecimal value that represents color.

◆ clearScreen() [5/5]

void vex::brain::lcd::clearScreen ( int  hue)

Clears the whole Screen to a default color or otherwise specified color.

Parameters
hueThe integer represents the hue of the color.

◆ clearLine() [1/5]

template<class T1 , class C >
void vex::brain::lcd::clearLine ( T1  number,
color 
)
inline

◆ clearLine() [2/5]

void vex::brain::lcd::clearLine ( int  number,
const color color 
)

Clears the specified line and sets it to a specified color.

Parameters
numberThe integer sets the line that is to be cleared.
colorA color unit where colors can be defined as names.

◆ clearLine() [3/5]

void vex::brain::lcd::clearLine ( int  number,
const char *  color 
)

Clears the specified line and sets it to a specified color.

Parameters
numberThe integer sets the line that is to be cleared.
colorA hexadecimal value that represents color.

◆ clearLine() [4/5]

void vex::brain::lcd::clearLine ( int  number,
int  hue 
)

Clears the specified line and sets it to a specified color.

Parameters
numberThe integer sets the line that is to be cleared.
hueAn integer that represents the hue of the color.

◆ clearLine() [5/5]

void vex::brain::lcd::clearLine ( void  )

Clears the rest of the line from where the cursor is located.

◆ newLine()

void vex::brain::lcd::newLine ( void  )

◆ drawPixel()

void vex::brain::lcd::drawPixel ( int  x,
int  y 
)

Draws a single pixel to the screen in the specified x and y location.

Parameters
xThe x location of where to draw the pixel.
yThe y location of where to draw the pixel.

◆ drawLine()

void vex::brain::lcd::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a line connecting the two specified points in the parameters.

Parameters
x1The x location of the first point.
y1The y location of the first point.
x2The x location of the second point.
y2The y location of the second point.

◆ drawRectangle() [1/5]

template<class T1 , class T2 , class T3 , class T4 , class C >
void vex::brain::lcd::drawRectangle ( T1  x,
T2  y,
T3  width,
T4  height,
color 
)
inline

◆ drawRectangle() [2/5]

void vex::brain::lcd::drawRectangle ( int  x,
int  y,
int  width,
int  height 
)

Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the current pen and fill color.

Parameters
xThe x-coordinate at which the left edge of the rectangle will be drawn on the screen.
yThe y-coordinate at which the top edge of the rectangle will be drawn on the screen.
widthThe width of the rectangle.
heightThe height of the rectangle.

◆ drawRectangle() [3/5]

void vex::brain::lcd::drawRectangle ( int  x,
int  y,
int  width,
int  height,
const color color 
)

Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified.

Parameters
xThe x-coordinate at which the left edge of the rectangle will be drawn on the screen.
yThe y-coordinate at which the top edge of the rectangle will be drawn on the screen.
widthThe width of the rectangle.
heightThe height of the rectangle.
colorA color unit where colors can be defined as names.

◆ drawRectangle() [4/5]

void vex::brain::lcd::drawRectangle ( int  x,
int  y,
int  width,
int  height,
const char *  color 
)

Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified.

Parameters
xThe x-coordinate at which the left edge of the rectangle will be drawn on the screen.
yThe y-coordinate at which the top edge of the rectangle will be drawn on the screen.
widthThe width of the rectangle.
heightThe height of the rectangle.
colorA hexadecimal value that represents color.

◆ drawRectangle() [5/5]

void vex::brain::lcd::drawRectangle ( int  x,
int  y,
int  width,
int  height,
int  hue 
)

Draws a rectangle using the specified points and attributes set in the parameters. Fills the rectangle with the color specified.

Parameters
xThe x-coordinate at which the left edge of the rectangle will be drawn on the screen.
yThe y-coordinate at which the top edge of the rectangle will be drawn on the screen.
widthThe width of the rectangle.
heightThe height of the rectangle.
hueThe color of the rectangle.

◆ drawCircle() [1/5]

template<class T1 , class T2 , class T3 , class C >
void vex::brain::lcd::drawCircle ( T1  x,
T2  y,
T3  radius,
color 
)
inline

◆ drawCircle() [2/5]

void vex::brain::lcd::drawCircle ( int  x,
int  y,
int  radius 
)

Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the current pen and fill color.

Parameters
xThe central x location of the circle.
yThe central y location of the circle.
radiusSets the radius of the circle to be drawn on the Screen.

◆ drawCircle() [3/5]

void vex::brain::lcd::drawCircle ( int  x,
int  y,
int  radius,
const color color 
)

Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified.

Parameters
xThe central x location of the circle.
yThe central y location of the circle.
radiusSets the radius of the circle to be drawn on the Screen.
colorA color unit where colors can be defined as names.

◆ drawCircle() [4/5]

void vex::brain::lcd::drawCircle ( int  x,
int  y,
int  radius,
const char *  color 
)

Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified.

Parameters
xThe central x location of the circle.
yThe central y location of the circle.
radiusSets the radius of the circle to be drawn on the Screen.
colorA hexadecimal value that represents color.

◆ drawCircle() [5/5]

void vex::brain::lcd::drawCircle ( int  x,
int  y,
int  radius,
int  hue 
)

Draws a circle using the specified points and attributes set in the parameters. Fills the circle with the color specified.

Parameters
xThe central x location of the circle.
yThe central y location of the circle.
radiusSets the radius of the circle to be drawn on the Screen.
hueAn integer that represents the hue of the color.

◆ drawBitmap()

void vex::brain::lcd::drawBitmap ( const bitmap image,
int  x = 0,
int  y = 0 
)

Draws a bitmap image on the screen.

Parameters
imageThe bitmap image to draw
xThe left-coordinate of the bitmap (default 0)
yThe top-coordinate of the bitmap (default 0)

◆ drawEyes()

void vex::brain::lcd::drawEyes ( EyesIdT  eyesId)

Draws eye graphics on the screen.

Parameters
eyesIdEYES_* eyes id value

◆ xPosition()

int32_t vex::brain::lcd::xPosition ( )

Gets the last x location pressed on the screen.

Returns
Returns an integer that represents the last x location pressed on the screen.

◆ yPosition()

int32_t vex::brain::lcd::yPosition ( )

Gets the last y location pressed on the screen.

Returns
Returns an integer that represents the last y location pressed on the screen.

◆ pressing()

bool vex::brain::lcd::pressing ( )

Gets the pressed status of the Screen.

Returns
Returns a Boolean based on the state of a press on the screen. If the screen is pressed, the Boolean will be true, if the button is released, the Boolean will be false.

◆ render() [1/2]

bool vex::brain::lcd::render ( )

Switches to double buffering or renders back buffer to screen.

Returns
Returns true if the back buffer was successfully copied to the screen.

◆ render() [2/2]

bool vex::brain::lcd::render ( bool  bVsyncWait,
bool  bRunScheduler = true 
)

Switches to double buffering or renders back buffer to screen.

Parameters
bVsyncWaitIf true, wait for the Vsync signal to render.
bRunScheduler(Optional) If true, run background tasks while waiting to render. By default, this parameter is true.
Returns
Returns true if the back buffer was successfully copied to the screen.

◆ drawImageFromBuffer() [1/2]

bool vex::brain::lcd::drawImageFromBuffer ( uint8_t *  buffer,
int  x,
int  y,
int  bufferLen 
)

Draws an image on the screen using the contents of the memory buffer.

Parameters
bufferA pointer to a buffer containing image data in either bmp or png format.
xThe x-coordinate at which the left edge of the image will be drawn.
yThe y-coordinate at which the top edge of the image will be drawn.
bufferLenThe size of the source image buffer in bytes.
Returns
Returns true if the image was successfully drawn on the screen.

This function draws an image on the screen using the contents of a buffer into which either BMP or PNG raw data has already been read. The contents may have come from a file on the SD card or have been statically declared in the code. The image should be no larger than the V5 Screen, that is, a maximum of 480 pixels wide by 272 pixels high. The top/left corner of the image is placed at the coordinates given by x and y, these can be negative if desired.

◆ drawImageFromBuffer() [2/2]

bool vex::brain::lcd::drawImageFromBuffer ( uint32_t *  buffer,
int  x,
int  y,
int  width,
int  height 
)

Draws an image on the screen using the contents of the memory buffer.

Parameters
bufferA pointer to a buffer containing raw 32 bit per pixel image data.
xThe x-coordinate at which the left edge of the image will be drawn.
yThe y-coordinate at which the top edge of the image will be drawn.
widthThe width of the image.
heightThe height of the image.
Returns
Returns true if the image was successfully drawn on the screen.

This funtion draws an image on the screen using the contents of a buffer into which raw RGB pixels have been placed. Each pixel is represented by a 32 bit value, however, only the lower 24 bits are used as transparency is not yet supported. The buffer contains pixels for the first row of the image immediately followed by pixels for the second row and so on. The image should be no larger than the V5 Screen, that is, a maximum of 480 pixels wide by 272 pixels high. The top/left corner of the image is placed at the coordinates given by x and y, these can be negative if desired.

◆ drawImageFromFile()

bool vex::brain::lcd::drawImageFromFile ( const char *  name,
int  x,
int  y 
)

Draws an image on the screen using a file on the SD Card as the source.

Parameters
nameThe name of the image, it must have either a ".bmp" or ".png" extension.
xThe x-coordinate at which the left edge of the image will be drawn.
yThe y-coordinate at which the top edge of the image will be drawn.
Returns
Returns true if the image was successfully drawn on the screen.

This funtion draws an image on the screen using the contents of a file on an SD Card. The file should be no larger than 512K bytes and must have either a ".bmp" or ".png" extension. The image should be no larger than the V5 Screen, that is, a maximum of 480 pixels wide by 272 pixels high. The top/left corner of the image is placed at the coordinates given by x and y, these can be negative if desired.