From 372a158bd7ebc1654def1ca654e99da1dafa9076 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 11 Mar 2025 08:53:07 -0500 Subject: [PATCH] Make n_temporal_planes, n_lanes "standard" argmuents & add the simple multilane mapper to examples that use click --- examples/fbmirror.py | 2 +- examples/fbmirror_scaled.py | 9 +++++++-- examples/virtualdisplay_keyboard.py | 12 ++++++++---- src/adafruit_blinka_raspberry_pi5_piomatter/click.py | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/fbmirror.py b/examples/fbmirror.py index d6a670d..d3eb18d 100644 --- a/examples/fbmirror.py +++ b/examples/fbmirror.py @@ -53,7 +53,7 @@ def make_pixelmap_multilane(width, height, n_addr_lines, n_lanes): @click.command @click.option("--x-offset", "xoffset", type=int, help="The x offset of top left corner of the region to mirror", default=0) @click.option("--y-offset", "yoffset", type=int, help="The y offset of top left corner of the region to mirror", default=0) -@piomatter_click.standard_options(n_lanes=2, n_temporal_planes=4) +@piomatter_click.standard_options def main(xoffset, yoffset, width, height, serpentine, rotation, pinout, n_planes, n_temporal_planes, n_addr_lines, n_lanes): if n_lanes != 2: pixelmap = simple_multilane_mapper(width, height, n_addr_lines, n_lanes) diff --git a/examples/fbmirror_scaled.py b/examples/fbmirror_scaled.py index b104e60..832c81f 100644 --- a/examples/fbmirror_scaled.py +++ b/examples/fbmirror_scaled.py @@ -43,6 +43,7 @@ import PIL.Image as Image import adafruit_blinka_raspberry_pi5_piomatter as piomatter import adafruit_blinka_raspberry_pi5_piomatter.click as piomatter_click +from adafruit_blinka_raspberry_pi5_piomatter.pixelmappers import simple_multilane_mapper with open("/sys/class/graphics/fb0/virtual_size") as f: screenx, screeny = [int(word) for word in f.read().split(",")] @@ -66,8 +67,12 @@ linux_framebuffer = np.memmap('/dev/fb0',mode='r', shape=(screeny, stride // byt @click.option("--y-offset", "yoffset", type=int, help="The y offset of top left corner of the region to mirror", default=0) @click.option("--scale", "scale", type=int, help="The scale factor to reduce the display down by.", default=3) @piomatter_click.standard_options -def main(xoffset, yoffset, scale, width, height, serpentine, rotation, pinout, n_planes, n_addr_lines): - geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_addr_lines=n_addr_lines, rotation=rotation) +def main(xoffset, yoffset, scale, width, height, serpentine, rotation, pinout, n_planes, n_temporal_planes, n_addr_lines, n_lanes): + if n_lanes != 2: + pixelmap = simple_multilane_mapper(width, height, n_addr_lines, n_lanes) + geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_addr_lines=n_addr_lines, n_temporal_planes=n_temporal_planes, n_lanes=n_lanes, map=pixelmap) + else: + geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_temporal_planes=n_temporal_planes, n_addr_lines=n_addr_lines, rotation=rotation) matrix_framebuffer = np.zeros(shape=(geometry.height, geometry.width, 3), dtype=np.uint8) matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed, pinout=pinout, framebuffer=matrix_framebuffer, geometry=geometry) diff --git a/examples/virtualdisplay_keyboard.py b/examples/virtualdisplay_keyboard.py index 91d2b5a..fcc1f48 100644 --- a/examples/virtualdisplay_keyboard.py +++ b/examples/virtualdisplay_keyboard.py @@ -35,6 +35,7 @@ from pyvirtualdisplay.smartdisplay import SmartDisplay import adafruit_blinka_raspberry_pi5_piomatter as piomatter import adafruit_blinka_raspberry_pi5_piomatter.click as piomatter_click +from adafruit_blinka_raspberry_pi5_piomatter.pixelmappers import simple_multilane_mapper keyboard_debug = False keys_down = set() @@ -92,8 +93,8 @@ ctrl_modified_range = (1, 26) @click.option("--ctrl-c-interrupt/--no-ctrl-c-interrupt", help="If Ctrl+C should be handled as an interrupt.", default=True) @piomatter_click.standard_options @click.argument("command", nargs=-1) -def main(scale, backend, use_xauth, extra_args, rfbport, width, height, serpentine, rotation, pinout, n_planes, - n_addr_lines, ctrl_c_interrupt, command): +def main(scale, backend, use_xauth, extra_args, rfbport, width, height, serpentine, rotation, pinout, n_planes, n_temporal_planes, + n_addr_lines, n_lanes, ctrl_c_interrupt, command): def handle_key_event(evt_data): if evt_data in key_map.keys(): keys_down.add(key_map[evt_data]) @@ -133,8 +134,11 @@ def main(scale, backend, use_xauth, extra_args, rfbport, width, height, serpenti if extra_args: kwargs['extra_args'] = shlex.split(extra_args) print("xauth", use_xauth) - geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_addr_lines=n_addr_lines, - rotation=rotation) + if n_lanes != 2: + pixelmap = simple_multilane_mapper(width, height, n_addr_lines, n_lanes) + geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_addr_lines=n_addr_lines, n_temporal_planes=n_temporal_planes, n_lanes=n_lanes, map=pixelmap) + else: + geometry = piomatter.Geometry(width=width, height=height, n_planes=n_planes, n_temporal_planes=n_temporal_planes, n_addr_lines=n_addr_lines, rotation=rotation) framebuffer = np.zeros(shape=(geometry.height, geometry.width, 3), dtype=np.uint8) matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed, pinout=pinout, framebuffer=framebuffer, geometry=geometry) diff --git a/src/adafruit_blinka_raspberry_pi5_piomatter/click.py b/src/adafruit_blinka_raspberry_pi5_piomatter/click.py index aa1da77..a78e276 100644 --- a/src/adafruit_blinka_raspberry_pi5_piomatter/click.py +++ b/src/adafruit_blinka_raspberry_pi5_piomatter/click.py @@ -40,9 +40,9 @@ def standard_options( rotation=piomatter.Orientation.Normal, pinout=piomatter.Pinout.AdafruitMatrixBonnet, n_planes=10, - n_temporal_planes=None, + n_temporal_planes=0, n_addr_lines=4, - n_lanes=None, + n_lanes=2, ) -> Callable[[], None]: """Add standard commandline flags, with the defaults given