مخ#

مقدمة#

توفر فئة VEX EXP Brain Sensing طرقًا للتفاعل مع أزرار الدماغ والبطارية المتصلة به.

تستخدم هذه الصفحة اسم الدماغ brain كمثال. استبدله بالاسم الذي قمت بتكوينه حسب الحاجة.

فيما يلي قائمة بجميع الطرق:

المسترجعات — استرجاع البيانات من البطارية والأزرار.

  • pressing — تُرجع ما إذا كان يتم الضغط على الزر المحدد.

  • voltage — يعيد جهد البطارية.

  • current — تُرجع قيمة سحب التيار من البطارية.

  • capacity — يعيد سعة البطارية المتبقية.

الوظائف المستدعاة - دوال مسجلة يتم استدعاؤها عند الضغط على الأزرار أو تحريرها.

  • pressed — يسجل دالة ليتم استدعاؤها عند الضغط على الزر المحدد.

  • released — يسجل دالة ليتم استدعاؤها عند تحرير الزر المحدد.

المحصلون#

pressing#

الضغط على pressing يُرجع قيمة منطقية تُشير إلى ما إذا كان زر مُحدد على الدماغ مضغوطًا حاليًا. يجب استدعاء هذه الطريقة على كائن زر مُحدد، مثل buttonCheck (انظر القائمة الكاملة لكائنات الأزرار أدناه).

  • True — يتم الضغط على الزر المحدد.

  • False — الزر المحدد غير مضغوط.

طريقة الاستخدام:
يمكن استخدام أحد عناصر الزر الثلاثة المتاحة مع هذه الطريقة، كما هو موضح أدناه:

زر

يأمر

buttonCheck

brain.buttonCheck.pressing() — زر التحقق

buttonLeft

brain.buttonLeft.pressing() — الزر الأيسر

buttonRight

brain.buttonRight.pressing() — الزر الأيمن

حدود

وصف

لا تحتوي هذه الطريقة على أي معلمات.

# Turn when the check button is pressed
while True:
    if brain.buttonCheck.pressing():
        drivetrain.turn(RIGHT)
    else:
        drivetrain.stop()

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)

حدود

وصف

units

اختياري. وحدة قياس الجهد: MV (افتراضي) — ملي فولت، أو VOLT

# 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())

capacity#

capacity يعيد مستوى البطارية المتبقي، كنسبة مئوية من 0% إلى 100%.

Usage:
brain.battery.capacity()

حدود

وصف

لا تحتوي هذه الطريقة على أي معلمات.

# Display the current battery capacity
brain.screen.print(brain.battery.capacity())

معاودة الاتصال#

pressed#

يُسجّل الأمر pressed يتم استدعاؤها عند الضغط على زر مُحدد في وحدة التحكم. يجب استدعاء هذه الدالة على كائن زر مُحدد، مثل buttonCheck — (انظر القائمة الكاملة لكائنات الأزرار أدناه).

طريقة الاستخدام:
يمكن استخدام أحد عناصر الزر الثلاثة المتاحة مع هذه الطريقة، كما هو موضح أدناه:

زر

يأمر

buttonCheck

brain.buttonCheck.pressed(callback, arg) — زر التحقق

buttonLeft

brain.buttonLeft.pressed(callback, arg) — الزر الأيسر

buttonRight

brain.buttonRight.pressed(callback, arg) — الزر الأيمن

حدود

وصف

callback

A function that is previously defined to execute when the specified button is being pressed.

arg

Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information.

# 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 يتم استدعاؤها عند تحرير زر معين في الدماغ. يجب استدعاء هذه الدالة على كائن زر معين، مثل buttonCheck — (انظر القائمة الكاملة لكائنات الأزرار أدناه).

طريقة الاستخدام:
يمكن استخدام أحد عناصر الزر الثلاثة المتاحة مع هذه الطريقة، كما هو موضح أدناه:

زر

يأمر

buttonCheck

brain.buttonCheck.released(callback, arg) — زر التحقق

buttonLeft

brain.buttonLeft.released(callback, arg) — الزر الأيسر

buttonRight

brain.buttonRight.released(callback, arg) — الزر الأيمن

حدود

وصف

callback

A function that is previously defined to execute when the specified button is released.

arg

Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information.

# Turn in a circle when the left button
# is released
def button_released():
    drivetrain.turn_for(LEFT, 360, DEGREES)

brain.buttonLeft.released(button_released)