Skip to content

Commit

Permalink
Add option to take screenshots in emulation mode.
Browse files Browse the repository at this point in the history
Press 'g' to take a screenshot of the current screen.
Screenshots are saved to /home/wlanpi/screenshots.
  • Loading branch information
adriangranados committed Sep 24, 2022
1 parent 2901538 commit 39f47c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wlanpi-fpms (1.2.49) unstable; urgency=medium

* Adds option to take screenshots in emulation mode

-- Adrian Granados <adrian@intuitibits.com> 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
Expand Down
15 changes: 15 additions & 0 deletions fpms/fpms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -1003,13 +1006,25 @@ 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()

##############################################################################
# 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
Expand Down

0 comments on commit 39f47c4

Please sign in to comment.