from time import sleep
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
from framebuf import FrameBuffer, MONO_VLSB
i2c = I2C(scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
oled = SSD1306_I2C(oled_width, oled_height, i2c)
buf = bytearray(oled_width * oled_height // 8)
fb = FrameBuffer(buf, oled_width, oled_height, MONO_VLSB)
fb.fill(0)
fb.text("Iniciando...", 0, 0)
oled.blit(fb, 0, 0)
oled.show()
x = count = 0
def square(x, color):
for i in range(4):
fb.line(x, 35+i, x+3, 35+i, color)
while True:
fb.fill(0)
fb.text("Compt. Grafica", 0, 0)
fb.text(f">> Contagem: {count}", 0, 20)
x += 1
count += 1
if x + 3 >= 128:
x = 0
square(x, 1)
oled.blit(fb, 0, 0)
oled.show()
sleep(0.001)