Skip to content
Snippets Groups Projects
Commit d0f63ff6 authored by rahix's avatar rahix Committed by dx
Browse files

sim: Add configurable OLED aspect ratio

This can be used to fix aspect ratio stretching of badly configured
screens.
parent ea093a9a
No related branches found
No related tags found
1 merge request!189BIG flow3r
......@@ -29,6 +29,7 @@ bgpath = os.path.join(simpath, "background.png")
background = pygame.image.load(bgpath)
OLED_SIZE = int(os.environ["SIM_OLED_SIZE"])
OLED_ASPECT = float(os.environ["SIM_OLED_ASPECT"])
def path_replace(p):
......@@ -517,9 +518,11 @@ class Simulation:
center_x = screen_w // 2
center_y = screen_h // 2
if FULL_SCREEN:
off_x = center_x - (screen_h // 2)
off_x = center_x - (screen_h * OLED_ASPECT // 2)
off_y = center_y - (screen_h // 2)
new = pygame.transform.scale(self._oled_surface, (screen_h, screen_h))
new = pygame.transform.scale(
self._oled_surface, (screen_h * OLED_ASPECT, screen_h)
)
full.blit(new, (off_x, off_y))
else:
off_x = center_x - (OLED_SIZE // 2)
......
......@@ -163,6 +163,7 @@ def sim_main():
help="Run the simulator as full-screen OLED display.",
)
parser.add_argument("--oled-size", dest="oled_size", default=240)
parser.add_argument("--oled-aspect", dest="oled_aspect", default=1)
parser.add_argument(
"override_app",
nargs="?",
......@@ -173,6 +174,7 @@ def sim_main():
os.environ["SIM_FULL_SCREEN"] = "1" if args.full_screen else "0"
os.environ["SIM_OLED_SIZE"] = str(args.oled_size)
os.environ["SIM_OLED_ASPECT"] = str(args.oled_aspect)
import _sim
_sim.SCREENSHOT = args.screenshot
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment