1try:
2    import framebuf
3except ImportError:
4    print("SKIP")
5    raise SystemExit
6
7
8def printbuf():
9    print("--8<--")
10    for y in range(h):
11        for x in range(w):
12            print("%02x" % buf[(x + y * w)], end="")
13        print()
14    print("-->8--")
15
16
17w = 8
18h = 5
19buf = bytearray(w * h)
20fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8)
21
22# fill
23fbuf.fill(0x55)
24printbuf()
25
26# put pixel
27fbuf.pixel(0, 0, 0x11)
28fbuf.pixel(w - 1, 0, 0x22)
29fbuf.pixel(0, h - 1, 0x33)
30fbuf.pixel(w - 1, h - 1, 0xFF)
31printbuf()
32
33# get pixel
34print(hex(fbuf.pixel(0, h - 1)), hex(fbuf.pixel(1, 1)))
35