#!/usr/bin/python3
import os
import time
import shutil

skipFrames = True

totalFrames = 7777

if skipFrames:
	startFrame=1
	skip=2
else:
	startFrame=0
	skip=1

startTime = time.time()

directory = 'lpbm/'
for i in range(startFrame, totalFrames, skip):
	path = os.path.join(directory, str(i)+".lpbm")

	#print (i)
	with open(path, 'rb') as f:
		pipe = open('/run/g13d/g13-0', 'wb')
		pipe.write(f.read())
		f.close()
		pipe.flush()
		pipe.close()
	#time.sleep(0.0416666666) # :/
	time.sleep(0.083333333) # Can't quite reach 24 fps, so we run at ~12 fps

endTime = time.time()

duration = endTime - startTime
print("Stop. Took " + str(duration) + " seconds.")
