from machine import Pin, I2C
import ssd1306
import time
# OLED
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
def box(x, y, w, h, color=1):
# يرسم إطار مستطيل باستخدام pixel فقط
for i in range(x, x + w):
oled.pixel(i, y, color)
oled.pixel(i, y + h - 1, color)
for j in range(y, y + h):
oled.pixel(x, j, color)
oled.pixel(x + w - 1, j, color)
def fill_box(x, y, w, h, color=1):
# يملأ مستطيل باستخدام pixel فقط (أبطأ بس مضمون)
for j in range(y, y + h):
for i in range(x, x + w):
oled.pixel(i, j, color)
def draw_face():
oled.fill(0)
# وجه (إطار)
box(10, 6, 108, 52, 1)
# عين يسار (مربع ممتلئ)
fill_box(35, 22, 10, 10, 1)
# بؤبؤ/لمعة (مربع فارغ)
fill_box(38, 25, 4, 4, 0)
# عين يمين
fill_box(83, 22, 10, 10, 1)
fill_box(86, 25, 4, 4, 0)
# أنف (خط عمودي بسيط)
for y in range(30, 40):
oled.pixel(64, y, 1)
for x in range(62, 67):
oled.pixel(x, 40, 1)
# فم (ابتسامة بسيطة)
for x in range(48, 81):
oled.pixel(x, 46, 1)
oled.pixel(47, 45, 1)
oled.pixel(81, 45, 1)
# خدود
oled.pixel(25, 38, 1)
oled.pixel(27, 39, 1)
oled.pixel(103, 38, 1)
oled.pixel(101, 39, 1)
oled.text("AI", 58, 10, 1)
oled.show()
draw_face()
while True:
time.sleep(1)