2525
2626import click
2727import numpy as np
28+ from PIL import ImageEnhance
2829from pyvirtualdisplay .smartdisplay import SmartDisplay
2930
3031import adafruit_blinka_raspberry_pi5_piomatter as piomatter
3738@click .option ("--backend" , help = "The pyvirtualdisplay backend to use" , default = "xvfb" )
3839@click .option ("--extra-args" , help = "Extra arguments to pass to the backend server" , default = "" )
3940@click .option ("--rfbport" , help = "The port number for the --backend xvnc" , default = None , type = int )
41+ @click .option ("--brightness" , help = "The brightness factor of the image output to the matrix" ,
42+ default = 1.0 , type = click .FloatRange (min = 0.1 , max = 1.0 ))
4043@click .option ("--use-xauth/--no-use-xauth" , help = "If a Xauthority file should be created" , default = False )
4144@piomatter_click .standard_options
4245@click .argument ("command" , nargs = - 1 )
43- def main (scale , backend , use_xauth , extra_args , rfbport , width , height , serpentine , rotation , pinout ,
46+ def main (scale , backend , use_xauth , extra_args , rfbport , brightness , width , height , serpentine , rotation , pinout ,
4447 n_planes , n_temporal_planes , n_addr_lines , n_lanes , command ):
4548 kwargs = {}
4649 if backend == "xvnc" :
@@ -61,8 +64,12 @@ def main(scale, backend, use_xauth, extra_args, rfbport, width, height, serpenti
6164 with SmartDisplay (backend = backend , use_xauth = use_xauth , size = (round (width * scale ),round (height * scale )), manage_global_env = False , ** kwargs ) as disp , Popen (command , env = disp .env ()) as proc :
6265 while proc .poll () is None :
6366 img = disp .grab (autocrop = False )
67+
6468 if img is None :
6569 continue
70+ if brightness != 1.0 :
71+ darkener = ImageEnhance .Brightness (img )
72+ img = darkener .enhance (brightness )
6673 img = img .resize ((width , height ))
6774 framebuffer [:, :] = np .array (img )
6875 matrix .show ()
0 commit comments