Skip to content

First working implementation of framebuffer rendering in Python

Florian Gross requested to merge flgr/firmware:flgr-framebuf into master

Sample code:

import framebuf
import urandom
import display

bytes = bytearray(160 * 80 * 2)
fb = framebuf.FrameBuffer(bytes, 160, 80, framebuf.RGB565)
d = display.open()

while True:
    fb.scroll(-1, -1)
    for _ in range(10):
        rx = urandom.randint(0, 160 - 10)
        ry = urandom.randint(0, 80 - 10)
        fb.fill_rect(rx, ry, 10, 10, urandom.randint(0, 0b11111_111111_11111))
    display.sys_display.framebuffer(fb)

Would be cool to add Python plumbing for this. We could either wrap the framebuf module in more Python code to convert coordinates (top right corner is 0,0) and colors (5bit green red blue iirc) or add our own display format to the framebuf ext module maybe.

Edited by schneider

Merge request reports