from machine import Pin, SoftI2C
from OLED_1inch5 import OLED_1inch5
import time
print("LAB 5 REAL BOARD STARTED")
i2c = SoftI2C(sda=Pin(6), scl=Pin(7), freq=1_000_000)
OLED_ADDR = 0x3d
oled = OLED_1inch5(OLED_ADDR, i2c)
print("OLED initialized (SSD1327 128x128)")
# STATIC FRAME
oled.fill(0)
oled.text("LAB 5 - OLED", 5, 5, 15)
oled.text("SSD1327 128x128", 5, 20, 15)
oled.line(0, 0, 127, 0, 10)
oled.hline(0, 64, 128, 5)
oled.vline(64, 0, 128, 5)
oled.rect(5, 80, 40, 30, 8)
oled.rect(60, 80, 50, 30, 12, True)
oled.pixel(110, 110, 15)
oled.show()
print("Static frame shown")
# Пауза 3 секунди перед анімацією
time.sleep(3)
# ANIMATION LOOP
x = 0
direction = 1
last_log_time = time.ticks_ms()
print("Animation started")
while True:
oled.fill(0)
oled.text("Animation", 30, 10, 15)
oled.fill_rect(x, 60, 30, 30, 12)
oled.show()
x += direction * 5
if x <= 0:
x = 0
direction = 1
print("Bounce left")
elif x >= 98:
x = 98
direction = -1
print("Bounce right")
time.sleep(0.05)