Пример #1
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()
Пример #2
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()
Пример #3
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)
Пример #4
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()