mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
Update timeturner.py
This commit is contained in:
parent
c9d15e1517
commit
b2804c604b
1 changed files with 8 additions and 8 deletions
|
|
@ -91,7 +91,7 @@ def run_curses(stdscr):
|
||||||
|
|
||||||
SERIAL_PORT = find_teensy_serial()
|
SERIAL_PORT = find_teensy_serial()
|
||||||
if not SERIAL_PORT:
|
if not SERIAL_PORT:
|
||||||
stdscr.addstr(0, 0, "❌ No serial device found.")
|
stdscr.addstr(0, 0, "X No serial device found.")
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return
|
return
|
||||||
|
|
@ -169,21 +169,21 @@ def run_curses(stdscr):
|
||||||
color = curses.color_pair(1)
|
color = curses.color_pair(1)
|
||||||
|
|
||||||
stdscr.attron(color)
|
stdscr.attron(color)
|
||||||
stdscr.addstr(7, 2, f"Sync Offset : {avg_ms:+.0f} ms ({avg_frames:+.0f} frames)")
|
stdscr.addstr(7, 2, f"Sync Jitter : {avg_ms:+.0f} ms ({avg_frames:+.0f} frames)")
|
||||||
stdscr.attroff(color)
|
stdscr.attroff(color)
|
||||||
elif parsed["status"] == "FREE":
|
elif parsed["status"] == "FREE":
|
||||||
stdscr.attron(curses.color_pair(3))
|
stdscr.attron(curses.color_pair(3))
|
||||||
stdscr.addstr(7, 2, "⚠️ LTC UNSYNCED — offset unavailable")
|
stdscr.addstr(7, 2, "⚠ LTC UNSYNCED — offset unavailable")
|
||||||
stdscr.attroff(curses.color_pair(3))
|
stdscr.attroff(curses.color_pair(3))
|
||||||
else:
|
else:
|
||||||
stdscr.addstr(7, 2, "Sync Offset : …")
|
stdscr.addstr(7, 2, "Sync Jitter : …")
|
||||||
|
|
||||||
# Timecode Match
|
# Timecode Match
|
||||||
if timecode_match_status == "IN SYNC":
|
if timecode_match_status == "IN SYNC":
|
||||||
stdscr.attron(curses.color_pair(2))
|
stdscr.attron(curses.color_pair(2))
|
||||||
elif timecode_match_status == "OUT OF SYNC":
|
elif timecode_match_status == "OUT OF SYNC":
|
||||||
stdscr.attron(curses.color_pair(1))
|
stdscr.attron(curses.color_pair(1))
|
||||||
stdscr.addstr(8, 2, f"Timecode Match: {timecode_match_status}")
|
stdscr.addstr(8, 2, f"Sync Status : {timecode_match_status}")
|
||||||
stdscr.attroff(curses.color_pair(1))
|
stdscr.attroff(curses.color_pair(1))
|
||||||
stdscr.attroff(curses.color_pair(2))
|
stdscr.attroff(curses.color_pair(2))
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ def run_curses(stdscr):
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stdscr.addstr(13, 2, f"⚠️ Error: {e}")
|
stdscr.addstr(13, 2, f"⚠ Error: {e}")
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
@ -233,9 +233,9 @@ def do_sync(stdscr, parsed, arrival_time):
|
||||||
)
|
)
|
||||||
timestamp = sync_time.strftime("%H:%M:%S.%f")[:-3]
|
timestamp = sync_time.strftime("%H:%M:%S.%f")[:-3]
|
||||||
subprocess.run(["sudo", "date", "-s", timestamp], check=True)
|
subprocess.run(["sudo", "date", "-s", timestamp], check=True)
|
||||||
stdscr.addstr(13, 2, f"✔️ Synced to LTC: {timestamp}")
|
stdscr.addstr(13, 2, f"✔ Synced to LTC: {timestamp}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stdscr.addstr(13, 2, f"❌ Sync failed: {e}")
|
stdscr.addstr(13, 2, f"X Sync failed: {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
curses.initscr()
|
curses.initscr()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue