شاشة#
مقدمة#
تتحكم طرق الشاشة في كيفية عرض وحدة التحكم في طائرة VEX AIR بدون طيار للنصوص والأرقام والرسومات والصور على شاشتها، وكيفية استجابتها لضغطات الشاشة.
فيما يلي قائمة بالطرق المتاحة:
طباعة المؤشر – عرض النص وإدارة مؤشر الطباعة.
print– يطبع النص أو الأرقام أو قيم المتغيرات في موضع المؤشر الحالي.set_cursor– ينقل المؤشر إلى صف وعمود محددين.next_row– ينقل المؤشر إلى العمود 1 من الصف التالي.clear_row– يمسح صفًا من النص.get_row– تُرجع الصف الذي سيتم فيه طباعة النص.get_column– تُرجع العمود الذي سيتم طباعة النص فيه.
طباعة XY - طباعة النص بإحداثيات تعتمد على البكسل.
print_at– يطبع النص أو الأرقام أو قيم المتغيرات عند إحداثيات x و y محددة.set_origin– يحدد الأصل المستخدم للطباعة والرسم القائم على الإحداثيات.
المُعدِّلات – تغيير إعدادات الشاشة والألوان وسلوك الرسم.
clear_screen– يمسح جميع الرسومات والنصوص والصور من شاشة التحكم.wait_for_render– يقوم بتبديل رسم الشاشة إلى سلوك العرض لاحقًا.set_font– يحدد الخط للنص المطبوع.set_pen_width– يحدد سمك الخطوط المرسومة ومخططات الأشكال.set_pen_color– يحدد لون النص والبكسلات والخطوط ومخططات الأشكال.set_text_fill_color– يحدد لون التعبئة خلف النص المطبوع.set_fill_color– يحدد لون التعبئة للأشكال المرسومة.
الرسم – أضف الرسومات والصور إلى الشاشة.
draw_pixel– يرسم بكسل واحد في موضع محدد x و y.draw_line– يرسم خطًا بين نقطتين.draw_rectangle– يرسم مستطيلاً باستخدام القلم الحالي وألوان التعبئة.draw_circle– يرسم دائرة باستخدام القلم الحالي وألوان التعبئة.show_file– يرسم صورة تم تحميلها.
اللمس – اكتشاف ضغطات الشاشة والاستجابة لها.
pressing– تُرجع ما إذا كانت الشاشة قيد الضغط حاليًا.x_position– تُرجع إحداثيات x لآخر ضغطة على الشاشة.y_position– تُرجع إحداثيات y لآخر ضغطة على الشاشة.
الوظائف المستدعاة – تشغيل الوظائف عند الضغط على الشاشة أو تحريرها.
بصمة المؤشر#
print#
print prints text, numbers, or variable values on the controller screen at the current cursor position and font.
Usage:
controller.screen.print(text)
حدود |
وصف |
|---|---|
|
النص أو الرقم أو قيمة المتغير المراد طباعتها على الشاشة. |
|
اختياري. الفاصل بين النص المطبوع. افتراضيًا، |
|
اختياري. السلسلة النصية التي تُضاف بعد آخر نص مطبوع. افتراضيًا، |
|
اختياري. عدد المنازل العشرية التي سيُطبع بها العدد العشري كعدد صحيح. افتراضيًا، الدقة |
# Display a message at the starting cursor position.
controller.screen.print("Time to fly!")

# Display the first 2 decimals of pi
controller.screen.print(3.1415, precision = 2)

set_cursor#
set_cursor moves the cursor to a specific row and column on the controller screen. The next print call will start printing at that location. The row and column spacing will take into account the selected font. With the default monospaced medium font, the screen can clearly display up to 18 rows and 53 columns. Text placed beyond this range may be cut off or harder to read.
Usage:
controller.screen.set_cursor(row, col)
حدود |
وصف |
|---|---|
|
الصف الذي سيتم تحريك المؤشر إليه. |
|
العمود الذي سيتم تحريك المؤشر إليه. |
# Display text starting at Row 7 Column 25.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print("Row 7, Column 25")

next_row#
next_row ينقل المؤشر إلى العمود 1 في الصف التالي على شاشة التحكم.
Usage:
controller.screen.next_row()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Display two lines of text.
controller.screen.print("Line 1")
controller.screen.next_row()
controller.screen.print("Line 2")

clear_row#
clear_row يمسح صفًا من النص على شاشة التحكم.
Usage:
controller.screen.clear_row(row, color)
المعلمة |
وصف |
|---|---|
|
اختياري. الصف المراد مسحه. القيمة الافتراضية هي صف المؤشر الحالي. |
|
Optional. The color to apply to the cleared row. If a color is not specified, the
|
# Clear only the second row of text
controller.screen.print("This text stays")
controller.screen.next_row()
controller.screen.print("This text disappears")
wait(3, SECONDS)
controller.screen.clear_row(2)
# Turn the 5th row green.
controller.screen.clear_row(5, GREEN)
get_row#
get_row تُرجع الصف الحالي الذي سيتم طباعة النص فيه، كعدد صحيح.
Usage:
controller.screen.get_row()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Display the cursor's current row.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_row())

get_column#
get_column تُرجع العمود الحالي الذي سيتم طباعة النص فيه، كعدد صحيح.
Usage:
controller.screen.get_column()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Display the cursor's current column.
controller.screen.set_cursor(row=7, col=25)
controller.screen.print(controller.screen.get_column())

طباعة XY#
print_at#
print_at prints text, numbers, or variable values on the controller screen at a specific (x, y) position in pixels, using the current font and origin. x sets how far from the left side the text begins, and y sets where the bottom of the letters sit. This method disregards the current cursor position.
Usage:
controller.screen.print_at(text, x, y)
المعلمة |
وصف |
|---|---|
|
النص أو الرقم أو قيمة المتغير المراد طباعتها على الشاشة. |
|
الموضع الأفقي للنص، كرقم صحيح من 0 إلى 640 بكسل. 0 لليسار؛ 640 لليمين. |
|
الموضع الرأسي للنص، كرقم صحيح من 0 إلى 480 بكسل. 0 هو الأعلى؛ 480 هو الأسفل. |
# Display a message in the middle of the screen.
controller.screen.print_at("Hello, drone!", x=320, y=240)

set_origin#
يُستخدم set_origin لتعيين نقطة الأصل (0, 0) المستخدمة للرسم والطباعة الإحداثية على شاشة وحدة التحكم. تكون نقطة الأصل افتراضيًا في الزاوية العلوية اليسرى من الشاشة. يمكن لهذه الطريقة إعادة تعيين نقطة الأصل إلى موقع إحداثيات بديل (x, y) على الشاشة.
Usage:
controller.screen.set_origin(x, y)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني الجديد الذي سيتم تعيينه كنقطة أصل، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي y الجديد الذي سيتم تعيينه كنقطة أصل، معطاة كعدد صحيح من 0 إلى 480. |
# Set the origin to the center of the screen.
controller.screen.set_origin(x=320, y=240)
# Draw a rectangle at the new origin.
controller.screen.draw_rectangle(x=0, y=0, width=80, height=40)

المتحولون#
clear_screen#
clear_screen يمسح جميع الرسومات والنصوص والصور من شاشة التحكم.
Usage:
controller.screen.clear_screen(row, col, color)
المعلمة |
وصف |
|---|---|
|
اختياري. الصف الذي سينتقل إليه المؤشر بعد مسح الشاشة. القيمة الافتراضية هي 1. |
|
اختياري. العمود الذي سينتقل إليه المؤشر بعد مسح الشاشة. القيمة الافتراضية هي 1. |
|
Optional. Sets the screen color. If
|
# Draw a circle, and clear it after 2 seconds.
controller.screen.draw_circle(x=320, y=240, radius=80)
wait(2, SECONDS)
controller.screen.clear_screen()
# Print two messages in the same spot
controller.screen.print("Hello!")
wait(3,SECONDS)
controller.screen.clear_screen(row=1, col=1)
controller.screen.print("Goodbye!")
# Set the background color of the screen to red.
controller.screen.clear_screen(color=RED)
wait_for_render#
يؤدي wait_for_render إلى تغيير سلوك عرض الشاشة إلى وضع العرض اللاحق. بمجرد تشغيل هذا الأمر، لن تظهر أوامر الشاشة التالية على شاشة التحكم حتى يتم تشغيل الأمر wait_for_render .
ملاحظة: استخدم هذا قبل رسم مجموعة من النصوص أو الأشكال أو الصور، ثم استخدمه مرة أخرى لعرض التحديث الكامل دفعة واحدة.
Usage:
controller.screen.wait_for_render()
المعلمة |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Display text and images when button 7 is pressed.
controller.screen.wait_for_render()
controller.screen.print("Screen rendered!")
controller.screen.draw_circle(x=320, y=240, radius=80)
while not controller.button7.pressing():
wait(5, MSEC)
controller.screen.wait_for_render()

set_font#
يُحدد set_font الخط المستخدم لعرض النصوص على شاشة التحكم. سيتم تطبيق هذا الخط على جميع النصوص المطبوعة بعد تشغيل هذه الدالة. الخط الافتراضي عند بدء المشروع هو MONO20.
Usage:
controller.screen.set_font(fontname)
المعلمة |
وصف |
|---|---|
|
Sets the font to one of the following:
|
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
# Display text using a larger font.
controller.screen.set_font(MONO40)
controller.screen.print("VEX")

set_pen_width#
set_pen_width يحدد سمك الخطوط المرسومة ومخططات الأشكال.
Usage:
controller.screen.set_pen_width(width)
المعلمة |
وصف |
|---|---|
|
عرض القلم، معبراً عنه كعدد صحيح بالبكسل. |
# Draw a rectangle with a pen width of 10.
controller.screen.set_pen_width(10)
controller.screen.draw_rectangle(x=200, y=200, width=200, height=80)

set_pen_color#
set_pen_color يحدد لون النص والبكسلات والخطوط ومخططات الأشكال.
Usage:
controller.screen.set_pen_color(color)
المعلمة |
وصف |
|---|---|
|
Optional. Sets the pen and font color. Options include:
|
# Draw a rectangle with an orange outline.
controller.screen.set_pen_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=240, height=150)
controller.screen.set_pen_color(WHITE)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

set_text_fill_color#
يُحدد الخيار set_text_fill_color لون تعبئة النص المطبوع. لون تعبئة النص الافتراضي شفاف.
Usage:
controller.screen.set_text_fill_color(color)
المعلمة |
وصف |
|---|---|
|
Optional. Sets the text fill color. Options include:
|
# Display two colors behind text
controller.screen.set_text_fill_color(RED)
controller.screen.print("Red")
controller.screen.next_row()
controller.screen.set_text_fill_color(BLUE)
controller.screen.print("Blue")

set_fill_color#
يُحدد الخيار set_fill_color لون التعبئة المستخدم عند رسم الأشكال. لون التعبئة الافتراضي هو الأسود.
Usage:
controller.screen.set_fill_color(color)
المعلمة |
وصف |
|---|---|
|
Optional. Sets the fill color. Options include:
|
# Draw an orange-filled rectangle with text on top
controller.screen.set_fill_color(ORANGE)
controller.screen.draw_rectangle(x=200, y=150, width=250, height=150)
controller.screen.print_at("VEXcode AIR", x=250, y=220)

يرسم#
draw_pixel#
draw_pixel draws one pixel at the selected x and y coordinate using the current pen color.
Usage:
controller.screen.draw_pixel(x, y)
المعلمة |
وصف |
|---|---|
|
إحداثي س حيث سيتم رسم البكسل، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي y حيث سيتم رسم البكسل، معطاة كعدد صحيح من 0 إلى 480. |
# Draw five pixels in a diagonal.
controller.screen.draw_pixel(x=360, y=200)
controller.screen.draw_pixel(x=340, y=220)
controller.screen.draw_pixel(x=320, y=240)
controller.screen.draw_pixel(x=300, y=260)
controller.screen.draw_pixel(x=280, y=280)
![]()
draw_line#
draw_line يرسم خطًا من إحداثيات الشاشة الأولى (x1, y1) إلى إحداثيات الشاشة الثانية (x2, y2) باستخدام عرض القلم ولون القلم.
تستخدم إحداثيات x و y الأصل الافتراضي (0، 0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
controller.screen.draw_line(x1, y1, x2, y2)
المعلمة |
وصف |
|---|---|
|
إحداثي البداية للخط على المحور السيني، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي y الابتدائي للخط، معطاة كعدد صحيح من 0 إلى 480. |
|
إحداثي س النهائي للخط، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي الصادات النهائي للخط، معطاة كعدد صحيح من 0 إلى 480. |
# Make an X across the screen.
controller.screen.draw_line(x1=0, y1=0, x2=640, y2=480)
controller.screen.set_pen_color(CYAN)
controller.screen.draw_line(x1=0, y1=480, x2=640, y2=0)

draw_rectangle#
draw_rectangle يرسم مستطيلاً باستخدام عرض القلم، لون القلم، ولون التعبئة، ما لم يتم استخدام المعلمة الاختيارية color.
تستخدم إحداثيات x و y الأصل الافتراضي (0، 0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
controller.screen.draw_rectangle(x, y, width, height, color)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني للزاوية العلوية اليسرى للمستطيل، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي y للزاوية العلوية اليسرى للمستطيل، معطاة كعدد صحيح من 0 إلى 480. |
|
عرض المستطيل، معبر عنه كعدد صحيح من 0 إلى 640. |
|
ارتفاع المستطيل، معبر عنه كعدد صحيح من 0 إلى 480. |
|
Optional. Sets the fill color of the rectangle. Options include:
|
# Draw two rectangles on the screen.
controller.screen.draw_rectangle(x=0, y=0, width=620, height=460)
controller.screen.draw_rectangle(x=200, y=180, width=200, height=100, color=GREEN)

draw_circle#
draw_circle يرسم دائرة باستخدام عرض القلم، لون القلم، ولون التعبئة، ما لم يتم استخدام المعلمة الاختيارية color.
تستخدم إحداثيات x و y الأصل الافتراضي (0، 0) ما لم يتم تعيين أصل مختلف باستخدام set_origin.
Usage:
controller.screen.draw_circle(x, y, radius, color)
المعلمة |
وصف |
|---|---|
|
الإحداثي السيني لمركز الدائرة، معطاة كعدد صحيح من 0 إلى 640. |
|
إحداثي y لمركز الدائرة، معطاة كعدد صحيح من 0 إلى 480. |
|
نصف قطر الدائرة، معطاة كعدد صحيح من 0 إلى 480 بكسل. |
|
Optional. Sets the fill color of the circle. Options include:
|
# Draw one green circle on the screen.
controller.screen.set_fill_color(GREEN)
controller.screen.draw_circle(x=320, y=240, radius=200, color=GREEN)

show_file#
show_file يرسم صورة مخصصة تم تحميلها على شاشة التحكم في موضع x و y، مع إمكانية تغيير الحجم والتدوير وشفافية ألفا.
Usage:
controller.screen.show_file(file, x, y, scale_width, scale_height, rotation, use_alpha)
المعلمة |
وصف |
|---|---|
|
الصورة التي قام المستخدم بتحميلها لاستخدامها. ستتغير الخيارات إذا تم تعديل أسماء الصور في لوحة التحكم. |
|
الإزاحة الأفقية للصورة، معطاة كعدد صحيح بالبكسل. القيم الموجبة تحركها إلى اليمين؛ والقيم السالبة تحركها إلى اليسار. |
|
الإزاحة الرأسية للصورة، معطاة كعدد صحيح بالبكسل. القيم الموجبة تحركها للأسفل؛ والقيم السالبة تحركها للأعلى. |
|
اختياري. عرض الصورة الذي يتم تغيير حجمها إليه، ويُعطى كعدد صحيح بالبكسل. |
|
اختياري. ارتفاع الصورة المراد تغيير حجمها، ويُعطى كعدد صحيح بالبكسل. |
|
اختياري. عدد الدرجات لتدوير الصورة، معطاة كعدد صحيح من 0 إلى 359. |
|
اختياري. ما إذا كان سيتم استخدام قناة ألفا للصورة للشفافية. الخيارات المتاحة: |
# Display uploaded Image 1 in the top left corner.
controller.screen.show_file(IMAGE1, x=0, y=0)
# Display uploaded Image 1 scaled to the full screen.
controller.screen.show_file(IMAGE1, x=65, y=0, scale_width=640, scale_height=480)
# Display uploaded Image 1 with rotation of 180 degrees.
controller.screen.show_file(IMAGE1, x=-65, y=0, rotation=180)
# Upload an image with a transparent background.
# Display uploaded Image 1 with alpha channel enabled.
controller.screen.show_file(IMAGE1, x=0, y=0, use_alpha=True)
يلمس#
pressing#
الضغط على pressing يُرجع قيمة منطقية تشير إلى ما إذا كانت شاشة الروبوت قيد الضغط حاليًا.
True– يتم الضغط على الشاشة.False– لا يتم الضغط على الشاشة.
Usage:
controller.screen.pressing()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Play a sound when the screen is pressed.
while True:
if controller.screen.pressing():
controller.sound.play_note("C5", 500)
wait(5, MSEC)
# Display different messages after the screen is pressed
while not controller.screen.pressing():
wait(5, MSEC)
controller.screen.print("First message!")
controller.screen.next_row()
# Lift finger to press the screen again
while controller.screen.pressing():
wait(5, MSEC)
while not controller.screen.pressing():
wait(5, MSEC)
controller.screen.print("Second message!")
controller.screen.next_row()
x_position#
x_position تُرجع إحداثيات x بالبكسل حيث تم الضغط على الشاشة آخر مرة، كعدد صحيح من 0 (يسار) إلى 640 (يمين).

Usage:
controller.screen.x_position()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Play a high or low note based on where screen is pressed.
while True:
if controller.screen.pressing():
if controller.screen.x_position() > 320:
controller.sound.play_note("C6", 500)
else:
controller.sound.play_note("C4", 500)
wait(5, MSEC)
y_position#
y_position تُرجع إحداثيات y بالبكسل حيث تم الضغط على الشاشة آخر مرة، كعدد صحيح من 0 (أعلى) إلى 480 (أسفل).

Usage:
controller.screen.y_position()
# Play a high or low note based on where screen is pressed.
while True:
if controller.screen.pressing():
if controller.screen.y_position() > 240:
controller.sound.play_note("C6", 500)
else:
controller.sound.play_note("C4", 500)
wait(5, MSEC)
معاودة الاتصال#
pressed#
pressed registers a function to be called when the controller screen is pressed.
Usage:
controller.screen.pressed(callback, arg)
حدود |
وصف |
|---|---|
|
A function that is previously defined to execute when the controller screen is pressed. |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Play a sound when the screen is pressed.
def play_sound():
controller.sound.play_note("C5", 500)
controller.screen.pressed(play_sound)
released#
released يسجل دالة ليتم استدعاؤها عند تحرير شاشة وحدة التحكم.
Usage:
controller.screen.released(callback, arg)
حدود |
وصف |
|---|---|
|
A function that is previously defined to execute when the controller screen is released. |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
# Play a sound when the screen is pressed.
def play_sound():
controller.sound.play_note("C5", 500)
controller.screen.released(play_sound)













