Загрузка данных


import Pico_LCD_1_3
import time

lcd = Pico_LCD_1_3.LCD_1inch3()

# Цвета
BLACK = 0x0000
EYE_COLOR = 0x0F0F
HEART_COLOR = 0x001F  # Надеюсь, это будет синий/голубой для сердец
TEAR_COLOR = 0x07FF   # Голубой цвет для слез

def draw_eyes(rx, ry):
    lcd.ellipse(80, 120, rx, ry, EYE_COLOR, True)
    lcd.ellipse(160, 120, rx, ry, EYE_COLOR, True)

def draw_heart(cx, cy):
    # Сердце: 2 круга + перевернутый треугольник
    # Круги
    lcd.ellipse(cx-8, cy-5, 8, 8, HEART_COLOR, True)
    lcd.ellipse(cx+8, cy-5, 8, 8, HEART_COLOR, True)
    # Треугольник (рисуем тремя линиями)
    lcd.line(cx-15, cy-2, cx+15, cy-2, HEART_COLOR)
    lcd.line(cx-15, cy-2, cx, cy+15, HEART_COLOR)
    lcd.line(cx+15, cy-2, cx, cy+15, HEART_COLOR)

# Глобальная переменная для управления циклом
current_emotion = "normal"

def set_emotion(emotion):
    global current_emotion
    current_emotion = emotion
    
    if emotion == "normal":
        lcd.fill(BLACK)
        draw_eyes(25, 40)
        lcd.show()

    elif emotion == "heart":
        # Моргание
        for i in range(40, 0, -10):
            lcd.fill(BLACK)
            draw_eyes(25, i)
            lcd.show()
            time.sleep(0.05)
        # Рисуем сердца
        lcd.fill(BLACK)
        draw_heart(80, 120)
        draw_heart(160, 120)
        lcd.show()

    elif emotion == "sad":
        # Цикл капания
        eye_idx = 0 # 0 - левый, 1 - правый
        while current_emotion == "sad":
            x = 80 if eye_idx == 0 else 160
            for y in range(130, 240, 15):
                if current_emotion != "sad": break
                lcd.fill(BLACK)
                draw_eyes(30, 20)
                lcd.ellipse(x, y, 5, 8, TEAR_COLOR, True)
                lcd.show()
                time.sleep(0.1)
            eye_idx = 1 - eye_idx # Переключаем глаз