import Pico_LCD_1_3
import time
lcd = Pico_LCD_1_3.LCD_1inch3()
# Константы
BLACK = 0x0000
EYE_COLOR = 0x0F0F
HEART_COLOR = 0xF0F0
TEAR_COLOR = 0x001F # Попробуем этот цвет для слез
def draw_eyes(rx, ry):
lcd.fill(BLACK)
lcd.ellipse(80, 120, rx, ry, EYE_COLOR, True)
lcd.ellipse(160, 120, rx, ry, EYE_COLOR, True)
lcd.show()
def blink():
# Овал -> Круг (25,40 -> 25,25) -> Плоская дуга (25, 5)
for ry in range(40, 0, -8):
draw_eyes(25, ry)
time.sleep(0.05)
time.sleep(0.1)
for ry in range(0, 41, 8):
draw_eyes(25, ry)
time.sleep(0.05)
def set_emotion(emotion):
if emotion == "normal":
draw_eyes(25, 40)
elif emotion == "heart":
# Сначала схлопываем
for ry in range(40, 5, -5):
draw_eyes(25, ry)
time.sleep(0.05)
# Отрисовка сердца (просто два красных круга для начала)
lcd.ellipse(80, 120, 15, 15, HEART_COLOR, True)
lcd.ellipse(160, 120, 15, 15, HEART_COLOR, True)
lcd.show()
elif emotion == "sad":
# Рисуем "грустные" глаза
draw_eyes(25, 20)
# Анимация капающей слезы
for y in range(130, 200, 10):
lcd.fill_rect(75, y, 5, 8, TEAR_COLOR)
lcd.fill_rect(155, y, 5, 8, TEAR_COLOR)
lcd.show()
time.sleep(0.1)
lcd.fill_rect(75, y, 5, 8, BLACK) # Стираем след
lcd.fill_rect(155, y, 5, 8, BLACK)
elif emotion == "blink":
blink()
print("Робот готов! Пиши: set_emotion('heart'), set_emotion('sad'), set_emotion('blink')")