tests/extmod: Add a test for framebuf module, tested by coverage build.
This commit is contained in:
parent
47899a1ab8
commit
2d8740a4d1
35
tests/extmod/framebuf1.py
Normal file
35
tests/extmod/framebuf1.py
Normal 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)
|
6
tests/extmod/framebuf1.py.exp
Normal file
6
tests/extmod/framebuf1.py.exp
Normal 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')
|
@ -35,3 +35,4 @@
|
||||
#undef MICROPY_VFS_FAT
|
||||
#define MICROPY_FSUSERMOUNT (1)
|
||||
#define MICROPY_VFS_FAT (1)
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user