Last of day, might have working
This commit is contained in:
20
mipi_test.py
20
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_SCALE = 1e-6 # 1 µs/div → 10 µs window
|
||||||
PROTO_POINTS = 500_000 # 500 k pts → 50 MSa/s (enough to see burst structure)
|
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
|
test_running = False # Global flag to control the background thread
|
||||||
|
|
||||||
# --- Instrument Connection ---
|
# --- Instrument Connection ---
|
||||||
@@ -241,10 +243,10 @@ def dual_capture(iteration):
|
|||||||
scope.write(":RUN")
|
scope.write(":RUN")
|
||||||
|
|
||||||
|
|
||||||
def test_worker(on_time):
|
def test_worker():
|
||||||
"""
|
"""
|
||||||
Background loop:
|
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)
|
- Runs dual_capture (signal quality + frame structure)
|
||||||
- Turns display OFF for 1 second
|
- Turns display OFF for 1 second
|
||||||
- Repeats until test_running = False
|
- Repeats until test_running = False
|
||||||
@@ -254,7 +256,7 @@ def test_worker(on_time):
|
|||||||
|
|
||||||
while test_running:
|
while test_running:
|
||||||
requests.put(URL, json={"state": "on"}, timeout=2)
|
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)
|
dual_capture(count)
|
||||||
count += 1
|
count += 1
|
||||||
requests.put(URL, json={"state": "off"}, timeout=2)
|
requests.put(URL, json={"state": "off"}, timeout=2)
|
||||||
@@ -298,14 +300,10 @@ def main_menu():
|
|||||||
|
|
||||||
elif choice == '5':
|
elif choice == '5':
|
||||||
if not test_running:
|
if not test_running:
|
||||||
try:
|
test_running = True
|
||||||
sec = float(input("ON DURATION (seconds): "))
|
t = threading.Thread(target=test_worker, daemon=True)
|
||||||
test_running = True
|
t.start()
|
||||||
t = threading.Thread(target=test_worker, args=(sec,), daemon=True)
|
print("TEST STARTED.")
|
||||||
t.start()
|
|
||||||
print(f"TEST STARTED — ON TIME: {sec}s")
|
|
||||||
except ValueError:
|
|
||||||
print("INVALID TIME ENTERED.")
|
|
||||||
else:
|
else:
|
||||||
print("TEST IS ALREADY RUNNING!")
|
print("TEST IS ALREADY RUNNING!")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user