LED αφής#

Εισαγωγή#

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

This page uses touchled_1 as the example Touch LED name. Replace it with your own configured name as needed.

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

Ενέργειες — Αλληλεπίδραση με την λυχνία αφής LED.

  • pressed — Registers a function to be called when the Touch LED is pressed.

  • released — Registers a function to be called when the Touch LED is released.

  • on — Turns the Touch LED on.

  • off — Turns the Touch LED off.

  • toggle — Turns the Touch LED on or off.

Μεταλλαγές — Αλλάξτε τα χρώματα, τη φωτεινότητα και τις ρυθμίσεις της λυχνίας αφής LED.

  • set_color — Sets the color of the Touch LED.

  • set_fade — Sets how fast colors will fade into one another.

  • set_brightness — Sets the brightness of the Touch LED.

  • set_blink — Alternate the Touch LED on and off indefinitely.

Λήψη δεδομένων — Επιστροφή δεδομένων από την οθόνη αφής LED.

  • pressing — Returns whether the Touch LED is being pressed.

  • installed — Returns whether the Touch LED is connected to the Brain.

Κατασκευαστές — Μη αυτόματη αρχικοποίηση και διαμόρφωση της λυχνίας αφής LED.

Ενέργειες#

pressed#

pressed registers a function to be called when the Touch LED is pressed.

Usage:
touchled_1.pressed(callback, arg)

Παράμετροι

Περιγραφή

callback

Μια συνάρτηση που έχει οριστεί προηγουμένως για εκτέλεση όταν πατιέται η λυχνία LED αφής.

arg

Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να μεταβιβαστούν στη συνάρτηση επανάκλησης. Δείτε Συναρτήσεις με Παραμέτρους για περισσότερες πληροφορίες.

# Turn blue while the Touch LED is pressed
def light_blue():
    touchled_1.set_color(Color.BLUE)

touchled_1.pressed(light_blue)

released#

released registers a function to be called when the Touch LED is released.

Usage:
touchled_1.released(callback, arg)

Παράμετροι

Περιγραφή

callback

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

arg

Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να μεταβιβαστούν στη συνάρτηση επανάκλησης. Δείτε Συναρτήσεις με Παραμέτρους για περισσότερες πληροφορίες.

# Turn red when the Touch LED is released
def light_red():
    touchled_1.set_color(Color.RED)

touchled_1.released(light_red)

on#

on turns the Touch LED on by setting its brightness to 100%.

Usage:
touchled_1.on(value)

Παράμετροι

Περιγραφή

value

Optional. Sets the LED’s color to:

  • Color.RED
  • Color.GREEN
  • Color.BLUE
  • Color.WHITE (default)
  • Color.YELLOW
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.BLUE_VIOLET
  • Color.BLUE_GREEN
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
  • Color.RED_ORANGE
You can also specify a custom color.

# Turn green when the robot is moving
touchled_1.on(Color.GREEN)
drivetrain.drive_for(FORWARD, 5)
touchled_1.off()

off#

off turns the Touch LED off by setting its brightness to 0%.

Usage:
touchled_1.off()

Παράμετροι

Περιγραφή

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

# Turn off Touch LED when movement is over
touchled_1.on(Color.GREEN)
drivetrain.drive_for(FORWARD, 5)
touchled_1.off()

toggle#

toggle turns the Touch LED on or off. If the LED is currently on, toggle sets its brightness to 0%, turning it off. If the LED is off, toggle sets its brightness to 100%, turning it on.

Usage:
touchled_1.toggle()

Παράμετροι

Περιγραφή

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

# Turn the Touch LED off and on
touchled_1.set_color(Color.RED)
while True:
    touchled_1.toggle()
    wait(0.5,SECONDS)

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

set_color#

set_color sets the color of the Touch LED. If the Touch LED is not already on when this method is used, it will set the brightness to 100% to turn the Touch LED on.

Usage:
touchled_1.set_color(color)

Παράμετροι

Περιγραφή

color

Optional. Sets the LED’s color to:

  • Color.RED
  • Color.GREEN
  • Color.BLUE
  • Color.WHITE (default)
  • Color.YELLOW
  • Color.ORANGE
  • Color.PURPLE
  • Color.RED_VIOLET
  • Color.VIOLET
  • Color.BLUE_VIOLET
  • Color.BLUE_GREEN
  • Color.YELLOW_GREEN
  • Color.YELLOW_ORANGE
  • Color.RED_ORANGE
If unspecified, set_color will turn the Touch LED on with the previously set color.
You can also specify a custom color.

# Change colors between blue and green
while True:
    touchled_1.set_color(Color.BLUE)
    wait(0.5, SECONDS)
    touchled_1.set_color(Color.GREEN)
    wait(0.5, SECONDS)

set_fade#

set_fade changes how the Touch LED transitions to new colors.

Usage:
touchled_1.set_fade(type)

Παράμετροι

Περιγραφή

type

How fast a color will fade from one to the next:

  • FadeType.FAST — Colors will transition quickly.
  • FadeType.OFF — Colors will instantly transition.
  • FadeType.SLOW — Colors will transition slowly.

# No fade to red, then slow fade to purple
touchled_1.set_fade(FadeType.OFF)
touchled_1.set_color(Color.RED)
wait(2, SECONDS)
touchled_1.set_fade(FadeType.SLOW)
touchled_1.set_color(Color.PURPLE)

set_brightness#

set_brightness sets the brightness of the Touch LED.

Usage:
touchled_1.set_brightness(brightness)

Παράμετροι

Περιγραφή

brightness

Η φωτεινότητα της λυχνίας LED αφής πρέπει να οριστεί ως ακέραιος αριθμός από 0% έως 100%.

# Show green at different brightness levels
touchled_1.set_color(Color.GREEN)
wait(1, SECONDS)
touchled_1.set_brightness(10)
wait(1, SECONDS)
touchled_1.set_brightness(100)

Αποκτητές#

pressing#

pressing returns an integer indicating whether the Touch LED is currently being pressed.

  • 1 — The TouchLED is being pressed.

  • 0 — The TouchLED is not being pressed.

Usage:
touchled_1.pressing()

Παράμετροι

Περιγραφή

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

# Turn TouchLED green when touched
while True:
    if touchled_1.pressing():
        touchled_1.set_color(Color.GREEN)
    else:
        touchled_1.set_color(Color.RED)
    wait(50, MSEC)

installed#

installed returns a Boolean indicating whether the Touch LED is connected to the Brain.

  • True — The Touch LED is connected to the Brain.

  • False — The Touch LED is not connected to the Brain.

Usage:
touchled_1.installed()

Παράμετροι

Περιγραφή

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

Κατασκευαστές#

Constructors are used to manually create Touchled objects, which are necessary for configuring a Touch LED outside of VEXcode.

Touchled#

Touchled creates a Touch LED.

Usage:
touchled_1 = Touchled(smartport)

Παράμετρος

Περιγραφή

smartport

Η Έξυπνη Θύρα στην οποία είναι συνδεδεμένη η λυχνία αφής LED, γράφεται ως PORTx όπου x είναι ο αριθμός της θύρας.

# Create a Touchled in Port 1
touchled_1 = Touchled(Ports.PORT1)