Μετρών την ώραν#
Εισαγωγή#
Ο Χρονοδιακόπτης στο VEX CTE σάς επιτρέπει να παρακολουθείτε τον χρόνο που έχει παρέλθει και να εκτελείτε ενέργειες με βάση χρονικά διαστήματα. Μπορεί να χρησιμοποιηθεί για να μετρήσετε πόσο χρόνο χρειάζεται κάτι ή να το επαναφέρετε για νέες λειτουργίες χρονισμού.
Note: The Timer is only available when a Brain has been constructed with brain = Brain(), as all Timer functionality is driven through methods on the Brain instance.
This page uses brain as the example Brain name. Replace it with your own configured name as needed.
Παρακάτω είναι μια λίστα με όλες τις μεθόδους:
timer_reset– Resets the timer to zero.timer_time– Returns the elapsed time since the project started.timer_event– Calls a function after a specified number of milliseconds, with optional arguments.
χρονοδιακόπτης_επαναφορά#
timer_reset sets the timer to zero. This can be used to time additional sections of code within the same project.
Usage:
brain.timer_reset()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the time until the move is completed
arm.move_to(-100, 200, 100, False)
while True:
print("\033[2J")
print(brain.timer_time(SECONDS))
wait(50, MSEC)
if arm.is_done():
brain.timer_reset()
χρονόμετρο_ώρας#
timer_time returns the current elapsed time of the timer in the specified units — an integer for MSEC or a float for SECONDS.
Usage:
brain.timer_time(units)
Παράμετροι |
Περιγραφή |
|---|---|
|
Optional. The unit to represent the time:
|
# Display the time until the move is completed
arm.move_to(-100, 200, 100, False)
while True:
print("\033[2J")
print(brain.timer_time(SECONDS))
wait(50, MSEC)
if arm.is_done():
brain.timer_reset()
χρονόμετρο_συμβάντος#
timer_event calls a function after a specified amount of time passes.
Usage:
timer_event(callback, delay, arg)
Παράμετροι |
Περιγραφή |
|---|---|
|
Μια συνάρτηση που θα εκτελεστεί όταν συμβεί το συμβάν χρονοδιακόπτη. |
|
Η καθυστέρηση πριν από την κλήση της συνάρτησης, σε χιλιοστά του δευτερολέπτου. |
|
Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να μεταβιβαστούν στη συνάρτηση επανάκλησης. Δείτε Χρήση Συναρτήσεων με Παραμέτρους για περισσότερες πληροφορίες. |
def move_arm():
arm.move_inc(0, 100, 0)
# Move the arm after a 5000 millisecond delay
timer_event(move_arm, 5000)