Εγκέφαλος#
Εισαγωγή#
Η κατηγορία ανίχνευσης εγκεφάλου VEX IQ (2ης γενιάς) προσφέρει μεθόδους αλληλεπίδρασης με τα κουμπιά του εγκεφάλου και τη συνδεδεμένη μπαταρία.
This page uses brain as the example Brain name. Replace it with your own configured name as needed.
Παρακάτω είναι μια λίστα με όλες τις μεθόδους:
Ενέργειες — Αλληλεπίδραση με τα κουμπιά VEX IQ (2ης γενιάς).
pressed— Registers a function to be called when the specified button is pressed.released— Registers a function to be called when the specified button is released.
Λήπτες — Επιστρέφουν δεδομένα από τα κουμπιά και την μπαταρία.
pressing— Returns whether the specified button is being pressed.capacity— Returns the brain’s remaining battery capacity.voltage— Returns the battery voltage.current— Returns the battery current draw.
Κατασκευαστές — Χειροκίνητη αρχικοποίηση του εγκεφάλου.
brain— Create a brain.
Ενέργειες#
pressed#
pressed registers a function to be called when a specific button on the Brain is pressed. This method must be called on a specific button object, such as buttonCheck — (see full list of button objects below).
Χρήση:
Ένα από τα τρία διαθέσιμα αντικείμενα κουμπιών μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:
Κουμπί |
Εντολή |
|---|---|
|
|
|
|
|
|
Παράμετροι |
Περιγραφή |
|---|---|
|
Μια συνάρτηση που έχει οριστεί εκ των προτέρων για εκτέλεση όταν πατιέται το καθορισμένο κουμπί. |
|
Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να περάσουν στη συνάρτηση επανάκλησης. Δείτε Συναρτήσεις με Παραμέτρους για περισσότερες πληροφορίες. |
# Turn in a circle when the left button
# is pressed
def button_pressed():
drivetrain.turn_for(RIGHT, 360, DEGREES)
brain.buttonLeft.pressed(button_pressed)
released#
released registers a function to be called when a specific button on the Brain is released. This method must be called on a specific button object, such as buttonCheck — (see full list of button objects below).
Χρήση:
Ένα από τα τρία διαθέσιμα αντικείμενα κουμπιών μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:
Κουμπί |
Εντολή |
|---|---|
|
|
|
|
|
|
Παράμετροι |
Περιγραφή |
|---|---|
|
Μια συνάρτηση που έχει οριστεί προηγουμένως για εκτέλεση όταν απελευθερωθεί το καθορισμένο κουμπί. |
|
Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να περάσουν στη συνάρτηση επανάκλησης. Δείτε Συναρτήσεις με Παραμέτρους για περισσότερες πληροφορίες. |
# Turn in a circle when the left button
# is released
def button_released():
drivetrain.turn_for(LEFT, 360, DEGREES)
brain.buttonLeft.released(button_released)
Αποκτητές#
pressing#
pressing returns a Boolean indicating whether a specific button on the Brain is currently being pressed. This method must be called on a specific button object, such as buttonCheck (see full list of button objects below).
True— The specified button is being pressed.False— The specified button is not being pressed.
Χρήση:
Ένα από τα τρία διαθέσιμα αντικείμενα κουμπιών μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:
Κουμπί |
Εντολή |
|---|---|
|
|
|
|
|
|
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()
capacity#
capacity returns the remaining battery level, as a percentage from 0% to 100%.
Usage:
brain.battery.capacity()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the current battery capacity
brain.screen.print(brain.battery.capacity())
voltage#
Voltage is the electrical pressure supplied to the battery. voltage returns the voltage of the battery as a decimal (float), which can help you check whether the battery is charged enough for the robot to run reliably, ranging from 7.0 to 8.0 Volts.
Usage:
brain.battery.voltage(units)
Παράμετροι |
Περιγραφή |
|---|---|
|
Optional. The unit that represents the voltage: |
# Display the current voltage of the battery
brain.screen.print(brain.battery.voltage())
current#
Current is how much electrical flow the robot is using from the battery. current returns the current drawn from the battery in amps as a decimal (float), which can help you see how hard the robot is working or whether motors may be under extra load, ranging from 0.0 to 15.0 Amps.
Usage:
brain.battery.current()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the current of the battery
brain.screen.print(brain.battery.current())
Κατασκευαστές#
Brain#
Brain creates an object of the brain class.
Usage:
brain = Brain()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
brain = Brain()
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()