Skip to content
Snippets Groups Projects
Commit 2d8740a4 authored by Damien George's avatar Damien George
Browse files

tests/extmod: Add a test for framebuf module, tested by coverage build.

parent 47899a1a
No related branches found
No related tags found
No related merge requests found
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)
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x80')
1 0
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00')
bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00')
......@@ -35,3 +35,4 @@
#undef MICROPY_VFS_FAT
#define MICROPY_FSUSERMOUNT (1)
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_FRAMEBUF (1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment