summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/framebuf1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod/framebuf1.py')
-rw-r--r--tests/extmod/framebuf1.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/extmod/framebuf1.py b/tests/extmod/framebuf1.py
index 52899028c7..cdc7e5b188 100644
--- a/tests/extmod/framebuf1.py
+++ b/tests/extmod/framebuf1.py
@@ -8,7 +8,10 @@ except ImportError:
w = 5
h = 16
buf = bytearray(w * h // 8)
-fbuf = framebuf.FrameBuffer1(buf, w, h, w)
+fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.MVLSB)
+
+# access as buffer
+print(memoryview(fbuf)[0])
# fill
fbuf.fill(1)
@@ -30,6 +33,36 @@ print(buf)
# get pixel
print(fbuf.pixel(0, 0), fbuf.pixel(1, 1))
+# hline
+fbuf.fill(0)
+fbuf.hline(0, 1, w, 1)
+print('hline', buf)
+
+# vline
+fbuf.fill(0)
+fbuf.vline(1, 0, h, 1)
+print('vline', buf)
+
+# rect
+fbuf.fill(0)
+fbuf.rect(1, 1, 3, 3, 1)
+print('rect', buf)
+
+#fill rect
+fbuf.fill(0)
+fbuf.fill_rect(1, 1, 3, 3, 1)
+print('fill_rect', buf)
+
+# line
+fbuf.fill(0)
+fbuf.line(1, 1, 3, 3, 1)
+print('line', buf)
+
+# line steep negative gradient
+fbuf.fill(0)
+fbuf.line(3, 3, 2, 1, 1)
+print('line', buf)
+
# scroll
fbuf.fill(0)
fbuf.pixel(2, 7, 1)
@@ -54,3 +87,13 @@ print(buf)
# char out of font range set to chr(127)
fbuf.text(str(chr(31)), 0, 0)
print(buf)
+
+# test invalid constructor
+try:
+ fbuf = framebuf.FrameBuffer(buf, w, h, 2, framebuf.MVLSB)
+except ValueError:
+ print("ValueError")
+
+# test legacy constructor
+fbuf = framebuf.FrameBuffer1(buf, w, h)
+fbuf = framebuf.FrameBuffer1(buf, w, h, w)