Пример #1
0
 def __init__(self):
     self.power = True
     self.sudoku = np.zeros((9, 9), int)
     self.Write = write.Write()
     self.Server = server.Server(self)
     self.MotorControl = stp.MotorControl()
     self.MotorControl.start()
     os.chdir("/home/pi/Desktop/Sudoku-Plotter/script/lcd")
     lcd3.write("Sudoku Plotter Welcome!")
Пример #2
0
 def writeSudoku(self, sudoku):
     try:
         self.sudoku = sudoku
         print(sudoku)
         lcd3.write("Initialisation of the position")
         self.MotorControl.initializePosition()
         lcd3.write("Sudoku writing in progress...")
         self.MotorControl.points = []
         self.MotorControl.convertPoints(self.Write.writeSudoku(sudoku))
     except KeyboardInterrupt:
         self.stop()
Пример #3
0
 def setPenPosition(self, text):
     lcd3.write("Sudokku Plotter position set")
     if not self.MotorControl.getPoints():
         self.MotorControl.points = [text]
Пример #4
0
 def starting(self):
     self.mySocket.listen(5)
     connexion, adresse = self.mySocket.accept()
     lcd3.write("connected to  ip " + str(adresse[0]))
     while self.power:
         try:
             text = connexion.recv(1024).decode()
             if not text:
                 self.starting()
             elif text == "reboot":
                 lcd3.write("Sudoku Plotter rebooting...")
                 connexion.send("raspi_reboot".encode())
                 os.system("reboot")
             elif text == "shutdown":
                 lcd3.write("Sudoku Plotter Goodbye!")
                 connexion.send("raspi_shutdown".encode())
                 self.boss.stop()
                 os.system("sudo shutdown -h now")
             elif text == "photo":
                 lcd3.write("a photo was taken")
                 self.boss.takePhoto()
                 sudoku = save.readSudoku(
                     "/home/pi/Desktop/Sudoku-Plotter/sudoku/Sudoku.txt")
                 sudoku_string = save.sudokuToString(sudoku)
                 connexion.send(sudoku_string.encode())
             elif text == "stop":
                 lcd3.write("Sudoku writing process stopped!")
                 connexion.send("raspi_stop".encode())
                 self.boss.sleep()
             elif text == "up" or text == "down":
                 connexion.send(text.encode())
                 self.boss.setPenPosition(text)
             else:
                 try:
                     self.sudoku = save.stringToSudoku(text)
                     connexion.send("sudoku_received".encode())
                     self.boss.writeSudoku(self.sudoku)
                 except IndexError or ValueError:
                     self.sudoku = np.zeros((9, 9), int)
         except ConnectionAbortedError or ConnectionResetError:
             lcd3.write("Client disconnected")
             self.starting()
         time.sleep(0.1)
Пример #5
0
 def tryConnect(self):
     try:
         self.mySocket.bind((self.host, self.port))
     except socket.error:
         lcd3.write("Connection failed")
         sys.exit()