Browse Source
This format is used in 2-color LED matrices and in e-ink displays like SSD1606.pull/3422/merge
Petr Viktorin
7 years ago
committed by
Damien George
4 changed files with 153 additions and 0 deletions
@ -0,0 +1,62 @@ |
|||
try: |
|||
import framebuf |
|||
except ImportError: |
|||
print("SKIP") |
|||
raise SystemExit |
|||
|
|||
def printbuf(): |
|||
print("--8<--") |
|||
for y in range(h): |
|||
for x in range(w): |
|||
print('%u' % ((buf[(x + y * w) // 4] >> ((x & 3) << 1)) & 3), end='') |
|||
print() |
|||
print("-->8--") |
|||
|
|||
w = 8 |
|||
h = 5 |
|||
buf = bytearray(w * h // 4) |
|||
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS2_HMSB) |
|||
|
|||
# fill |
|||
fbuf.fill(3) |
|||
printbuf() |
|||
fbuf.fill(0) |
|||
printbuf() |
|||
|
|||
# put pixel |
|||
fbuf.pixel(0, 0, 1) |
|||
fbuf.pixel(3, 0, 2) |
|||
fbuf.pixel(0, 4, 3) |
|||
fbuf.pixel(3, 4, 2) |
|||
printbuf() |
|||
|
|||
# get pixel |
|||
print(fbuf.pixel(0, 4), fbuf.pixel(1, 1)) |
|||
|
|||
# scroll |
|||
fbuf.fill(0) |
|||
fbuf.pixel(2, 2, 3) |
|||
printbuf() |
|||
fbuf.scroll(0, 1) |
|||
printbuf() |
|||
fbuf.scroll(1, 0) |
|||
printbuf() |
|||
fbuf.scroll(-1, -2) |
|||
printbuf() |
|||
|
|||
w2 = 2 |
|||
h2 = 3 |
|||
buf2 = bytearray(w2 * h2 // 4) |
|||
fbuf2 = framebuf.FrameBuffer(buf2, w2, h2, framebuf.GS2_HMSB) |
|||
|
|||
# blit |
|||
fbuf2.fill(0) |
|||
fbuf2.pixel(0, 0, 1) |
|||
fbuf2.pixel(0, 2, 2) |
|||
fbuf2.pixel(1, 0, 1) |
|||
fbuf2.pixel(1, 2, 2) |
|||
fbuf.fill(3) |
|||
fbuf.blit(fbuf2, 3, 3, 0) |
|||
fbuf.blit(fbuf2, -1, -1, 0) |
|||
fbuf.blit(fbuf2, 16, 16, 0) |
|||
printbuf() |
@ -0,0 +1,57 @@ |
|||
--8<-- |
|||
33333333 |
|||
33333333 |
|||
33333333 |
|||
33333333 |
|||
33333333 |
|||
-->8-- |
|||
--8<-- |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
-->8-- |
|||
--8<-- |
|||
10020000 |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
30020000 |
|||
-->8-- |
|||
3 0 |
|||
--8<-- |
|||
00000000 |
|||
00000000 |
|||
00300000 |
|||
00000000 |
|||
00000000 |
|||
-->8-- |
|||
--8<-- |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
00300000 |
|||
00000000 |
|||
-->8-- |
|||
--8<-- |
|||
00000000 |
|||
00000000 |
|||
00000000 |
|||
00030000 |
|||
00000000 |
|||
-->8-- |
|||
--8<-- |
|||
00000000 |
|||
00300000 |
|||
00000000 |
|||
00030000 |
|||
00000000 |
|||
-->8-- |
|||
--8<-- |
|||
33333333 |
|||
23333333 |
|||
33333333 |
|||
33311333 |
|||
33333333 |
|||
-->8-- |
Loading…
Reference in new issue