Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 2d8740a

Browse files
committed
tests/extmod: Add a test for framebuf module, tested by coverage build.
1 parent 47899a1 commit 2d8740a

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

tests/extmod/framebuf1.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
try:
2+
import framebuf
3+
except ImportError:
4+
print("SKIP")
5+
import sys
6+
sys.exit()
7+
8+
w = 5
9+
h = 16
10+
buf = bytearray(w * h // 8)
11+
fbuf = framebuf.FrameBuffer1(buf, w, h, w)
12+
13+
# fill
14+
fbuf.fill(1)
15+
print(buf)
16+
fbuf.fill(0)
17+
print(buf)
18+
19+
# put pixel
20+
fbuf.pixel(0, 0, 1)
21+
fbuf.pixel(4, 0, 1)
22+
fbuf.pixel(0, 15, 1)
23+
fbuf.pixel(4, 15, 1)
24+
print(buf)
25+
26+
# get pixel
27+
print(fbuf.pixel(0, 0), fbuf.pixel(1, 1))
28+
29+
# scroll
30+
fbuf.fill(0)
31+
fbuf.pixel(2, 7, 1)
32+
fbuf.scroll(0, 1)
33+
print(buf)
34+
fbuf.scroll(0, -2)
35+
print(buf)

tests/extmod/framebuf1.py.exp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
2+
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
3+
bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x80')
4+
1 0
5+
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00')
6+
bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00')

unix/mpconfigport_coverage.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
#undef MICROPY_VFS_FAT
3636
#define MICROPY_FSUSERMOUNT (1)
3737
#define MICROPY_VFS_FAT (1)
38+
#define MICROPY_PY_FRAMEBUF (1)

0 commit comments

Comments
 (0)