-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (29 loc) · 1.19 KB
/
Copy pathmain.py
File metadata and controls
39 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
### Main.py
### Executable for the TV class
import tv
import time
import sys
newTV = tv.TV(120, 44, 30, "https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# Check for download skip
if (len(sys.argv) > 1):
print ("Skipping download! Playing cached video")
else:
newTV.download_video()
wipe = "\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[Fv"
# Timers for drawing
start_draw = end_draw = diff_draw = total_draw = sleep_time = 0
fps_time = 1 / newTV.fps
for i in range (0, 2000):
print (wipe)
start_draw = time.perf_counter()
# Render
print(newTV.get_ascii_frame())
print(f"Render: {newTV.get_render_time()} Draw: {diff_draw} Total: {total_draw} Sleep: {sleep_time}")
# Calculate Time
end_draw = time.perf_counter()
diff_draw = end_draw - start_draw
total_draw = newTV.get_render_time() + diff_draw
sleep_time = fps_time - total_draw
# Only sleep if time is positive
if (sleep_time > 0):
time.sleep(sleep_time)