]> vault307.fbx.one Git - PicoTamachibi.git/blob - display.py
Neuer Kommentar Z.10
[PicoTamachibi.git] / display.py
1 from machine import I2C, Pin
2 from ssd1306 import SSD1306_I2C
3 import framebuf
4 from time import sleep
5
6 sda = Pin(0)
7 scl = Pin(1)
8 id = 0
9
10 i2c = I2C(id=id, sda=sda, scl=scl)
11
12 oled = SSD1306_I2C(width=128, height=64, i2c=i2c)
13 oled.init_display()
14 oled.text("test", 1, 1)
15 oled.show()
16 sleep(1)
17
18 images = []
19 for n in range (1,5):
20 with open('frame0%s.pbm' % n, 'rb') as f:
21 f.readline() # magic number
22 f.readline() # creator comment
23 f.readline() # dimensions
24 data = bytearray(f.read())
25 fbuf = framebuf.FrameBuffer(data, 128,64, framebuf.MONO_HLSB)
26 images.append(fbuf)
27
28 while True:
29 for i in images:
30 oled.invert(1)
31 oled.blit(i,0,0)
32 oled.show()
33 sleep(0.1)
34 sleep(0.4)
35 for i in reversed(images):
36 oled.invert(1)
37 oled.blit(i,0,0)
38 oled.show()
39 sleep(0.1)