summaryrefslogtreecommitdiff
path: root/tests/extmod/framebuf8.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-12-14 17:36:13 +1100
committerDamien George <damien.p.george@gmail.com>2017-12-14 17:36:13 +1100
commit46b35356e1727365dd5a33fcf3a722fda82c8b08 (patch)
tree1e279da65a7775aebc36c93a9cef8e65970b2af0 /tests/extmod/framebuf8.py
parent34247465c34113bb26f6c9582ea31f31b0ea0d1b (diff)
extmod/modframebuf: Add 8-bit greyscale format (GS8).
Diffstat (limited to 'tests/extmod/framebuf8.py')
-rw-r--r--tests/extmod/framebuf8.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/extmod/framebuf8.py b/tests/extmod/framebuf8.py
new file mode 100644
index 000000000..b6899aae9
--- /dev/null
+++ b/tests/extmod/framebuf8.py
@@ -0,0 +1,32 @@
+try:
+ import framebuf
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+def printbuf():
+ print("--8<--")
+ for y in range(h):
+ for x in range(w):
+ print('%02x' % buf[(x + y * w)], end='')
+ print()
+ print("-->8--")
+
+w = 8
+h = 5
+buf = bytearray(w * h)
+fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8)
+
+# fill
+fbuf.fill(0x55)
+printbuf()
+
+# put pixel
+fbuf.pixel(0, 0, 0x11)
+fbuf.pixel(w - 1, 0, 0x22)
+fbuf.pixel(0, h - 1, 0x33)
+fbuf.pixel(w - 1, h - 1, 0xff)
+printbuf()
+
+# get pixel
+print(hex(fbuf.pixel(0, h - 1)), hex(fbuf.pixel(1, 1)))