from machine import Pin, I2C
from time import sleep
from ssd1306 import SSD1306_I2C

# 初始化I2C接口
i2c = I2C(0, scl=Pin(22), sda=Pin(21))

# 初始化OLED显示屏
oled_width = 128
oled_height = 64
oled = SSD1306_I2C(oled_width, oled_height, i2c)

# 清空屏幕
oled.fill(0)
oled.show()

# 定义表情
def draw_face_happy():
    oled.fill(0)  # 清空屏幕
    # 眼睛
    oled.framebuf.fill_rect(30, 20, 10, 10, 1)  # 左眼
    oled.framebuf.fill_rect(90, 20, 10, 10, 1)  # 右眼
    # 微笑
    oled.arc(40, 40, 48, 52, 1)  # 微笑弧线
    oled.show()

def draw_face_sad():
    oled.fill(0)  # 清空屏幕
    # 眼睛
    oled.framebuf.fill_rect(30, 20, 10, 10, 1)  # 左眼
    oled.framebuf.fill_rect(90, 20, 10, 10, 1)  # 右眼
    # 哭的想起