summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/framebuf1.py
blob: f550b6b4f4d4e8e974f8cee676ae2be70320f7b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
try:
    import framebuf
except ImportError:
    print("SKIP")
    import sys
    sys.exit()

w = 5
h = 16
buf = bytearray(w * h // 8)
fbuf = framebuf.FrameBuffer1(buf, w, h, w)

# fill
fbuf.fill(1)
print(buf)
fbuf.fill(0)
print(buf)

# put pixel
fbuf.pixel(0, 0, 1)
fbuf.pixel(4, 0, 1)
fbuf.pixel(0, 15, 1)
fbuf.pixel(4, 15, 1)
print(buf)

# get pixel
print(fbuf.pixel(0, 0), fbuf.pixel(1, 1))

# scroll
fbuf.fill(0)
fbuf.pixel(2, 7, 1)
fbuf.scroll(0, 1)
print(buf)
fbuf.scroll(0, -2)
print(buf)
fbuf.scroll(1, 0)
print(buf)
fbuf.scroll(-1, 0)
print(buf)
fbuf.scroll(2, 2)
print(buf)