VEX V5 Python API
Public Member Functions | List of all members
vex.BrainLcd Class Reference

Use the LCD class to write or draw to the LCD The LCD screen has a resolution of 480x240 pixels. More...

Public Member Functions

def __init__ (self, parent)
 Use the LCD class to write or draw to the LCD. More...
 
def set_cursor (self, row, col)
 Sets the cursor to the row and column number set in the parameters. More...
 
def set_font (self, font)
 Sets the font type to be displayed on the LCD that is determined by the parameter. More...
 
def set_pen_width (self, width)
 Sets the pen width to the determined by the parameter set in the command. More...
 
def set_origin (self, x, y)
 Sets the origin of the LCD screen to the parameters defined in the function. More...
 
def column (self)
 An integer type represents the a column on the LCD screen. More...
 
def row (self)
 An integer type represents the a row on the LCD screen. More...
 
def set_pen_color (self, color)
 Sets the color of the pen to a specified color. More...
 
def set_pen_color_hue (self, hue)
 Sets the color of the pen to a specified color. More...
 
def set_fill_color (self, color)
 Sets the background fill color of the LCD screen to the specified color. More...
 
def set_fill_color_hue (self, color)
 
def get_string_width (self, text)
 Gets the width in pixels of the given string. More...
 
def get_string_height (self, text)
 Gets the height in pixels of the given string. More...
 
def print_ (self, text, new_line=True)
 Print a string to the screen at the cursor location. More...
 
def print_line (self, number, text)
 Print a string to the screen at a specific line. More...
 
def print_at (self, x, y, opaque, text)
 Prints a string at an x, y location with the ability to be transparent. More...
 
def clear_screen (self, color=None)
 Clears the whole LCD to a default color or otherwise specified color. More...
 
def clear_screen_hue (self, hue)
 Clears the whole LCD to a default color or otherwise specified color. More...
 
def clear_line (self, number=None, color=None)
 Clears the specified line and sets it to a specified color. More...
 
def clear_line_hue (self, number, hue)
 
def new_line (self)
 Clears the rest of the line from where the cursor is located and then moves the cursor to the beginning of the next line. More...
 
def draw_pixel (self, x, y)
 Draws a single pixel to the LCD screen in the specified x and y location. More...
 
def draw_line (self, x1, y1, x2, y2)
 Draws a line connecting the two specified points in the parameters. More...
 
def draw_rectangle (self, x, y, width, height, color=None)
 Draws a rectangle using the specified points and attributes set in the parameters. More...
 
def draw_rectangle_hue (self, x, y, width, height, hue)
 
def draw_circle (self, x, y, radius, color=None)
 Draws a circle using the specified points and attributes set in the parameters. More...
 
def draw_circle_hue (self, x, y, radius, hue)
 
def draw_bitmap (self, bitmap, x=0, y=0)
 Draws a bitmap image on the screen. More...
 
def draw_image_from_buffer (self, buffer, x=0, y=0)
 Draws an image on the screen using the contents of the memory buffer. More...
 
def draw_image_from_buffer_raw (self, buffer, x, y, width, height)
 Draws an image on the screen using the contents of the memory buffer. More...
 
def draw_image_from_file (self, filename, x=0, y=0)
 Draws an image on the screen using a file on the SD Card as the source. More...
 
def draw_eyes (self, eyes)
 Draws eye graphics on the screen. More...
 
def x_position (self)
 Gets the last x location pressed on the screen. More...
 
def y_position (self)
 Gets the last y location pressed on the screen. More...
 
def pressing (self)
 Gets the pressed status of the LCD. More...
 
def render (self, vsync_wait=True)
 Switches to double buffering or renders back buffer to screen. More...
 

Detailed Description

Use the LCD class to write or draw to the LCD The LCD screen has a resolution of 480x240 pixels.

Constructor & Destructor Documentation

◆ __init__()

def vex.BrainLcd.__init__ (   self,
  parent 
)

Use the LCD class to write or draw to the LCD.

The LCD screen has a resolution of 480x240 pixels

Member Function Documentation

◆ set_cursor()

def vex.BrainLcd.set_cursor (   self,
  row,
  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.
colSets the column number for where the cursor is placed.

◆ set_font()

def vex.BrainLcd.set_font (   self,
  font 
)

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

Parameters
fontFont enum value.

◆ set_pen_width()

def vex.BrainLcd.set_pen_width (   self,
  width 
)

Sets the pen width to the determined by the parameter set in the command.

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

◆ set_origin()

def vex.BrainLcd.set_origin (   self,
  x,
  y 
)

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

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

◆ column()

def vex.BrainLcd.column (   self)

An integer type represents the a column on the LCD screen.

Returns
Returns an integer that represents the a column on the LCD screen.

◆ row()

def vex.BrainLcd.row (   self)

An integer type represents the a row on the LCD screen.

Returns
Returns an integer that represents the a row on the LCD screen.

◆ set_pen_color()

def vex.BrainLcd.set_pen_color (   self,
  color 
)

Sets the color of the pen to a specified color.

Parameters
color0xRRGGBB color, Color enum value or a string like "#rrggbb" or "#rgb"

◆ set_pen_color_hue()

def vex.BrainLcd.set_pen_color_hue (   self,
  hue 
)

Sets the color of the pen to a specified color.

Parameters
hueAn integer that represents the hue of the color.

◆ set_fill_color()

def vex.BrainLcd.set_fill_color (   self,
  color 
)

Sets the background fill color of the LCD screen to the specified color.

*

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

◆ set_fill_color_hue()

def vex.BrainLcd.set_fill_color_hue (   self,
  color 
)

◆ get_string_width()

def vex.BrainLcd.get_string_width (   self,
  text 
)

Gets the width in pixels of the given string.

Returns
Returns an integer that represents the width of the string in pixels. int32_t getStringWidth( const char *cstr );

◆ get_string_height()

def vex.BrainLcd.get_string_height (   self,
  text 
)

Gets the height in pixels of the given string.

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

◆ print_()

def vex.BrainLcd.print_ (   self,
  text,
  new_line = True 
)

Print a string to the screen at the cursor location.

Parameters
textobject to print, usually a string. For multiple arguments, use format like "x: %g y: %g" % (x, y) -> "x: 123 y: 456" Supported format flags are g (all) x (hex) d (int) f (float)
new_line

◆ print_line()

def vex.BrainLcd.print_line (   self,
  number,
  text 
)

Print a string to the screen at a specific line.

Parameters
numberline number to print on, 1 is top line.
textobject to print, usually a string. For multiple arguments, use format like "x: %g y: %g" % (x, y) -> "x: 123 y: 456" Supported format flags are g (all) x (hex) d (int) f (float)

◆ print_at()

def vex.BrainLcd.print_at (   self,
  x,
  y,
  opaque,
  text 
)

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

Parameters
xThe x location of where the print should start
yThe y location of the baseline where the print should start
opaqueIf set to false, the print will be transparent.
textobject to print, usually a string.

◆ clear_screen()

def vex.BrainLcd.clear_screen (   self,
  color = None 
)

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

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

◆ clear_screen_hue()

def vex.BrainLcd.clear_screen_hue (   self,
  hue 
)

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

Parameters
hueAn integer that represents the hue of the color.

◆ clear_line()

def vex.BrainLcd.clear_line (   self,
  number = None,
  color = None 
)

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

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

◆ clear_line_hue()

def vex.BrainLcd.clear_line_hue (   self,
  number,
  hue 
)

◆ new_line()

def vex.BrainLcd.new_line (   self)

Clears the rest of the line from where the cursor is located and then moves the cursor to the beginning of the next line.

◆ draw_pixel()

def vex.BrainLcd.draw_pixel (   self,
  x,
  y 
)

Draws a single pixel to the LCD 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.

◆ draw_line()

def vex.BrainLcd.draw_line (   self,
  x1,
  y1,
  x2,
  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.

◆ draw_rectangle()

def vex.BrainLcd.draw_rectangle (   self,
  x,
  y,
  width,
  height,
  color = None 
)

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

Fills the rectangle with a default color unless specified.

Parameters
xThe top left x location of the rectangle.
yThe top left y location of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
color

◆ draw_rectangle_hue()

def vex.BrainLcd.draw_rectangle_hue (   self,
  x,
  y,
  width,
  height,
  hue 
)

◆ draw_circle()

def vex.BrainLcd.draw_circle (   self,
  x,
  y,
  radius,
  color = None 
)

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

Fills the circle with a default color unless specified.

Parameters
xThe central x location of the circle.
yThe central y location of the circle.
radiusSets the redius of the circle to be drawn on the LCD.
color

◆ draw_circle_hue()

def vex.BrainLcd.draw_circle_hue (   self,
  x,
  y,
  radius,
  hue 
)

◆ draw_bitmap()

def vex.BrainLcd.draw_bitmap (   self,
  bitmap,
  x = 0,
  y = 0 
)

Draws a bitmap image on the screen.

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

◆ draw_image_from_buffer()

def vex.BrainLcd.draw_image_from_buffer (   self,
  buffer,
  x = 0,
  y = 0 
)

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

Parameters
buffera buffer containing image data in 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.
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.

◆ draw_image_from_buffer_raw()

def vex.BrainLcd.draw_image_from_buffer_raw (   self,
  buffer,
  x,
  y,
  width,
  height 
)

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

Parameters
bufferA 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
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.

◆ draw_image_from_file()

def vex.BrainLcd.draw_image_from_file (   self,
  filename,
  x = 0,
  y = 0 
)

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

Parameters
filenameThe 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
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.

◆ draw_eyes()

def vex.BrainLcd.draw_eyes (   self,
  eyes 
)

Draws eye graphics on the screen.

Parameters
eyeseyes bitmap id, a vex.Eyes.XYZ constant value

◆ x_position()

def vex.BrainLcd.x_position (   self)

Gets the last x location pressed on the screen.

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

◆ y_position()

def vex.BrainLcd.y_position (   self)

Gets the last y location pressed on the screen.

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

◆ pressing()

def vex.BrainLcd.pressing (   self)

Gets the pressed status of the LCD.

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

◆ render()

def vex.BrainLcd.render (   self,
  vsync_wait = True 
)

Switches to double buffering or renders back buffer to screen.