Οθόνη#

Εισαγωγή#

Οι μέθοδοι Οθόνης ελέγχουν τον τρόπο με τον οποίο ο εγκέφαλος EXP εμφανίζει κείμενο, αριθμούς και γραφικά στην οθόνη του.

Από προεπιλογή, η γραμματοσειρά για εκτύπωση στο Brain είναι monospaced small η οποία έχει 7 γραμμές και 20 στήλες.

Για το σχέδιο, η ανάλυση του Brain είναι 159 x 107 pixel.

Ένα διάγραμμα πλέγματος με ετικέτες της οθόνης VEX Brain που δείχνει γραμμές, στήλες, διαστάσεις pixel και συντεταγμένες, με κόκκινες γραμμές που σκιαγραφούν το πλέγμα.

Παρακάτω είναι μια λίστα με τις διαθέσιμες μεθόδους:

Εκτύπωση δρομέα – Εμφάνιση κειμένου και διαχείριση του δρομέα εκτύπωσης.

  • print – Prints text, numbers, or variable values at the current cursor position.

  • print_at – Prints text, numbers, or variable values at specific x and y coordinates.

  • set_cursor – Moves the cursor to a specific row and column.

  • set_origin – Sets the origin used for coordinate-based printing and drawing.

  • next_row – Moves the cursor to the next row.

  • clear_row – Clears a row of text.

  • row – Returns the row where text will be printed.

  • column – Returns the column where text will be printed.

  • get_string_width – Returns the width of a string in pixels using the current font.

  • get_string_height – Returns the height of a string in pixels using the current font.

Μεταλλαγμένοι – Αλλάξτε τις ρυθμίσεις της οθόνης, τα χρώματα και τη συμπεριφορά σχεδίασης.

  • clear_screen – Clears all drawings and text from the Brain screen.

  • set_font – Sets the font type used for printing text on the Brain’s screen.

  • set_pen_width – Sets the thickness of drawn lines and shape outlines.

  • set_pen_color – Sets the color of text, pixels, lines, and shape outlines.

  • set_fill_color – Sets the fill color for drawn shapes and printed text backgrounds.

Σχεδίαση – Δημιουργήστε σχήματα, γραμμές και γραφικά στην οθόνη Brain.

  • draw_pixel – Draws one pixel at a coordinate.

  • draw_line – Draws a line between two points.

  • draw_rectangle – Draws a rectangle using the current pen and fill colors.

  • draw_circle – Draws a circle using the current pen and fill colors.

  • draw_image_from_file – Draws an image from the SD card.

  • render – Switches drawing to double buffered and renders the Brain’s screen.

  • set_clip_region – Sets the clip region for drawing the supplied rectangle.

Εκτύπωση δρομέα#

print#

print prints text, numbers, or variable values on the Brain screen at the current cursor position and font.

Χρήση:

brain.screen.print(text, sep, precision)

Παράμετροι

Περιγραφή

text

Το κείμενο, ο αριθμός ή η τιμή μεταβλητής που θα εκτυπωθεί.

sep

Optional. A string to inset between values. This must be written as a keyword argument (sep=). The default is “”.

precision

Optional. The number of decimal places to display when printing simple numbers. This must be written as a keyword argument(precision=). The default is 2.

brain.screen.print("Hello, Robot!")

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει την ένδειξη "Hello Robot" τυπωμένη στην οθόνη.

# Print the number 1 on the Brain's screen at current
# cursor position.
brain.screen.print(1)

# Print the numbers 1, 2, 3 and 4 on the Brain's screen at
# current cursor position separated by a '-'.
brain.screen.print(1, 2, 3, 4, sep='-')

set_cursor#

set_cursor moves the cursor to a specific row and column on the Brain screen. The next print call will start printing at that location. The row and column spacing will take into account the selected font. The default cursor position is Row 1, Column 1.

Χρήση:

brain.screen.set_cursor(row, column)

Παράμετροι

Περιγραφή

row

Η γραμμή στην οποία θα μετακινηθεί ο κέρσορας.

column

Η στήλη στην οποία θα μετακινηθεί ο κέρσορας.

# Display text starting at Row 3 Column 10.
brain.screen.set_cursor(3, 10)
brain.screen.print("R3, C10")

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει την ένδειξη "R3, C10" τυπωμένη στην οθόνη.

set_origin#

set_origin sets the origin used for drawing and coordinate-based printing on the Brain screen. By default, the origin is the top-left corner of the screen.

Χρήση:

brain.screen.set_origin(x, y)

Παράμετροι

Περιγραφή

x

Η θέση x της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία, από 0 έως 159.

y

Η θέση y της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία, από 0 έως 107.

next_row#

next_row moves the cursor to column 1 on the next row on the Brain screen.

Χρήση:

brain.screen.next_row()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Display two lines of text.
brain.screen.print("Line 1")
brain.screen.next_row()
brain.screen.print("Line 2")

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει το κείμενο "3" στη σειρά 3.

clear_row#

clear_row clears a single row of text on the Brain screen.

Χρήση:

brain.screen.clear_row(row)

Παράμετροι

Περιγραφή

row

Προαιρετικό. Η γραμμή που θα διαγραφεί. Η προεπιλογή είναι η τρέχουσα γραμμή του δρομέα.

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Clear Brain's screen to black.
brain.screen.clear_row()

# Clear Brain's screen to blue using predefined color.
brain.screen.clear_row(2, Color.BLUE)

row#

row returns the row where text will be printed as an integer.

Χρήση:

brain.screen.row()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Display the cursor's current row.
brain.screen.set_cursor(3, 10)
brain.screen.print(brain.screen.row())

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει το κείμενο "3" στη σειρά 3.

column#

column returns the column where text will be printed as an integer.

Χρήση:

brain.screen.column()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Display the cursor's current column.
brain.screen.set_cursor(3, 10)
brain.screen.print(brain.screen.column())

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει το κείμενο "10" στη στήλη 10.

get_string_width#

get_string_width returns the width of a string in pixels as an integer, using the current font.

Χρήση:

brain.screen.get_string_width(string)

Παράμετροι

Περιγραφή

string

Η χορδή που θα μετρηθεί.

get_string_height#

get_string_height returns the height of a string in pixels as an integer, using the current font.

Χρήση:

brain.screen.get_string_height(string)

Παράμετροι

Περιγραφή

string

Η χορδή που θα μετρηθεί.

Μεταλλάκτες#

clear_screen#

clear_screen clears all drawings and text from the Brain’s screen.

Χρήση:

brain.screen.clear_screen(color)

Παράμετροι

Περιγραφή

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to black.
brain.screen.clear_screen()

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to blue using predefined color.
brain.screen.clear_screen(Color.BLUE)

set_font#

set_font sets the font used for displaying text on the Brain screen. This font will apply to all text printed after this method runs.

Χρήση:

brain.screen.set_font(fontname)

Παράμετροι

Περιγραφή

fontname

The font size (examples below):

  • MONO12
  • MONO15
  • MONO20
  • MONO30
  • MONO40
  • MONO60
  • PROP20
  • PROP30
  • PROP40
  • PROP60
Note: Extra small and small sizes are not available for proportional fonts.

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους MONO 12. Δείχνει από το Α έως το Ω και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφεται 9 σειρές, 26 στήλες.
MONO12

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους MONO 15. Δείχνει από το A έως το T και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφει 7 σειρές, 22 στήλες.
MONO15

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους MONO 20. Δείχνει από το A έως το P και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφει 5 σειρές, 16 στήλες.
MONO20

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους MONO 30. Εμφανίζονται από A έως J. Στο κάτω μέρος της οθόνης, αναγράφεται R:3 C:10.
MONO30

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους MONO 40. Στο κάτω μέρος της οθόνης, αναγράφεται R:2 C:8.
MONO40

Ο εγκέφαλος εκτύπωσε αριθμούς και γράμματα με μέγεθος γραμματοσειράς MONO 60. Εμφανίζεται μόνο το MON60.
MONO60

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους PROP 20. Δείχνει από το A έως το W και όλους τους αριθμούς. Στο κάτω μέρος της οθόνης, αναγράφει 5 σειρές, 16 στήλες.
PROP20

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους PROP 30. Δείχνει από το A έως το P. Στο κάτω μέρος της οθόνης, γράφει R:3 C:10.
PROP30

Η οθόνη του εγκεφάλου τύπωσε αριθμούς και γράμματα με γραμματοσειρά μεγέθους PROP 40. Στο κάτω μέρος της οθόνης, αναγράφεται R:2 C:8.
PROP40

Ο εγκέφαλος εκτύπωσε αριθμούς και γράμματα με μέγεθος γραμματοσειράς PROP 60. Εμφανίζεται μόνο το PROP60.
PROP60

# Set the font type to MONO40.
brain.screen.set_font(FontType.MONO40)
brain.screen.print("VEX")

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει το κείμενο "VEX" σε μεγαλύτερη γραμματοσειρά από την προεπιλεγμένη.

set_pen_width#

set_pen_width sets the thickness of drawn lines and shape outlines.

Χρήση:

brain.screen.set_pen_width(width)

Παράμετροι

Περιγραφή

width

Το πλάτος της πένας, σε pixel, κυμαίνεται από 0 έως 32.

# Draw a rectangle with a pen width of 10.
brain.screen.set_pen_width(10)
brain.screen.draw_rectangle(20, 20, 75, 50)

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει ένα ορθογώνιο με παχιά περιγράμματα.

set_pen_color#

set_pen_color sets the color of text, pixels, lines, and shape outlines.

Χρήση:

brain.screen.set_pen_color(color)

Παράμετροι

Περιγραφή

color

The pen and font color to use. This can be a valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Draw a rectangle with orange borders.
brain.screen.set_pen_color(Color.ORANGE)
brain.screen.draw_rectangle(20, 20, 75, 50)

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει ένα ορθογώνιο με πορτοκαλί περιγράμματα.

# Set pen color red using a hex value.
brain.screen.set_pen_color(0xFF0000)

# Set pen color blue using predefined color.
brain.screen.set_pen_color(Color.BLUE)

# Set pen color green using web string.
brain.screen.set_pen_color("#00FF00")

set_fill_color#

set_fill_color sets the fill color used for drawing rectangles and circles.

Χρήση:

brain.screen.set_fill_color(color)

Παράμετροι

Περιγραφή

color

The fill color to use. This can be a valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Draw a purple rectangle.
brain.screen.set_fill_color(Color.PURPLE)
brain.screen.draw_rectangle(20, 20, 75, 50)

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει ένα ορθογώνιο γεμάτο με μωβ.

# Set fill color red using a hex value.
brain.screen.set_fill_color(0xFF0000)

# Set fill color blue using predefined color.
brain.screen.set_fill_color(Color.BLUE)

# Set fill color green using web string.
brain.screen.set_fill_color("#00FF00")

Ισοπαλία#

draw_pixel#

draw_pixel draws one pixel at the selected x and y coordinate using the current pen color.

Χρήση:

brain.screen.draw_pixel(x, y)

Παράμετροι

Περιγραφή

x

Η συντεταγμένη x για τη σχεδίαση του εικονοστοιχείου, από 0 έως 159, με αναφορά στην αρχή της οθόνης.

y

Η συντεταγμένη y για τη σχεδίαση του pixel, από 0 έως 107, με αναφορά στην αρχή της οθόνης.

# Draw the pixels marking the corners of a square.
brain.screen.draw_pixel(50, 50)
brain.screen.draw_pixel(50, 75)
brain.screen.draw_pixel(75, 50)
brain.screen.draw_pixel(75, 75)

Ένα στιγμιότυπο οθόνης του εγκεφάλου EXP που δείχνει μια συλλογή από pixel που δείχνουν τις γωνίες ενός τετραγώνου.

draw_line#

draw_line draws a line from the first screen coordinate (x1, y1) to the second screen coordinate (x2, y2) using the current pen width and pen color.

Χρήση:

brain.screen.draw_line(x1, y1, x2, y2)

Παράμετροι

Περιγραφή

x1

Η συντεταγμένη x σε pixel της αρχής της γραμμής, από 0 έως 159, που αναφέρεται στην αρχή της οθόνης.

y1

Η συντεταγμένη y σε pixel της αρχής της γραμμής, από 0 έως 107, που αναφέρεται στην αρχή της οθόνης.

x2

Η συντεταγμένη x σε pixel του τέλους της γραμμής, από 0 έως 159, που αναφέρεται στην αρχή της οθόνης.

y2

Η συντεταγμένη y σε pixel του τέλους της γραμμής, από 0 έως 107, που αναφέρεται στην αρχή της οθόνης.

# Draw a line from the top left to bottom right of the screen.
brain.screen.draw_line(0, 0, 159, 107)

Η οθόνη του εγκεφάλου δείχνει μια λεπτή διαγώνια γραμμή στο κέντρο, από την επάνω αριστερή γωνία έως την κάτω δεξιά γωνία.

draw_rectangle#

draw_rectangle draws a rectangle using the current pen width, pen color, and fill color, unless the optional color parameter is used.

Χρήση:

brain.screen.draw_rectangle(x, y, width, height, color)

Παράμετροι

Περιγραφή

x

Η συντεταγμένη x σε pixel της επάνω αριστερής γωνίας του ορθογωνίου, από 0 έως 159, που αναφέρεται στην αρχή της οθόνης.

y

Η συντεταγμένη y σε pixel της επάνω αριστερής γωνίας του ορθογωνίου, από 0 έως 107, που αναφέρεται στην αρχή της οθόνης.

width

Το πλάτος του ορθογωνίου.

height

Το ύψος του ορθογωνίου.

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Draw a rectangle on the screen.
brain.screen.draw_rectangle(20, 20, 80, 30)

Η οθόνη του εγκεφάλου εμφανίζει ένα ορθογώνιο με ένα λεπτό λευκό περίγραμμα στην οθόνη.

# Draw a green rectangle on the screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_rectangle(10, 10, 20, 20)

# Draw a green rectangle on the screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_rectangle(50, 50, 20, 20, Color.RED)

draw_circle#

draw_circle draws a circle using the current pen width, pen color, and fill color, unless the optional color parameter is used.

Χρήση:

brain.screen.draw_circle(x, y, radius, color)

Παράμετροι

Περιγραφή

x

Η συντεταγμένη x σε pixel του κέντρου του κύκλου, από 0 έως 159, που αναφέρεται στην αρχή της οθόνης.

y

Η συντεταγμένη y σε pixel του κέντρου του κύκλου, από 0 έως 107, που αναφέρεται στην αρχή της οθόνης.

radius

Η ακτίνα του κύκλου.

color

Optional. A valid ColorType, a hex value, or a web string.

  • Color.BLACK
  • Color.BLUE
  • Color.GREEN
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED
  • Color.VIOLET
  • Color.WHITE
  • Color.YELLOW
You can also specify a custom color.

# Draw a circle on the screen.
brain.screen.draw_circle(80, 50, 20)

Η οθόνη του εγκεφάλου δείχνει έναν κύκλο με ένα λεπτό λευκό περίγραμμα στο κέντρο.

# Draw a green circle on the Brain's screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_circle(50, 50, 10)

# Draw a green circle on the Brain's screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_circle(100, 50, 10, Color.RED)

draw_image_from_file#

draw_image_from_file draws an image from the SD card. The filename you put when calling the method must be located on the SD card.

Χρήση:

brain.screen.draw_image_from_file(filename, x, y)

Παράμετροι

Περιγραφή

filename

Το όνομα αρχείου της εικόνας.

x

Η συντεταγμένη x για την επάνω αριστερή γωνία της εικόνας στην οθόνη.

y

Η συντεταγμένη y για την επάνω αριστερή γωνία της εικόνας στην οθόνη.

# Draw the vex.bmp image on the Brain's screen at coordinate 0, 0.
brain.screen.draw_image_from_file('vex.bmp', 0, 0)

render#

render switches drawing to double buffered and renders the Brain’s screen. Once called, further drawing will not appear on the Brain’s screen until the next time render is called.

  • True if buffer was successfully rendered to the screen.

  • False if buffer was not successfully rendered to the screen.

Χρήση:

brain.screen.render()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

set_clip_region#

set_clip_region defines a rectangular area on the screen where all drawings and text will be confined. Any content outside this region will not be displayed.

Χρήση:

brain.screen.set_clip_region(x, y, width, height)

Παράμετροι

Περιγραφή

x

Η θέση x της επάνω αριστερής γωνίας του ορθογωνίου, που αναφέρεται στην αρχή της οθόνης.

y

Η θέση y της επάνω αριστερής γωνίας του ορθογωνίου, που αναφέρεται στην αρχή της οθόνης.

width

Το πλάτος του ορθογωνίου.

height

Το ύψος του ορθογωνίου.