Example #1
0
	def S3():
		print ("timeS3 S3 function")
		cad.lcd.clear()
		#Takes input
		question = LCDQuestion(question="Set TotalTime", answers=v1.totalTimeEngAnswers)
		answer_index = question.ask()
		cad.lcd.clear()
		v1.totalTimeEng = v1.totalTimeEngAnswers[answer_index]
		v1.totalTime = v1.totalTimeAnswers[answer_index]
		#User feedback
		cad.lcd.write("Time selected\n{0}".format(v1.totalTimeEng))
		time.sleep(1)
		cad.lcd.clear()
		#Setting individual video times
		if v1.currentMode == "VID":
			question = LCDQuestion(question= "Set Video Time", answers=v1.totalTimeEngAnswers)
			answer_index = question.ask()
			v1.videoTimeEng = v1.totalTimeEngAnswers[answer_index]
			v1.videoTime = v1.totalTimeAnswers[answer_index]
			cad.lcd.clear()
			cad.lcd.write("VidTime selected\n{0}".format(v1.videoTimeEng))
			time.sleep(1)
			#Double check individual video time is not greater than total time
			if v1.totalTime <  v1.videoTime:
				cad.lcd.clear()
				cad.lcd.write("Error: vidTime\nis too large")
				time.sleep(1)
				timeS3.S3()
			else:
				shutdownS5.homeScreen()
		else:
			shutdownS5.homeScreen()
Example #2
0
	def testRes():
		print ("camVidStartS1 testRes function")
		if v1.currentMode == "VID" and v1.resolutionH == "1944":
			cad.lcd.clear()
			cad.lcd.write("Wrong res\nTry again")
			time.sleep(1)
			shutdownS5.homeScreen()
		else:
			camVidStartS1.runCMD()
Example #3
0
	def updateCMD():
		print ("camVidStartS1 updateCMD function")
		if v1.totalTime == 0 or v1.resolutionW == 0 or v1.resolutionH == 0 or v1.inputFPS == 0 or \
					(v1.currentMode == "CAM" and v1.numFrames == 0):
			cad.lcd.clear()
			cad.lcd.write("Check inputs")
			time.sleep(2)
			shutdownS5.homeScreen()
		#Checks fps is correct for resolution
		elif v1.inputFPS != 0:
			camVidStartS1.testFPS()
Example #4
0
	def testFPS():
		print ("camVidStartS1 testFPS function")
		if v1.inputFPS == "Custom":
			pass
		else:
			setFpsS4.determineFPS()
			if v1.FPSanswers.count(v1.inputFPS) == 0:
				cad.lcd.clear()
				cad.lcd.write("Wrong frameRate\nTry again")
				time.sleep(1)
				shutdownS5.homeScreen()
			elif v1.FPSanswers.count(v1.inputFPS) > 0:
				camVidStartS1.testRes()
Example #5
0
	def S1():
		print ("camVidStartS1 S1 function")
		cad.lcd.clear()
		question = LCDQuestion(question="VID/CAM or START:", answers=v1.runMode)
		answer_index = question.ask()
		cad.lcd.clear()
		v1.inputRun = v1.runMode[answer_index]
		#Execute os string
		if v1.inputRun == "START":
			#Updates cmdStr with camera or vid inputs first before executing cmd
			#Also runs a series of checks to make sure all the inputs are correct
			camVidStartS1.updateCMD()
			cad.lcd.clear()
			cad.lcd.write("Running program")
			print (v1.cmdStr)
			if camVidStartS1.updateCMD() == "":
				cad.lcd.clear()
				cad.lcd.write("No inputs given!")
			else:
				pass
#				os.system("{0}".format(v1.cmdStr))
		#Video mode
		elif v1.inputRun == "VID":
			v1.currentMode = v1.inputRun
			cad.lcd.clear()
			cad.lcd.write("Selected video\nCheck res")
			time.sleep(1)
			shutdownS5.homeScreen()
		#Camera mode
		elif v1.inputRun == "CAM":
			v1.currentMode = v1.inputRun
			#Sets up timeInterval to be 1 in preparation for selecting the fps
			v1.timeInterval = 1
			cad.lcd.clear()
			cad.lcd.write("Selected pictures\nCheck res")
			time.sleep(1)
			shutdownS5.homeScreen()
		elif v1.inputRun == "Reset variables":
			print ("hi")
			v1.totalTime = 0
			v1.totalTimeEng = 0
			v1.videoTime = 0
			v1.videoTimeEng = 0
			v1.resolutionW = 0
			v1.resolutionH = 0
			v1.inputFPS = 0
			v1.numFrames = 0
			v1.timeInterval = 0
			v1.internalCamFR = 0
			v1.inputRun = ""
			v1.currentMode = "MODE"
			v1.cmdStr = ""
			shutdownS5.homeScreen()
		#Returns to homescreen
		else:
			shutdownS5.homeScreen()
Example #6
0
	def S4():
		print ("setFpsS4 S4 function")
		cad.lcd.clear()
		#Sets fps values based on chosen resolution, takes input from piface
		setFpsS4.determineFPS()
		question = LCDQuestion(question="Set FPS", answers=v1.FPSanswers)
		answer_index = question.ask()
		cad.lcd.clear()
		v1.inputFPS = v1.FPSanswers[answer_index]
		#Only for camera mode:
		#Internally sets v1.numFrames and v1.timeInterval based on the chosen fps from the above options.  If v1.inputFPS is "Custom",
		# the user chooses fps options.  For camera, internal framerate is set through runCMD when the resolution is sent to the slavePies.
		setFpsS4.setCamFramesAndTime()	
		setFpsS4.manualFpsSelect()
		#User feedback
		cad.lcd.write("FPS selected: \n{0}".format(v1.inputFPS))
		time.sleep(1)
		shutdownS5.homeScreen()
Example #7
0
	def manualFpsSelect():
		print ("setFpsS4 manualFpsSelect function")
		if v1.inputFPS == "Custom":
			question = LCDQuestion(question="Set numFrames", answers = v1.customNumFramesAnswers)
			answer_index = question.ask()
			v1.numFrames = v1.customNumFramesAnswers[answer_index]
			cad.lcd.clear()
			question = LCDQuestion(question="Set time (sec)", answers = v1.customTimeIntervalAnswers)
			answer_index = question.ask()
			v1.timeInterval = v1.customTimeIntervalAnswers[answer_index]
			cad.lcd.clear()

			v1.inputFPS = v1.numFrames
			cad.lcd.write("Selected fps:\n{0} frames/{1} secs".format(v1.numFrames, v1.timeInterval) )
			time.sleep(2)
			shutdownS5.homeScreen()
		else:
			pass
Example #8
0
	def S2():
		print ("resolutionS2 S2 function")
		cad.lcd.clear()
		# Takes input from piface
		if v1.currentMode == "CAM":
			v1.resAnswers = v1.camResAnswers
		else:
			v1.resAnswers = v1.vidResAnswers
		print (v1.resAnswers)
		question = LCDQuestion(question="Set resolution", answers=v1.resAnswers)
		answer_index = question.ask()
		#Parses answer into resW and resH
		v1.resolutionStr = v1.resAnswers[answer_index]
		resParse = str.split(v1.resolutionStr, 'x')
		v1.resolutionW = resParse[0]
		v1.resolutionH = resParse[1]
		cad.lcd.clear()
		#User feedback
		cad.lcd.write("Res selected: \n{0}x{1}".format(v1.resolutionW, v1.resolutionH))
		time.sleep(1)
		cad.lcd.clear()
		cad.lcd.write("Check frmrate\n is correct")
		time.sleep(1)
		shutdownS5.homeScreen()
Example #9
0
		print (v1.inputRun)
		print (v1.currentMode)
		print (v1.resolutionW)
		print (v1.resolutionH)
		print (v1.totalTime)
		print (v1.videoTime)
		print (v1.numFrames)
		print (v1.timeInterval)
		print (v1.inputFPS)
		print (v1.internalCamFR)

if __name__ == '__main__': 
	cad = pifacecad.PiFaceCAD()
	p1 = callAll()
	cad.lcd.clear()
	shutdownS5.homeScreen()

	#Note from pifacecad github:
	#listener cannot deactivate itself so we have to wait until it has finished using a barrier
	v1.end_barrier = Barrier(2)

	listener = pifacecad.SwitchEventListener(chip=cad)

	for i in range(8):
		listener.register(i, pifacecad.IODIR_FALLING_EDGE, p1.setParameters)	

	listener.activate()
	v1.end_barrier.wait() #Waiting until exit activated in the S5 method

	#Exit
	listener.deactivate()