Οθόνη#
Εισαγωγή#
The screen class is derived from the brain base class. It controls how the V5 Brain shows text, numbers, and graphics on its touchscreen, and how it responds to touch input.
Από προεπιλογή, η γραμματοσειρά για εκτύπωση στο Brain είναι monospaced small η οποία έχει 12 γραμμές και 48 στήλες.
Για το σχέδιο, η ανάλυση του Brain είναι 480 x 240 pixel.

Πρόσβαση#
The screen class can be accessed by:
Brain.Screen
Σημειώσεις#
The
screenobject is provided by the Brain. It is not constructed directly.Projects use a single global
Brainobject, so screen functions are called usingBrain.Screen.
Παράδειγμα#
/* This constructor is required when using VS Code.
A Brain is generated automatically at the start of
VEXcode projects. */
// Create the V5 Brain
brain Brain = brain();
// Print text to the Brain screen
Brain.Screen.print("Hello!");
Συναρτήσεις Μελών#
The screen class includes the following member functions:
print— Prints formatted text, numbers, or Boolean values to the Brain screen.setCursor— Moves the text cursor to a specified row and column.newLine— Clears the remainder of the current line and moves the cursor to the next line.clearLine— Clears the remainder of the current line or clears a specified line.row— Returns the row where text will be printed.column— Returns the column where text will be printed.getStringHeight— Returns the height of a string in pixels using the current font.getStringWidth— Returns the width of a string in pixels using the current font.printAt— Prints formatted text at an x, y pixel location.clearScreen— Clears all drawings and text from the Brain screen.setFont— Sets the font used for printing on the screen.setPenWidth— Sets the thickness of drawn lines and shape outlines.setPenColor— Sets the color of text, pixels, lines, and shape outlines.setFillColor— Sets the fill color for drawn shapes and printed text backgrounds.setOrigin— Sets the origin used for screen coordinates.setClipRegion— Restricts screen output to a rectangular region.drawPixel— Draws one pixel at a coordinate.drawLine— Draws a line between two points.drawRectangle— Draws a rectangle at an x, y location with a specified size.drawCircle— Draws a circle at an x, y location with a specified radius.drawImageFromFile— Draws an image from an SD card file onto the screen.render— Enables double buffering or renders the back buffer to the screen.pressing— Returns whether the screen is currently being pressed.xPosition— Returns the x-coordinate of the most recent screen press.yPosition— Returns the y-coordinate of the most recent screen press.pressed— Registers a callback function to run when the screen is pressed.released— Registers a callback function to run when the screen is released after being pressed.
Before calling any screen member functions, a brain instance must be created, as shown below:
// Create the V5 Brain
brain Brain = brain();
print#
Εμφανίζει κείμενο, αριθμούς ή λογικές τιμές στην οθόνη V5 Brain.
Available Functions1 — Εκτυπώνει μορφοποιημένο κείμενο χρησιμοποιώντας κυριολεκτικές συμβολοσειρές ή συμβολοσειρές τύπου C μόνο για ανάγνωση.
void print( const char* format, ... );
Parameters2 — Εκτυπώνει μορφοποιημένο κείμενο χρησιμοποιώντας τροποποιήσιμους πίνακες χαρακτήρων.
void print( char* format, ... );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
A format string provided as a string literal or read-only C-style string (for example, |
|
|
Μια συμβολοσειρά μορφοποίησης που παρέχεται ως τροποποιήσιμος πίνακας χαρακτήρων. |
|
Μία ή περισσότερες πρόσθετες τιμές που εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΗ έξοδος ξεκινά από την τρέχουσα θέση του κέρσορα στην οθόνη, η οποία .
Το τυπωμένο κείμενο χρησιμοποιεί την τρέχουσα γραμματοσειρά οθόνης .
Text printed with
printis always printed with a background, and the background color is determined by the current fill color.Όταν χρησιμοποιείτε μια συμβολοσειρά μορφοποίησης, ο αριθμός και οι τύποι των τιμών που διαβιβάζονται πρέπει να ταιριάζουν με τους προσδιοριστές μορφής στη συμβολοσειρά.
// Display a message at the starting cursor
Brain.Screen.print("Hello, Robot!");

setCursor#
Moves the cursor to a specific row and column on the V5 Brain screen. The next print call will start printing at that location.
void setCursor(
int32_t row,
int32_t col );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η γραμμή στην οποία θα μετακινηθεί ο κέρσορας. |
|
|
Η στήλη στην οποία θα μετακινηθεί ο κέρσορας. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesAffects where subsequent text output begins when using
print.Οι γραμμές και οι στήλες βασίζονται στην τρέχουσα γραμματοσειρά οθόνης.
The default font (
mono20) uses 12 rows and 48 columns.Calling
setCursoraffects the position of subsequent text output only.
// Display text starting at Row 3 Column 12
Brain.Screen.setCursor(3, 12);
Brain.Screen.print("Row 3, Column 12");

newLine#
Μετακινεί τον κέρσορα στην αρχή της επόμενης γραμμής στην οθόνη Brain.
Available Functionsvoid newLine();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΑυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesIf the cursor is in the middle of a sentence,
newLinewill clear the rest of the row after the cursor before moving to the next row.After calling
newLine, the cursor is positioned at the first column of the next line.The cursor position and row numbering are set using
setCursor.
// Display two lines of text
Brain.Screen.print("Line 1");
Brain.Screen.newLine();
Brain.Screen.print("Line 2");

clearLine#
Διαγράφει κείμενο από μια σειρά στην οθόνη V5 Brain.
Available Functions1 — Διαγράφει το υπόλοιπο της τρέχουσας γραμμής από τη θέση του κέρσορα.
void clearLine();
2 — Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.
void clearLine( int number );
3 — Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void clearLine( int number, const color& color );
4 — Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void clearLine( int number, const char* color );
Parameters5 — Διαγράφει την καθορισμένη γραμμή χρησιμοποιώντας μια τιμή απόχρωσης.
void clearLine( int number, int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The row number to clear. Row numbering starts at |
|
|
Clears the row using a
|
|
|
Clears the row using a hexadecimal color value (for example, |
|
|
Clears the row using an integer hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΗ διαγραφή μιας γραμμής δεν αλλάζει την τρέχουσα θέση του κέρσορα.
The cursor position and row numbering are set using
setCursor.The
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Display text on two rows
Brain.Screen.print("This text stays");
Brain.Screen.newLine();
Brain.Screen.print("This disappears");
// Wait 3 seconds before clearing row 2
wait(3, seconds);
Brain.Screen.clearLine(2);
row#
Επιστρέφει τη γραμμή όπου θα εκτυπωθεί το κείμενο στην οθόνη V5 Brain.
Available Functionsint32_t row();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesReturns an int32_t representing the row where text will be printed.
Η αρίθμηση γραμμών ξεκινά από το 1.
NotesΗ θέση του κέρσορα βασίζεται στην τρέχουσα γραμματοσειρά οθόνης .
Η επιστρεφόμενη τιμή υποδεικνύει πού θα εμφανιστεί η επόμενη εκτυπωμένη έξοδος.
The row value changes when text is printed or when
setCursoris called.
// Display the cursor's current row
Brain.Screen.setCursor(3, 12);
Brain.Screen.print(Brain.Screen.row());

column#
Επιστρέφει τη στήλη όπου θα εκτυπωθεί το κείμενο στην οθόνη V5 Brain.
Available Functionsint32_t column();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesReturns an int32_t representing the column where text will be printed.
Η αρίθμηση στηλών ξεκινά από το 1.
NotesΗ θέση του κέρσορα βασίζεται στην τρέχουσα γραμματοσειρά οθόνης .
Η επιστρεφόμενη τιμή υποδεικνύει πού θα εμφανιστεί η επόμενη εκτυπωμένη έξοδος.
The column value changes when text is printed or when
setCursoris called.
// Display the cursor's current column
Brain.Screen.setCursor(5, 15);
Brain.Screen.print(Brain.Screen.column());

getStringHeight#
Επιστρέφει το ύψος, σε pixel, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη V5 Brain.
Available Functionsint32_t getStringHeight(
const char* cstr );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The text to be measured, provided as a C-style string (for example, |
Returns an int32_t representing the height of the string in pixels when rendered on the Brain screen.
getStringWidth#
Επιστρέφει το πλάτος, σε pixel, μιας συμβολοσειράς όταν αποδίδεται στην οθόνη V5 Brain.
Available Functionsint32_t getStringWidth(
const char* cstr );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The text to be measured, provided as a C-style string (for example, |
Returns an int32_t representing the width of the string in pixels when rendered on the Brain screen.
Το επιστρεφόμενο πλάτος εξαρτάται από την τρέχουσα επιλεγμένη γραμματοσειρά οθόνης .
Αυτή η συνάρτηση μετρά τη συμβολοσειρά χωρίς να την απεικονίζει στην οθόνη.
Το επιστρεφόμενο πλάτος αντικατοπτρίζει τον τρόπο με τον οποίο θα εμφανιζόταν η συμβολοσειρά κατά την εκτύπωση.
printAt#
Εκτυπώνει κείμενο, αριθμούς ή λογικές τιμές σε μια συγκεκριμένη συντεταγμένη στην οθόνη V5 Brain.
Available Functions1 — Εκτυπώνει τη μορφοποιημένη έξοδο στην καθορισμένη θέση pixel.
void printAt( int32_t x, int32_t y, const char* format, ... );
Parameters2 — Εκτυπώνει τη μορφοποιημένη έξοδο στην καθορισμένη θέση pixel και ορίζει εάν το φόντο κειμένου είναι αδιαφανές ή διαφανές.
void printAt( int32_t x, int32_t y, bool bOpaque, const char* format, ... );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η θέση x για εκτύπωση, με αναφορά στην αρχή της οθόνης. |
|
|
Η θέση y για εκτύπωση, με αναφορά στην αρχή της οθόνης. |
|
|
Controls whether the printed text is drawn opaquely or transparently:
|
|
|
A format string that controls what is printed on the screen (for example, |
|
Μία ή περισσότερες πρόσθετες τιμές που εισάγονται στη συμβολοσειρά μορφοποίησης, διαχωρισμένες με κόμματα. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe
xandycoordinates are relative to the current screen origin, which can be changed usingsetOrigin.Το τυπωμένο κείμενο χρησιμοποιεί την τρέχουσα γραμματοσειρά οθόνης .
Όταν χρησιμοποιείτε μια συμβολοσειρά μορφοποίησης, ο αριθμός και οι τύποι των τιμών που διαβιβάζονται πρέπει να ταιριάζουν με τους προσδιοριστές μορφής στη συμβολοσειρά.
// Print "Center" at the center of the screen
Brain.Screen.printAt(220, 120, "Center");

clearScreen#
Διαγράφει όλα τα σχέδια και το κείμενο από την οθόνη Brain και επαναφέρει τη θέση του κέρσορα στη γραμμή 1, στήλη 1.
Available Functions1 — Μαυρίζει την οθόνη.
void clearScreen();
2 — Καθαρίζει την οθόνη χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void clearScreen( const color& color );
3 — Καθαρίζει την οθόνη χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void clearScreen( const char* color );
Parameters4 — Καθαρίζει την οθόνη χρησιμοποιώντας μια τιμή απόχρωσης.
void clearScreen( int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Clears the screen using a
|
|
|
Clears the screen using a hexadecimal color value represented as a string (for example, |
|
|
Clears the screen using an integer hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Clear screen after 2 seconds
Brain.Screen.print("VEXcode");
wait(2, seconds);
Brain.Screen.clearScreen();
// Clear screen to blue after 2 seconds
Brain.Screen.print("VEXcode");
wait(2, seconds);
Brain.Screen.clearScreen(blue);

setFont#
Ορίζει τη γραμματοσειρά που χρησιμοποιείται για το κείμενο που εμφανίζεται στην οθόνη V5 Brain.
This controls the font applied to subsequent text output when using screen text functions such as print.
void setFont(
fontType font );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Sets the font to one of the following:
|
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Examples// Print larger text
Brain.Screen.setFont(mono40);
Brain.Screen.print("VEX");

// Print in Chinese
Brain.Screen.setFont(fontType::cjk16);
Brain.Screen.print("VEX机器人");

setPenWidth#
Ορίζει το πάχος των γραμμών που σχεδιάζονται και των περιγραμμάτων σχήματος.
Available Functionsvoid setPenWidth(
uint32_t width );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Το πλάτος της πένας, σε pixel, κυμαίνεται από 0 έως 32. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe pen width applies to drawing functions such as
drawLine,drawRectangle, anddrawCircle.
// Draw a rectangle with a pen width of 10
Brain.Screen.setPenWidth(10);
Brain.Screen.drawRectangle(50, 50, 130, 60);

setPenColor#
Ορίζει το χρώμα κειμένου, pixel, γραμμών και περιγραμμάτων σχήματος.
Available Functions1 — Ορίζει το χρώμα της πένας χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void setPenColor( const color& color );
2 — Ορίζει το χρώμα της πένας χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void setPenColor( const char* color );
Parameters3 — Ορίζει το χρώμα της πένας χρησιμοποιώντας μια τιμή απόχρωσης.
void setPenColor( int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Sets the pen color using a
|
|
|
Sets the pen color using a hexadecimal color value represented as a string (for example, |
|
|
Sets the pen color using an integer hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe default pen color at the start of a project is
white.The pen color is used for outlines of shapes (such as with
drawCircleordrawRectangle), text and numeric output (withprintandprintAt), and individual pixels drawn withdrawPixel.The
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Draw a rectangle with orange borders
Brain.Screen.setPenColor(orange);
Brain.Screen.drawRectangle(50, 50, 130, 60);

setFillColor#
Ορίζει το χρώμα γεμίσματος που χρησιμοποιείται κατά τη σχεδίαση σχημάτων.
Available Functions1 — Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void setFillColor( const color& color );
2 — Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void setFillColor( const char* color );
Parameters3 — Ορίζει το χρώμα γεμίσματος χρησιμοποιώντας μια τιμή απόχρωσης.
void setFillColor( int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Sets the fill color using a
|
|
|
Sets the fill color using a hexadecimal color value represented as a string (for example, |
|
|
Sets the fill color using an integer hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe default fill color at the start of a project is
black.The fill color is used for interior of shapes (such as with
drawCircleordrawRectangle).The fill color is used as the background color for printed text (such as with
printandprintAt).If
transparentis used with printed text, the background will beblack.
The
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Draw a rectangle filled with purple
Brain.Screen.setFillColor(purple);
Brain.Screen.drawRectangle(50, 100, 130, 60);

setOrigin#
Ορίζει την αρχή που χρησιμοποιείται για το σχέδιο και την εκτύπωση με βάση τις συντεταγμένες στην οθόνη Brain.
Available Functionsvoid setOrigin(
int32_t x,
int32_t y );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η θέση x της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία της οθόνης Brain από 0 έως 479. |
|
|
Η θέση y της αρχής των αξόνων σε σχέση με την επάνω αριστερή γωνία της οθόνης Brain από 0 έως 239. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΗ προεπιλεγμένη αρχή είναι η επάνω αριστερή γωνία της οθόνης στη συντεταγμένη (0, 0).
The origin applies to coordinate functions such as
drawLine,drawRectangle,drawCircle, andprintAt.Η προέλευση παραμένει σε ισχύ μέχρι να αλλάξει ξανά ή να γίνει επαναφορά του έργου.
setClipRegion#
Ορίζει μια ορθογώνια περιοχή στην οθόνη όπου θα περιορίζονται όλα τα σχέδια και το κείμενο. Δεν θα εμφανίζεται κανένα περιεχόμενο εκτός αυτής της περιοχής.
Available Functionsvoid setClipRegion(
int x,
int y,
int width,
int height );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η συντεταγμένη x της επάνω αριστερής γωνίας της περιοχής αποκοπής, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η συντεταγμένη y της επάνω αριστερής γωνίας της περιοχής αποκοπής, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
|
|
Το πλάτος της περιοχής κλιπ σε pixel, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Το ύψος της περιοχής κλιπ σε pixel, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΟι συναρτήσεις σχεδίασης εξακολουθούν να εκτελούνται ακόμη και αν βρίσκονται εκτός της περιοχής κλιπ, αλλά μόνο το τμήμα εντός της περιοχής είναι ορατό.
The
xandycoordinates are relative to the current screen origin, which can be changed usingsetOrigin.Η περιοχή αποκοπής ισχύει μόνο για το τρέχον νήμα.
Ο ορισμός μιας νέας περιοχής κλιπ αντικαθιστά οποιαδήποτε προηγουμένως ορισμένη περιοχή κλιπ για το τρέχον νήμα.
// Restrict text and drawings to a specific region
Brain.Screen.setClipRegion(0, 0, 120, 120);
Brain.Screen.drawRectangle(60, 60, 100, 100, red);
Brain.Screen.printAt(60, 60, "Cut off!");

drawPixel#
Σχεδιάζει ένα pixel στην οθόνη V5 Brain στην επιλεγμένη θέση pixel x και y.
Available Functionsvoid drawPixel(
int x,
int y );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η συντεταγμένη x όπου θα σχεδιαστεί το εικονοστοιχείο, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η συντεταγμένη y όπου θα σχεδιαστεί το εικονοστοιχείο, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 239. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesPixels are drawn using the current pen color set with
setPenColor.The
xandycoordinates are relative to the current screen origin, which can be set usingsetOrigin.Εάν η καθορισμένη θέση του pixel βρίσκεται εκτός των ορίων της οθόνης, το pixel δεν σχεδιάζεται.
// Draw the pixels marking the corners of a square
Brain.Screen.drawPixel(250, 100);
Brain.Screen.drawPixel(275, 100);
Brain.Screen.drawPixel(250, 125);
Brain.Screen.drawPixel(275, 125);
![]()
drawLine#
Σχεδιάζει μια ευθεία γραμμή που συνδέει δύο σημεία στην οθόνη V5 Brain.
Available Functionsvoid drawLine(
int x1,
int y1,
int x2,
int y2 );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η αρχική συντεταγμένη x της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η αρχική συντεταγμένη y της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
|
|
Η τελική συντεταγμένη x της γραμμής, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η τελική συντεταγμένη y της γραμμής, η οποία δίνεται ως ακέραιος αριθμός από 0 έως 239. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesLines are drawn using the current pen color set with
setPenColor.The width of the line is determined by the current pen width set with
setPenWidth.The
xandycoordinates are relative to the current screen origin, which can be set usingsetOrigin.Εάν οποιοδήποτε τμήμα της γραμμής βρίσκεται εκτός των ορίων της οθόνης, σχεδιάζεται μόνο το ορατό τμήμα.
// Draw a line from the top left to bottom right of the screen
Brain.Screen.drawLine(0, 0, 479, 239);

drawRectangle#
Σχεδιάζει ένα ορθογώνιο στην οθόνη V5 Brain στην καθορισμένη θέση και μέγεθος.
Available Functions1 — Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.
void drawRectangle( int x, int y, int width, int height );
2 — Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void drawRectangle( int x, int y, int width, int height, const color& color );
3 — Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void drawRectangle( int x, int y, int width, int height, const char* color );
Parameters4 — Σχεδιάζει και γεμίζει ένα ορθογώνιο χρησιμοποιώντας μια τιμή απόχρωσης.
void drawRectangle( int x, int y, int width, int height, int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η συντεταγμένη x της επάνω αριστερής γωνίας του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η συντεταγμένη y της επάνω αριστερής γωνίας του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
|
|
Το πλάτος του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Το ύψος του ορθογωνίου, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
|
|
Fills the rectangle using a
|
|
|
Fills the rectangle using a hexadecimal color value (for example, |
|
|
Fills the rectangle using a hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe rectangle outline is drawn using the current pen color set with
setPenColor.The outline thickness is determined by the current pen width set with
setPenWidth.When no
colorparameter is provided, the rectangle interior is filled using the current fill color set withsetFillColor.The
xandycoordinates are relative to the current screen origin, which can be changed usingsetOrigin.Εάν οποιοδήποτε τμήμα του ορθογωνίου βρίσκεται εκτός των ορίων της οθόνης, σχεδιάζεται μόνο το ορατό τμήμα.
The
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Draw a rectangle on the screen
Brain.Screen.drawRectangle(50, 50, 130, 60);

drawCircle#
Σχεδιάζει έναν κύκλο στην οθόνη V5 Brain στην καθορισμένη θέση και ακτίνα.
Available Functions1 — Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας το τρέχον διαμορφωμένο χρώμα γεμίσματος.
void drawCircle( int x, int y, int radius );
2 — Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας ένα προκαθορισμένο ή προσαρμοσμένο χρώμα αντικείμενο.
void drawCircle( int x, int y, int radius, const color& color );
3 — Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας μια δεκαεξαδική τιμή χρώματος.
void drawCircle( int x, int y, int radius, const char* color );
Parameters4 — Σχεδιάζει και γεμίζει έναν κύκλο χρησιμοποιώντας μια τιμή απόχρωσης.
void drawCircle( int x, int y, int radius, int hue );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η συντεταγμένη x του κέντρου του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 479. |
|
|
Η συντεταγμένη y του κέντρου του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 239. |
|
|
Η ακτίνα του κύκλου, που δίνεται ως ακέραιος αριθμός από 0 έως 239 pixel. |
|
|
Fills the circle using a
|
|
|
Fills the circle using a hexadecimal color value (for example, |
|
|
Fills the circle using a hue value in the range |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesThe circle outline is drawn using the current pen color set with
setPenColor.The outline thickness is determined by the current pen width set with
setPenWidth.When no
colorparameter is provided, the circle interior is filled using the current fill color set withsetFillColor.The
xandycoordinates are relative to the current screen origin, which can be changed usingsetOrigin.The
hueparameter value is based on a circular color wheel, as shown below, where values represent degrees around the wheel (for example, red near 0°, green near 120°, and blue near 240°).

// Draw a circle on the screen
Brain.Screen.drawCircle(240, 120, 40);

drawImageFromFile#
Σχεδιάζει μια εικόνα στην οθόνη V5 Brain χρησιμοποιώντας ένα αρχείο εικόνας που είναι αποθηκευμένο στην κάρτα SD.
Available Functionsbool drawImageFromFile(
const char* name,
int x,
int y );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The filename of the image on the SD card. The file must have a |
|
|
Η συντεταγμένη x, σε pixel από 0 έως 479, στην οποία θα σχεδιαστεί η αριστερή άκρη της εικόνας. |
|
|
Η συντεταγμένη y, σε pixel από 0 έως 239, στην οποία θα σχεδιαστεί το πάνω άκρο της εικόνας. |
Returns a Boolean indicating whether the image was successfully drawn:
true— The image was successfully loaded and drawn on the screen.false— The image could not be drawn (for example, if the file does not exist or is invalid).
Supported image formats are
.bmpand.png.The image file size must not exceed
512 KB.Συνιστάται η κωδικοποίηση RLE 8-bit για την ελαχιστοποίηση του μεγέθους του αρχείου.
Οι μέγιστες υποστηριζόμενες διαστάσεις εικόνας είναι το μέγεθος της οθόνης Brain (περίπου 479 x 239 pixel).
The
xandycoordinates are relative to the current screen origin, which can be changed usingsetOrigin.
// Draw a bmp file on the Brain's screen at coordinate 0, 0
Brain.Screen.drawImageFromFile("test_image.bmp", 0, 0);
render#
Enables double buffering for the Brain’s screen. Once called, any drawing functions (like text, shapes, or images) will no longer appear immediately for the rest of the project. Instead, updates will only be shown when render is used again. This allows for smoother and more controlled screen updates, but means nothing will be visible until render is used.
1 — Ενεργοποιεί τη διπλή προσωρινή αποθήκευση ή αποδίδει την προσωρινή αποθήκευση στην οθόνη.
bool render();
Parameters2 — Αποδίδει το back buffer στην οθόνη με έλεγχο της συμπεριφοράς κάθετου συγχρονισμού και προαιρετική εκτέλεση χρονοδιαγράμματος.
bool render( bool bVsyncWait, bool bRunScheduler = true );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
|
|
|
Optional.
|
Returns a Boolean indicating whether the saved drawings in the buffer were successfully rendered to the screen:
true— The drawings were successfully rendered on the screen.false— The drawings could not be rendered on the screen.
Notes
Calling
renderwill requirerenderto be used for the rest of the project.
Brain.Screen.render();
// Draw text to the back buffer
Brain.Screen.print("Render later...");
// Wait for a screen press to render drawings
while (!Brain.Screen.pressing()) {
wait(20, msec);
}
Brain.Screen.render();
pressing#
Αναφέρει εάν πατιέται η οθόνη V5 Brain αυτήν τη στιγμή.
Available Functionsbool pressing();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesReturns a Boolean indicating the current pressed state of the screen:true — The screen is currently being pressed. or false — The screen is not being pressed.
// Change the screen's color after it's pressed
while (Brain.Screen.pressing() == false) {
wait(5, msec);
}
Brain.Screen.setFillColor(green);
Brain.Screen.drawRectangle(0, 0, 479, 239);
// Display different messages after the screen is pressed
while (!Brain.Screen.pressing()) {
wait(5, msec);
}
Brain.Screen.print("First message!");
Brain.Screen.newLine();
// Lift finger to press the screen again
while (Brain.Screen.pressing()) {
wait(5, msec);
}
while (Brain.Screen.pressing() == false) {
wait(5, msec);
}
Brain.Screen.print("Second message!");
Brain.Screen.newLine();
xPosition#
Επιστρέφει τη συντεταγμένη x του τελευταίου πατήματος στην οθόνη V5 Brain.
Available Functionsint32_t xPosition();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesReturns an int32_t representing the x-coordinate, in pixels from 0 to 479, of the last screen press.
// Display a circle where the screen is pressed
while (Brain.Screen.pressing() == false) {
wait(5, msec);
}
Brain.Screen.drawCircle(Brain.Screen.xPosition(), Brain.Screen.yPosition(), 20, white);
yPosition#
Επιστρέφει τη συντεταγμένη y του τελευταίου πατήματος στην οθόνη V5 Brain.
Available Functionsint32_t yPosition();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesReturns an int32_t representing the y-coordinate, in pixels from 0 to 239, of the last screen press.
// Display a circle where the screen is pressed
while (Brain.Screen.pressing() == false) {
wait(5, msec);
}
Brain.Screen.drawCircle(Brain.Screen.xPosition(), Brain.Screen.yPosition(), 20, white);
pressed#
Καταγράφει μια συνάρτηση που θα κληθεί όταν πατηθεί η οθόνη V5 Brain.
Available Functions1 — Καλεί μια συνάρτηση όταν πατηθεί η οθόνη.
void pressed( void (*callback)(void) );
Parameters2 — Καλεί μια συνάρτηση όταν πατηθεί η οθόνη και μεταβιβάζει ένα όρισμα που ορίζεται από τον χρήστη στη συνάρτηση επανάκλησης.
void pressed( void (*callback)(void*), void* arg );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Μια συνάρτηση που καλείται όταν πατηθεί η οθόνη. |
|
|
Μια συνάρτηση που καλείται όταν πατηθεί η οθόνη και λαμβάνει ένα όρισμα που ορίζεται από τον χρήστη. |
|
|
Μια τιμή που ορίζεται από τον χρήστη και η οποία διαβιβάζεται στη συνάρτηση επανάκλησης όταν πατηθεί η οθόνη. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΗ λειτουργία επανάκλησης εκτελείται κάθε φορά που πατιέται η οθόνη Brain.
Only one callback function can be registered at a time; calling
pressedagain replaces the previous callback.The callback function must return
void.
Define the callback function (outside of
int main())// Tracks how many times the screen is pressed. void onScreenPressed(void* arg) { int* count = (int*)arg; (*count)++; Brain.Screen.clearScreen(); Brain.Screen.setCursor(1, 1); Brain.Screen.print("Pressed %d times", *count); }Register the callback inside
int main()int main() { int pressCount = 0; // Register the callback and pass a value to update. Brain.Screen.pressed(onScreenPressed, &pressCount); while (true) { wait(20, msec); } }
released#
Καταγράφει μια συνάρτηση που θα κληθεί όταν απελευθερωθεί η οθόνη V5 Brain μετά το πάτημα.
Available Functions1 — Καλεί μια συνάρτηση όταν η οθόνη απελευθερωθεί μετά το πάτημα.
void released( void (*callback)(void) );
Parameters2 — Καλεί μια συνάρτηση όταν η οθόνη απελευθερωθεί μετά το πάτημα και μεταβιβάζει ένα όρισμα που ορίζεται από τον χρήστη στη συνάρτηση επανάκλησης.
void released( void (*callback)(void*), void* arg );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Μια συνάρτηση που καλείται όταν η οθόνη απελευθερώνεται μετά το πάτημα. |
|
|
Μια συνάρτηση που καλείται όταν η οθόνη απελευθερώνεται μετά το πάτημα και λαμβάνει ένα όρισμα που ορίζεται από τον χρήστη. |
|
|
Μια τιμή που ορίζεται από τον χρήστη και η οποία διαβιβάζεται στη συνάρτηση επανάκλησης όταν η οθόνη απελευθερώνεται μετά το πάτημα. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΗ λειτουργία επανάκλησης εκτελείται κάθε φορά που απελευθερώνεται η οθόνη Brain αφού πατηθεί.
Only one callback function can be registered at a time; calling
releasedagain replaces the previous callback.The callback function must return
void.
Define the callback function (outside of
int main())// Tracks how many times the screen is released. void onScreenReleased(void* arg) { int* count = (int*)arg; (*count)++; Brain.Screen.clearScreen(); Brain.Screen.setCursor(1, 1); Brain.Screen.print("Released %d times", *count); }Register the callback inside
int main()int main() { int releaseCount = 0; // Register the callback and pass a value to update. Brain.Screen.released(onScreenReleased, &releaseCount); while (true) { wait(20, msec); } }










