diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e39deacb9a71823fa9a509ace4ae234a42e8857..d01df2aafdf17b121331bf57a4fc3865ea8df76c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,6 +70,15 @@ build-p6: paths: ['build/flow3r.elf'] expire_in: 5 hours +simulate: + stage: build + script: + - python3 sim/run.py screenshot + artifacts: + expose_as: 'Smulator Screenshot' + paths: ['flow3r.png'] + expire_in: 5 hours + pages: stage: deploy only: diff --git a/sim/fakes/hardware.py b/sim/fakes/hardware.py index 03462f885e11572ccdd51d522f14416da45ad0f6..316ceee2810844e9252e74425986bdf48a05ba27 100644 --- a/sim/fakes/hardware.py +++ b/sim/fakes/hardware.py @@ -2,6 +2,7 @@ import math import os import time import itertools +import sys import pygame @@ -15,6 +16,10 @@ bgpath = os.path.join(simpath, "background.png") background = pygame.image.load(bgpath) +SCREENSHOT = False +SCREENSHOT_DELAY = 5 + + class Input: """ Input implements an input overlay (for petals or buttons) that can be @@ -466,6 +471,16 @@ def display_update(subctx): _sim.render_display(fb) _sim.render_gui_now() + global SCREENSHOT + global SCREENSHOT_DELAY + if SCREENSHOT: + SCREENSHOT_DELAY -= 1 + if SCREENSHOT_DELAY <= 0: + path = os.curdir + "/flow3r.png" + pygame.image.save(screen, path) + print("Saved screenshot to ", path) + sys.exit(0) + fbm.put(fbp, c) diff --git a/sim/run.py b/sim/run.py index 18e58649786a4bc0810380e727baf0c0129c9a6c..c6037d1f30e1828f4390a42729f257c7c0f4803f 100644 --- a/sim/run.py +++ b/sim/run.py @@ -107,4 +107,9 @@ def _stat(path): os.stat = _stat +if len(sys.argv) >= 2 and sys.argv[1] == "screenshot": + import hardware + + hardware.SCREENSHOT = True + import main