@@ -299,35 +299,6 @@ def _set_hue_to_config(self):
299299 ProcessRunner .run (["modetest" , "-M" , "rockchip" , "-a" , "-w" ,
300300 "179:hue:" + str (self .system_config .hue * 5 )])
301301
302-
303- #This was from ChatGPT and might be able to be modified to get the current display
304- #but currently its capturing an old one which just says Loading...
305- def capture_kmsdrm_png (self , output_path = "/tmp/screenshot.png" , fb_path = "/dev/fb0" ):
306- logger = PyUiLogger .get_logger ()
307-
308- # Read width/height/stride from sysfs if possible
309- try :
310- with open ("/sys/class/graphics/fb0/virtual_size" , "r" ) as f :
311- width_str , height_str = f .read ().strip ().split ("," )
312- width , height = int (width_str ), int (height_str )
313- with open ("/sys/class/graphics/fb0/stride" , "r" ) as f :
314- stride = int (f .read ().strip ())
315- except Exception as e :
316- logger .warning (f"Failed to read fb0 sysfs info: { e } , using defaults" )
317- width , height , stride = 640 , 480 , 2560
318-
319- # Open framebuffer for reading
320- frame_bytes = bytearray ()
321- with open (fb_path , "rb" ) as fb :
322- for _ in range (height ):
323- row = fb .read (stride )
324- frame_bytes .extend (row [:width * 4 ]) # slice only visible pixels
325-
326- # Convert BGRA to RGBA
327- img = Image .frombytes ("RGBA" , (width , height ), bytes (frame_bytes ), "raw" , "BGRA" )
328- img .save (output_path )
329- logger .info (f"Framebuffer saved to { output_path } ({ width } x{ height } )" )
330- return output_path
331302
332303 def _take_snapshot (self , path ):
333304 ProcessRunner .run (["/mnt/sdcard/spruce/flip/screenshot.sh" , path ])
0 commit comments