From 39f47c458d020253789cccf69e1ea453915d5854 Mon Sep 17 00:00:00 2001 From: Adrian Granados Date: Fri, 23 Sep 2022 21:26:51 -0400 Subject: [PATCH] Add option to take screenshots in emulation mode. Press 'g' to take a screenshot of the current screen. Screenshots are saved to /home/wlanpi/screenshots. --- debian/changelog | 6 ++++++ fpms/fpms.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/debian/changelog b/debian/changelog index a16a5dc..3e69e7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wlanpi-fpms (1.2.49) unstable; urgency=medium + + * Adds option to take screenshots in emulation mode + + -- Adrian Granados Fri, 23 Sep 2022 20:25:24 -0500 + wlanpi-fpms (1.2.48) unstable; urgency=medium * [profiler] Fix logic corrupting /etc/wlanpi-profiler/config.ini diff --git a/fpms/fpms.py b/fpms/fpms.py index 202380b..a0352cd 100755 --- a/fpms/fpms.py +++ b/fpms/fpms.py @@ -964,6 +964,9 @@ def emulate_buttons(): running = False break + if (char == "g" or char == "G"): + capture_screen() + if (char == "8" or char == "w"): button_up.pin.drive_low() button_up.pin.drive_high() @@ -1003,6 +1006,7 @@ def emulate_buttons(): print("UP = 'w', DOWN = 'x', LEFT = 'a', RIGHT = 'd', CENTER = 's'") if button_key1 and button_key2 and button_key3: print("KEY1 = 'i', KEY2 = 'o', KEY3 = 'p'") + print("Press 'g' to capture the screen.") print("Press 'k' to terminate.") e = threading.Thread(name="button-emulator", target=emulate_buttons) e.start() @@ -1010,6 +1014,17 @@ def emulate_buttons(): ############################################################################## # Helper functions ############################################################################## + def capture_screen(): + g_vars['sig_fired'] = True + screenshots_dir = "/home/wlanpi/screenshots" + if not os.path.exists(screenshots_dir): + os.makedirs(screenshots_dir) + timestr = datetime.now().strftime("%Y_%m_%d-%I_%M_%S_%p") + save_file = screenshots_dir + "/screenshot_" + timestr + ".png" + g_vars['image'].save(save_file) + print(save_file) + g_vars['sig_fired'] = False + def sleep_screen(): oled.sleep() g_vars['screen_cleared'] = True