2 changed files with 39 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||
|
class Framebuffer(object): |
||||
|
def __init__(self, device_no: int): |
||||
|
self.path = "/dev/fb%d" % device_no |
||||
|
config_dir = "/sys/class/graphics/fb%d/" % device_no |
||||
|
self.size = tuple(_read_and_convert_to_ints( |
||||
|
config_dir + "/virtual_size")) |
||||
|
self.stride = _read_and_convert_to_ints(config_dir + "/stride")[0] |
||||
|
self.bits_per_pixel = _read_and_convert_to_ints( |
||||
|
config_dir + "/bits_per_pixel")[0] |
||||
|
assert self.stride == self.bits_per_pixel // 8 * self.size[0] |
||||
|
def __str__(self): |
||||
|
args = (self.path, self.size, self.stride, self.bits_per_pixel) |
||||
|
return "%s size:%s stride:%s bits_per_pixel:%s" % args |
||||
|
# Note: performance is terrible even for medium resolutions |
||||
|
def show(self, image: Image): |
||||
|
converter = _CONVERTER[(image.mode, self.bits_per_pixel)] |
||||
|
assert image.size == self.size |
||||
|
out = converter(image) |
||||
|
with open(self.path, "wb") as fp: |
||||
|
fp.write(out) |
||||
|
def on(self): |
||||
|
pass |
||||
|
def off(self): |
||||
|
pass |
@ -0,0 +1,15 @@ |
|||||
|
import clock_pillow |
||||
|
from framebuffer import Framebuffer |
||||
|
import time |
||||
|
|
||||
|
|
||||
|
def main(): |
||||
|
fb = Framebuffer() |
||||
|
while True: |
||||
|
img = clock_pillow.draw_clock(pixelformat="RGB", aliasing=4) |
||||
|
fb.show(img) |
||||
|
time.sleep(0.1) |
||||
|
|
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
main() |
Loading…
Reference in new issue