From c61476e8468dbe84b78bea1757c3e945e94b790e Mon Sep 17 00:00:00 2001 From: david rice Date: Thu, 2 Apr 2026 16:08:50 +0100 Subject: [PATCH] Last of day, might have working --- mipi_test.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mipi_test.py b/mipi_test.py index 5693b9a..0064777 100644 --- a/mipi_test.py +++ b/mipi_test.py @@ -28,6 +28,8 @@ SIG_POINTS = 500_000 # 500 k pts → ~25 GSa/s PROTO_SCALE = 1e-6 # 1 µs/div → 10 µs window PROTO_POINTS = 500_000 # 500 k pts → 50 MSa/s (enough to see burst structure) +DISPLAY_SETTLE_S = 1.0 # seconds to wait after display ON before arming scope + test_running = False # Global flag to control the background thread # --- Instrument Connection --- @@ -241,10 +243,10 @@ def dual_capture(iteration): scope.write(":RUN") -def test_worker(on_time): +def test_worker(): """ Background loop: - - Turns display ON, waits on_time seconds for it to stabilise + - Turns display ON, waits DISPLAY_SETTLE_S for it to stabilise - Runs dual_capture (signal quality + frame structure) - Turns display OFF for 1 second - Repeats until test_running = False @@ -254,7 +256,7 @@ def test_worker(on_time): while test_running: requests.put(URL, json={"state": "on"}, timeout=2) - time.sleep(on_time) # let display stabilise before arming + time.sleep(DISPLAY_SETTLE_S) dual_capture(count) count += 1 requests.put(URL, json={"state": "off"}, timeout=2) @@ -298,14 +300,10 @@ def main_menu(): elif choice == '5': if not test_running: - try: - sec = float(input("ON DURATION (seconds): ")) - test_running = True - t = threading.Thread(target=test_worker, args=(sec,), daemon=True) - t.start() - print(f"TEST STARTED — ON TIME: {sec}s") - except ValueError: - print("INVALID TIME ENTERED.") + test_running = True + t = threading.Thread(target=test_worker, daemon=True) + t.start() + print("TEST STARTED.") else: print("TEST IS ALREADY RUNNING!")