Exemple #1
0
	def S3(self):
		cad.lcd.clear()
		#Takes input
		question = LCDQuestion(question="Set TotalTime", answers=totalTimeEngAnswers)
		answer_index = question.ask()
		cad.lcd.clear()
		p1.totalTimeEng = totalTimeEngAnswers[answer_index]
		p1.totalTime = totalTimeAnswers[answer_index]
		#User feedback
		cad.lcd.write("Time selected\n{0}".format(p1.totalTimeEng))
		time.sleep(1)
		cad.lcd.clear()
		#Setting individual video times
		if p1.currentMode == "VID":
			question = LCDQuestion(question= "Set Video Time", answers=totalTimeEngAnswers)
			answer_index = question.ask()
			p1.videoTimeEng = totalTimeEngAnswers[answer_index]
			p1.videoTime = totalTimeAnswers[answer_index]
			cad.lcd.clear()
			cad.lcd.write("VidTime selected\n{0}".format(p1.videoTimeEng))
			time.sleep(1)
			#Double check individual video time is not greater than total time
			if p1.totalTime <  p1.videoTime:
				cad.lcd.clear()
				cad.lcd.write("Error: vidTime\nis too large")
				time.sleep(1)
				p1.S3()
			else:
				p1.homeScreen()
		else:
			p1.homeScreen()
Exemple #2
0
	def S3(self):
		cad.lcd.clear()
		#Takes input
		question = LCDQuestion(question="Set TotalTime(M)", answers=timeAnswers)
		answer_index = question.ask()
		cad.lcd.clear()
		#User feedback
		if p1.currentMode == "VID":
			#Takes the first time input as total running time 
			p1.inputTime = timeAnswers[answer_index]
			cad.lcd.write("Total Time (min)\n{0}".format(p1.inputTime))
			time.sleep(1)
			cad.lcd.clear()
			#note: vidTimeEngAnswers is for usability, stored number is array index answer from vidTimeAnswers
			question = LCDQuestion(question="Set VideoTime", answers=vidTimeEngAnswers)
			answer_index = question.ask()
			p1.videoTime = vidTimeAnswers[answer_index]
			cad.lcd.clear()
			cad.lcd.write("Video Time\n{0}".format(vidTimeEngAnswers[answer_index]))
			time.sleep(1)
			p1.homeScreen()
		else:
			p1.inputTime = timeAnswers[answer_index]
			cad.lcd.write("Time selected: \n{0}".format(p1.inputTime))
			time.sleep(1)
			p1.homeScreen()
Exemple #3
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()
Exemple #4
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()
Exemple #5
0
 def askResolution(self, event):
     event.chip.lcd.set_cursor(0, 0)
     if event.pin_num == 1:
         cad.lcd.clear()
         # 			question = LCDQuestion(question="Set resolution", answers=["1920x1080", "2592x1944", "1296x972", "1296x972", "1296x730", "640x480"])
         question = LCDQuestion(question="Set resolution", answers=answers)
         print answers
         answer_index = question.ask()
         print answer_index
         cad.lcd.write("Resolution: " + str(answers[answer_index]))
Exemple #6
0
	def S4(self):
		cad.lcd.clear()
		#Sets framerate values based on chosen resolution, takes input from piface
		p1.determineFR()
		question = LCDQuestion(question="Set Framerate", answers=p1.TFanswers)
		answer_index = question.ask()
		cad.lcd.clear()
		#User feedback
		p1.inputFR = p1.TFanswers[answer_index]
		cad.lcd.write("FRate selected: \n{0}".format(p1.inputFR))
		time.sleep(1)
		p1.homeScreen()
Exemple #7
0
	def manualFRSelect(self):
		if p1.FRanswers == "Custom":
			question = LCDQuestion(question="Set num of frames", answers = customNumFramesAnswers)
			answer_index = question.ask()
			p1.numFrames = customNumFramesAnswers[answer_index]
			cad.lcd.clear()
			question = LCDQuestion(question="Set time interval", answers = customTimeIntervalAnswers)
			answer_index = question.ask()
			p1.timeInterval = customTimeIntervalAnswers[answer_index]
			cad.lcd.clear()
			cad.lcd.write("Selected framerate:\n{0} frames/{1} seconds".format(p1.numFrames, p1.timeInterval) )
			time.sleep(2)
			p1.homeScreen()
Exemple #8
0
	def manualFRSelect(self):
		if p1.inputFR == "Custom":
			question = LCDQuestion(question="Set numFrames", answers = customNumFramesAnswers)
			answer_index = question.ask()
			p1.numFrames = customNumFramesAnswers[answer_index]
			cad.lcd.clear()
			question = LCDQuestion(question="Set time (sec)", answers = customTimeIntervalAnswers)
			answer_index = question.ask()
			p1.timeInterval = customTimeIntervalAnswers[answer_index]
			cad.lcd.clear()
			cad.lcd.write("Selected framerate:\n{0} frames/{1} secs".format(p1.numFrames, p1.timeInterval) )
			p1.inputFPS = "{0}F/{1}S".format(p1.numFrames, p1.timeInterval)
			time.sleep(2)
			p1.homeScreen()
		else:
			pass
Exemple #9
0
	def S5(self):
		cad.lcd.clear()
		question = LCDQuestion(question="Choose cmd:", answers=exitAnswers)
		answers_index = question.ask()
		p1.exitAns = exitAnswers[answers_index]
		cad.lcd.clear()
		if p1.exitAns == "MPi exit prgm":
			question = LCDQuestion(question="MPi exit prgm?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Exiting program")
				time.sleep(1)
				cad.lcd.clear()
				end_barrier.wait()
			else:
				p1.homeScreen()
		elif p1.exitAns == "Restart":
			question = LCDQuestion(question="Restart?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Restarting")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sudo reboot")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Shutdown":
			question = LCDQuestion(question="Shutdown?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Shutting down")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sudo shutdown -h now")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Num file in fldr":
			numFiles = subprocess.check_output("ls -1 /home/pi/ivport/pictures/ | wc -l", shell=True)
			print (str(numFiles))
			cad.lcd.clear()
			cad.lcd.write("Num files:\n{0}".format(str(numFiles)))
			time.sleep(2)
			p1.homeScreen()
		elif p1.exitAns == "Clear mvFolder":
			os.system("rm -f /home/pi/ivport/pictures/*.jpg & rm -f /home/pi/ivport/pictures/*.h264")
			cad.lcd.clear()
			cad.lcd.write("Cleared folder")
			time.sleep(1)
			p1.homeScreen()
		else:
			p1.homeScreen()
Exemple #10
0
	def S4(self):
		cad.lcd.clear()
		#Sets fps values based on chosen resolution, takes input from piface
		p1.determineFPS()
		question = LCDQuestion(question="Set FPS", answers=p1.FPSanswers)
		answer_index = question.ask()
		cad.lcd.clear()
		p1.inputFPS = p1.FPSanswers[answer_index]
		#Only for camera mode:
		#Internally sets p1.numFrames and p1.timeInterval based on the chosen fps from the above options.  If p1.inputFPS is "Custom",
		# the user chooses fps options.  For camera, internal framerate is set through runCMD when the resolution is sent to the slavePies.
		p1.setCamFramesAndTime()
		p1.manualFpsSelect()
		#User feedback
		cad.lcd.write("FPS selected: \n{0}".format(p1.inputFPS))
		time.sleep(1)
		p1.homeScreen()
Exemple #11
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
Exemple #12
0
def askWhereToMove(event):
    global pieceSelected
    if (isStarted == True and pieceSelected == True):
        from pifacecad.tools.question import LCDQuestion
        question = LCDQuestion(question="Which Move",
                               answers=["Left", "Down", "Up", "Right"])
        answer_index = question.ask()
        try:
            string_index = str(answer_index)
            string_index = (string_index + str(0)).encode()
            s.sendto(string_index, (host, port))
            d = s.recvfrom(1024)
            reply = d[0]
            addr = d[1]
            if (struct.unpack('1B', reply[:1])[0] == 2):
                pieceSelected = False
        except (socket.error):
            sys.exit()
Exemple #13
0
	def S2(self):
		cad.lcd.clear()
		#Takes input from piface
		question = LCDQuestion(question="Set resolution", answers=resAnswers)
		answer_index = question.ask()
		#Parses answer into resW and resH
		resolutionStr = resAnswers[answer_index]
		resParse = str.split(resolutionStr, 'x')
		p1.resolutionW = resParse[0]
		p1.resolutionH = resParse[1]
		cad.lcd.clear()
		#User feedback
		cad.lcd.write("Res selected: \n{0}x{1}".format(p1.resolutionW, p1.resolutionH))
		time.sleep(1)
		cad.lcd.clear()
		cad.lcd.write("Check frmrate\n is correct")
		time.sleep(1)
		p1.homeScreen()
Exemple #14
0
def askWhichPiece(event):
    global pieceSelected
    if (isStarted == True and pieceSelected == False):
        from pifacecad.tools.question import LCDQuestion
        question = LCDQuestion(question="Select An Action",
                               answers=["Select", "GoRight", "GoLeft"])
        answer_index = question.ask()
        try:
            string_index = str(answer_index).encode()
            s.sendto(string_index, (host, port))
            d = s.recvfrom(1024)
            reply = d[0]
            addr = d[1]
            if (struct.unpack('1B', reply[:1])[0] == 1):
                pieceSelected = True
        except (socket.error):
            sys.exit()
    else:
        print(isStarted)
        print(pieceSelected)
Exemple #15
0
def askOther(event):
    global pieceSelected
    if (isStarted == True and pieceSelected == True):
        from pifacecad.tools.question import LCDQuestion
        question = LCDQuestion(question="Other Options",
                               answers=["Flip", "Rotate", "Go Back", "Place"])
        answer_index = question.ask()
        try:
            string_index = str(answer_index)
            string_index = (string_index + str(1)).encode()
            s.sendto(string_index, (host, port))
            d = s.recvfrom(1024)
            reply = d[0]
            addr = d[1]
            if (answer_index == 2):
                pieceSelected = False
            if (struct.unpack('1B', reply[:1])[0] == 2):
                pieceSelected = False
        except (socket.error):
            sys.exit()
Exemple #16
0
	def S1(self):
		cad.lcd.clear()
		question = LCDQuestion(question="VID/CAM or START:", answers=runMode)
		answer_index = question.ask()
		cad.lcd.clear()
		p1.inputRun = runMode[answer_index]
		#Execute os string
		if p1.inputRun == "START":
			cad.lcd.clear()
			cad.lcd.write("Running program")
			#Updates cmdStr with camera or vid inputs first before executing cmd
			p1.updateCMD()
			print (p1.cmdStr)
			if p1.updateCMD() == "":
				cad.lcd.clear()
				cad.lcd.write("No inputs given!")
			else:
				pass
#				os.system("{0}".format(p1.cmdStr))
		#Set string to video mode
		elif p1.inputRun == "VID":
			p1.currentMode = p1.inputRun
#			p1.fileName = "videoMode1.py"
			cad.lcd.clear()
			cad.lcd.write("Selected video\nCheck res")
			time.sleep(1)
			p1.homeScreen()
		#Set string to camera mode
		elif p1.inputRun == "CAM":
			p1.currentMode = p1.inputRun
#			p1.fileName = "manualPic2.py"
			#Sets up timeInterval to be 1 in preparation for selecting the fps
			p1.timeInterval = 1
			cad.lcd.clear()
			cad.lcd.write("Selected pictures\nCheck res")
			time.sleep(1)
			p1.homeScreen()
		#Returns to homescreen
		else:
			p1.homeScreen()
Exemple #17
0
	def S1(self):
		cad.lcd.clear()
		question = LCDQuestion(question="VID/CAM or START:", answers=runMode)
		answer_index = question.ask()
		cad.lcd.clear()
		p1.inputRun = runMode[answer_index]
		#Execute os string
		if p1.inputRun == "START":
			cad.lcd.clear()
			cad.lcd.write("Running program")
			#Updates cmdStr with camera or vid inputs first before executing cmd
			p1.updateCMD()
			print (p1.cmdStr)
			if p1.updateCMD() == "":
				cad.lcd.clear()
				cad.lcd.write("No inputs given!")
			else:
				os.system("{0}".format(p1.cmdStr))
				#Close program
#				end_barrier.wait()
		#Set string to video mode
		elif p1.inputRun == "VID":
			p1.currentMode = p1.inputRun
			p1.fileName = "videoMode1.py"
			cad.lcd.clear()
			cad.lcd.write("Selected video\nCheck time again")
			time.sleep(2)
			p1.homeScreen()
		#Set string to manual mode
		elif p1.inputRun == "CAM":
			p1.currentMode = p1.inputRun
			p1.fileName = "pictureCaptureIvport.py"
			cad.lcd.clear()
			cad.lcd.write("Selected pictures")
			time.sleep(1)
			p1.homeScreen()
		#Returns to homescreen
		else:
			p1.homeScreen()
Exemple #18
0
	def S2(self):
		cad.lcd.clear()
		#Takes input from piface
		# if p1.currentMode == "CAM":
		# 	resAnswers = camResAnswers
		# else:
		resAnswers = vidResAnswers
		question = LCDQuestion(question="Set resolution", answers=resAnswers)
		answer_index = question.ask()
		#Parses answer into resW and resH
		resolutionStr = resAnswers[answer_index]
		resParse = str.split(resolutionStr, 'x')
		self.resolutionW = resParse[0]
		self.resolutionH = resParse[1]
		cad.lcd.clear()
		#User feedback
		cad.lcd.write("Res selected: \n{0}x{1}".format(p1.resolutionW, p1.resolutionH))
		time.sleep(1)
		cad.lcd.clear()
		cad.lcd.write("Check frmrate\n is correct")
		time.sleep(1)
		p1.printResolutions()
Exemple #19
0
	def S1(self):
		cad.lcd.clear()
		question = LCDQuestion(question="VID/CAM or START:", answers=runMode)
		answer_index = question.ask()
		cad.lcd.clear()
		p1.inputRun = runMode[answer_index]
		#Execute os string
		if p1.inputRun == "START":
			cad.lcd.clear()
			cad.lcd.write("Running program")
			#Updates cmdStr with camera or vid inputs first before executing cmd
			p1.updateCMD()
			print p1.cmdStr
			if p1.updateCMD() == "":
				cad.lcd.clear()
				cad.lcd.write("No inputs given!")
			os.system("{0}".format(p1.cmdStr))
			time.sleep(1)
			p1.homeScreen()
		#Set string to video mode
		#TODO: DOUBLE CHECK .FORMAT TO ENSURE IT IS SENDING CORRECT PARAMETER TO THE FUNCTION
		elif p1.inputRun == "VID":
			p1.currentMode = p1.inputRun
			p1.fileName = "videoMode1.py"
			cad.lcd.clear()
			cad.lcd.write("Selected video\nCheck time again")
			time.sleep(2)
			p1.homeScreen()
		#Set string to manual mode
		elif p1.inputRun == "CAM":
			p1.currentMode = p1.inputRun
			p1.fileName = "manualPic.py"
			cad.lcd.clear()
			cad.lcd.write("Selected pictures")
			time.sleep(1)
			p1.homeScreen()
		#Returns to homescreen
		else:
			p1.homeScreen()
Exemple #20
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()
Exemple #21
0
import pifacecad
import time
import subprocess
import os,sys
import signal
from pifacecad.tools.question import LCDQuestion
from subprocess import call
cad = pifacecad.PiFaceCAD()
cd = os.path.dirname(os.path.realpath(sys.argv[0]))
dronekiller = "NotRunning"
hostapd_interface="wlan0"
hostapd_ipaddress="192.168.3.1"
musicdir = "~/Music/"
pifmfreq = "96.4"
while True:
    question = LCDQuestion(question="Option:", answers=["Services","Utilities","Shutdown","Reboot","Exit","Lock"])
    result = question.ask()
    if result == 0:
        # Services
        question = LCDQuestion(question="Service:", answers=["HOSTAPD","DNSMASQ","SAMBA", "Back"])
        result = question.ask()
        if result == 0:
            # Hostapd
            question = LCDQuestion(question="HOSTAPD Service", answers=["Start","Stop","Cancel"])
            result = question.ask()
            if result == 0:
                cad.lcd.clear()
                if dronekiller != "NotRunning":
                    cad.lcd.write("DroneKiller\nis running!")
                    time.sleep(2)
                else:
currencies = currencies.split(',')
currencies.remove('')

availableCurrecies = []
for x in currencies:
	if len(x) == 3:
		availableCurrecies.append(x)

# print(availableCurrecies)

# fromCurrency = availableCurrecies[int(input("Enter from Currency:"))]
# toCurrency = "GBP"
# amount = 2
cad.lcd.cursor_off()
cad.lcd.backlight_on()
question = LCDQuestion(question="Load presets", answers=["Yes","No"])
answer = question.ask()

if not answer:
	f = open('currencyPairs','r')
	currencyPairs =[]
	for line in f:
		line = line.replace("\n","")
		pair = line.split(" ")
		currencyPairs.append(pair)
	f.close()

	# currencyPairs = [["GBP","JPY"],["USD","GBP"],["USD","JPY"]]
	availableCurrecies = []
	for pair in currencyPairs:
		availableCurrecies.append(pair[0] + ">" + pair[1])
Exemple #23
0
cad = pifacecad.PiFaceCad()

cad.lcd.backlight_on()
#cad.lcd.write("hello")

#####xo = subprocess.check_output("wifi scan", shell=True).decode('utf-8')
xo = subprocess.check_output("iwlist wlan0 scanning  | grep ESSID", shell=True).decode('utf-8')
###cad.lcd.write(xo)
#print(xo)

ssids = []

for line in xo.split("\n"):
 ssid = line.split('\"')
 if ssid[0] != '': 
  #cad.lcd.write(ssid[1] + '\r') 
  ssids.append(ssid[1])
  #print(ssids)

print(ssids)
#>>> customcad = pifacecad.PiFaceCAD()
cad.lcd.cursor_off()
cad.lcd.blink_off()


question = LCDQuestion(question="Select WiFi net",answers=ssids,selector="#",cad=cad)
answer_index = question.ask()



Exemple #24
0
	def S5(self):
		cad.lcd.clear()
		question = LCDQuestion(question="Choose cmd:", answers=exitAnswers)
		answers_index = question.ask()
		p1.exitAns = exitAnswers[answers_index]
		cad.lcd.clear()
		if p1.exitAns == "MPi exit prgm":
			question = LCDQuestion(question="MPi exit prgm?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Exiting program")
				time.sleep(1)
				cad.lcd.clear()
				end_barrier.wait()
			else:
				p1.homeScreen()
		elif p1.exitAns == "MPi restart":
			question = LCDQuestion(question="Restart MPi?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Restarting MPi")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sudo reboot")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Shutdown all":
			question = LCDQuestion(question="Shutdown all?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Shutting down\nall")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo halt & sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo halt & \
				sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo halt & sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo halt")
				os.system("sudo shutdown -h now")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Reboot all":
			question = LCDQuestion(question="Reboot all?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Rebooting all")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo reboot & sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo reboot & \
					   sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo reboot & sshpass -p 'raspberry' ssh [email protected] -o StrictHostKeyChecking=no sudo reboot")
				os.system("sudo reboot")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Num file in fldr":
			numFiles = subprocess.check_output("ls -1 /home/pi/pastImages/ | wc -l", shell=True)
			print (str(numFiles))
			cad.lcd.clear()
			cad.lcd.write("Num files:\n{0}".format(str(numFiles)))
			time.sleep(2)
			p1.homeScreen()
		elif p1.exitAns == "Clear mvFolder":
			os.system("rm /home/pi/pastImages/*.jpg & rm /home/pi/pastImages/*.h264")
			cad.lcd.clear()
			cad.lcd.write("Cleared folder")
			time.sleep(1)
			p1.homeScreen()
		else:
			p1.homeScreen()
Exemple #25
0
	def setParameters(self, event):
		event.chip.lcd.set_cursor(0,0)
		#S2: SET RESOLUTION
		if event.pin_num == 1:
			cad.lcd.clear()
			#Takes input from piface
			question = LCDQuestion(question="Set resolution", answers=resAnswers)
			answer_index = question.ask()
			#Parses answer into resW and resH
			resolutionStr = resAnswers[answer_index]
			resParse = string.split(resolutionStr, 'x')
			p1.resolutionW = resParse[0]
			p1.resolutionH = resParse[1]
			cad.lcd.clear()
			#User feedback
			cad.lcd.write("Res selected: \n{0}x{1}".format(p1.resolutionW, p1.resolutionH))
			time.sleep(1)
			cad.lcd.clear()
			cad.lcd.write("Check frmrate\n is correct")
			time.sleep(1)
			cad.lcd.clear()
			p1.homeScreen()
		#S3: SET TIME
		#TODO: FIX TIME CHOICES TO APPROPRIATE VALUES
		if event.pin_num == 2:
			cad.lcd.clear()
			#Takes input
			question = LCDQuestion(question="Set time (mins)", answers=timeAnswers)
			answer_index = question.ask()
			cad.lcd.clear()
			#User feedback
			p1.inputTime = timeAnswers[answer_index]
			cad.lcd.write("Time selected: \n{0}".format(p1.inputTime))
			time.sleep(1)
			cad.lcd.clear()
			p1.homeScreen()
		#S4: SET TIMEFRAME
		if event.pin_num == 3:
			cad.lcd.clear()
			#Sets framerate values based on chosen resolution, takes input from piface
			p1.determineFR()
			question = LCDQuestion(question="Set Framerate", answers=p1.TFanswers)
			answer_index = question.ask()
			cad.lcd.clear()
			#User feedback
			p1.inputFR = p1.TFanswers[answer_index]
			cad.lcd.write("FRate selected: \n{0}".format(p1.inputFR))
			time.sleep(1)
			cad.lcd.clear()
			p1.homeScreen()
		#S1: SET CAMERA/VIDEO MODE OR START PROGRAM
		#TODO: Add error handling for video and camera options
		if event.pin_num == 0:
			cad.lcd.clear()
			question = LCDQuestion(question="VID/CAM or START:", answers=runMode)
			answer_index = question.ask()
			cad.lcd.clear()
			p1.inputRun = runMode[answer_index]
			#EXECUTE OS STRING
			#TO DO: NOT FUNCTIONAL
			if p1.inputRun == "START":
				cad.lcd.clear()
				cad.lcd.write("running program")
				os.system("{0}".format(p1.cmdStr))
				time.sleep(1)
				p1.homeScreen()
			#SET STRING TO VIDMODE
			#TODO: DOUBLE CHECK .FORMAT TO ENSURE IT IS SENDING CORRECT PARAMETER TO THE FUNCTION
			#TODO: MAKE FUNCTIONAL
			elif p1.inputRun == "VID":
				p1.currentMode = p1.inputRun
				p1.cmdStr = ("sshpass -p 'raspberry' ssh [email protected]:/home/pi/videoMode.py {0} {1} {2} {3} & sshpass -p 'raspberry' ssh [email protected]:/home/pi/videoMode.py {0} {1} {2} {3}\
					 & sshpass -p 'raspberry' ssh [email protected]:/home/pi/videoMode.py {0} {1} {2} {3} & sshpass -p 'raspberry' ssh [email protected]:/home/pi/videoMode.py {0} {1} {2} {3}\
					".format(p1.inputTime, p1.inputFR, p1.resolutionW, p1.resolutionH))
				print p1.cmdStr
				cad.lcd.clear()
				cad.lcd.write("Selected video")
				time.sleep(1)
				p1.homeScreen()
			#SET STRING TO MANUALPIC MODE
			#TODO: MAKE FUNCTIONAL
			elif p1.inputRun == "CAM":
				p1.currentMode = p1.inputRun
				print p1.cmdStr
				p1.cmdStr = ("sshpass -p 'raspberry' ssh [email protected]:/home/pi/manualPics.py {0} {1} {2} {3} & sshpass -p 'raspberry' ssh [email protected]:/home/pi/manualPics.py {0} {1} {2} {3}\
					 & sshpass -p 'raspberry' ssh [email protected]:/home/pi/manualPics.py {0} {1} {2} {3} & sshpass -p 'raspberry' ssh [email protected]:/home/pi/manualPics.py {0} {1} {2} {3}\
					".format(p1.inputTime, p1.resolutionW, p1.resolutionH, p1.inputFR))
				cad.lcd.clear()
				cad.lcd.write("Selected pictures")
				time.sleep(1)
				p1.homeScreen()
			#Returns to homescreen
			else:
				cad.lcd.clear()
				p1.homeScreen()
		#S5: SHUTDOWN BUTTON
		#TODO; NOT FUNCTIONAL
		if event.pin_num == 4:
			cad.lcd.clear()
#			os.system("sudo shutdown -h now")
			cad.lcd.write("Ending program")
			time.sleep(1)
			cad.lcd.clear()
Exemple #26
0
	def S5(self):
		cad.lcd.clear()
		question = LCDQuestion(question="Choose exit:", answers=exitAnswers)
		answers_index = question.ask()
		p1.exitAns = exitAnswers[answers_index]
		cad.lcd.clear()
		if p1.exitAns == "MPi exit prgm":
			question = LCDQuestion(question="MPi exit prgm?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Exiting program")
				time.sleep(1)
				cad.lcd.clear()
				end_barrier.wait()
				
			else:
				p1.homeScreen()
		elif p1.exitAns == "MPi restart":
			question = LCDQuestion(question="Restart MPi?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Restarting MPi")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sudo reboot")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Shutdown all":
			question = LCDQuestion(question="Shutdown all?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Shutting down\nall")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sshpass -p 'raspberry' ssh [email protected] sudo halt & sshpass -p 'raspberry' ssh [email protected] sudo halt & \
				sshpass -p 'raspberry' ssh [email protected] sudo halt & sshpass -p 'raspberry' ssh [email protected] sudo halt")
				os.system("sudo shutdown -h now")
			else:
				p1.homeScreen()
		elif p1.exitAns == "Reboot all":
			question = LCDQuestion(question="Reboot all?", answers=exitConfirm)
			answers_index = question.ask()
			p1.exitAns = exitConfirm[answers_index]
			if p1.exitAns == "Yes":
				cad.lcd.clear()
				cad.lcd.write("Rebooting all")
				time.sleep(1)
				cad.lcd.clear()
				os.system("sshpass -p 'raspberry' ssh [email protected] sudo reboot & sshpass -p 'raspberry' ssh [email protected] sudo reboot & \
				sshpass -p 'raspberry' ssh [email protected] sudo reboot & sshpass -p 'raspberry' ssh [email protected] sudo reboot")
				os.system("sudo reboot")
			else:
				p1.homeScreen()
		else:
			p1.homeScreen()
Exemple #27
0
			cad.lcd.set_cursor(position,0)
			cad.lcd.write("+")

		if cad.switches[0].value:
			# button pressed
			if position == 8:
				if not pressed:
					# pressed when over target
					pressed = 1
					score += 1
			else:
				# pressed when not over target
				gameOver = True
				break

	printString = "Game over, your score was: {score}".format(score=score)
	print(printString)
	cad.lcd.clear()
	cad.lcd.write("Game Over!")
	cad.lcd.set_cursor(0,1)
	cad.lcd.write("Your score: {score}".format(score=score))
	sleep(2)
	answers=["Yes","No"]
	question = LCDQuestion(question="Play again?", answers=answers)
	playing = question.ask()==answers.index("Yes")
	cad.lcd.clear()

cad.lcd.backlight_off()