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

This commit is contained in:
Damien George 2016-09-04 16:40:40 +10:00
parent 47899a1ab8
commit 2d8740a4d1
3 changed files with 42 additions and 0 deletions

35
tests/extmod/framebuf1.py Normal file
View File

@ -0,0 +1,35 @@
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)

View File

@ -0,0 +1,6 @@
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')

View File

@ -35,3 +35,4 @@
#undef MICROPY_VFS_FAT
#define MICROPY_FSUSERMOUNT (1)
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_FRAMEBUF (1)