]> wolfpit.net Git - hardware/fuck_tomatoes/.git/commitdiff
t
authorMichael Reeves <michaelreeves808@gmail.com>
Fri, 22 Feb 2019 12:43:31 +0000 (04:43 -0800)
committerMichael Reeves <michaelreeves808@gmail.com>
Fri, 22 Feb 2019 12:43:31 +0000 (04:43 -0800)
FuckTomato.py
Printer.py
Tests.py
User_Interface/__pycache__/MouseManager.cpython-37.pyc
__pycache__/Printer.cpython-37.pyc
utils/Gcode.py
utils/PrinterUtils.py
utils/__pycache__/Gcode.cpython-37.pyc
utils/__pycache__/PrinterUtils.cpython-37.pyc [new file with mode: 0644]

index 0d500382bfafda9c2214b42a7d736a70243cc3b9..2e5cbf9167def54848d6bb6150e79cf1e868134e 100644 (file)
@@ -1,6 +1,8 @@
-import cv2, sys, Printer
+import cv2, sys, Printer, time
 from User_Interface import Draw, MouseManager, Buttons
 
 from User_Interface import Draw, MouseManager, Buttons
 
+start_time = time.time()
+
 cap = cv2.VideoCapture(0)
 ret, frame = cap.read()
 cv2.namedWindow('image')
 cap = cv2.VideoCapture(0)
 ret, frame = cap.read()
 cv2.namedWindow('image')
@@ -12,7 +14,10 @@ while 1:
        Draw.drawImage(frame, printer)
        cv2.imshow('image', frame)
 
        Draw.drawImage(frame, printer)
        cv2.imshow('image', frame)
 
-       print(printer.packageIsExecuting())
+       if time.time() - start_time > 8:
+               res = printer.packageIsExecuting()
+               if not res:
+                       print(res)
        #if not printer.packageIsExecuting():
                # ...Detection and package send... #
                #After g-code package send, check for XY reset and update printer execution status
        #if not printer.packageIsExecuting():
                # ...Detection and package send... #
                #After g-code package send, check for XY reset and update printer execution status
index bd311c254c60f94c96eecaf724580aff93116094..690e984d84017c83368d1d7d738a795b99bceb47 100644 (file)
@@ -39,22 +39,21 @@ class Printer():
                self.writePoint(self.adjustXY(xy))
 
        def sendPackage(self, points):
                self.writePoint(self.adjustXY(xy))
 
        def sendPackage(self, points):
-               package = Gcode.buildGcodePackage(list(map(self.adjustXY, points)))
+               package = Gcode.buildGcodePackage(list(map(self.adjustXY, points)), (self.max_X, self.max_Y))
                self.writePackage(package)
 
        def packageIsExecuting(self):
                #Query the printer for position
                self.writePackage(package)
 
        def packageIsExecuting(self):
                #Query the printer for position
-               self.printerSerial.reset_input_buffer()
+               #self.printerSerial.reset_input_buffer()
                self.printerSerial.write('M114'.encode())
                printerData = ''
                while self.printerSerial.in_waiting > 0:
                        printerData += str(self.printerSerial.readline())
                self.printerSerial.write('M114'.encode())
                printerData = ''
                while self.printerSerial.in_waiting > 0:
                        printerData += str(self.printerSerial.readline())
-
                if 'Count' in printerData:
                if 'Count' in printerData:
-                       x, y = PrinterUtils.parsePrinterXY(printerData)
-                       if x == 0 and y == 0: return False
+                       headPosition = PrinterUtils.parsePrinterXY(printerData)
+                       return not PrinterUtils.isHomed(headPosition)
                return True
                return True
-               
+
        def raiseZ(self):
                self.printerSerial.write('G0 F5000 Z50\n'.encode())
        
        def raiseZ(self):
                self.printerSerial.write('G0 F5000 Z50\n'.encode())
        
index d85e5f5c5d62df10b90b693235aa881fab5f376d..22d289af98456a3f86794a36a3b16c9211593fd9 100644 (file)
--- a/Tests.py
+++ b/Tests.py
@@ -1,18 +1,23 @@
 import Printer, time
 import Printer, time
+from utils import Gcode
 
 testPoints = [
 
 testPoints = [
-(176, 204),
-(306, 208),
-(354, 159),
-(218, 134),
-(277, 126),
-(335, 126),
-(246, 189)
+    (176, 204),
+    (306, 208),
+    (176, 204) 
 ]
 
 ]
 
+start_time = time.time()
 p = Printer.Printer('COM4', (200,200))
 p = Printer.Printer('COM4', (200,200))
-time.sleep(8)
 
 
+cum = False
 while 1:
 while 1:
-    res = p.packageIsExecuting()
-    
\ No newline at end of file
+    if time.time() - start_time > 8:
+        if not cum:
+            cum = True
+            p.sendPackage(testPoints)
+            
+        res = p.packageIsExecuting()
+        if not res:
+            print('Is HOmed: ' + str(time.time()))
+            p.sendPackage(testPoints)
index 5f041938116134f121d36eed1e71e7cd5e5404dc..f974c41f6334032236aac7f1c9a2f65c92358e80 100644 (file)
Binary files a/User_Interface/__pycache__/MouseManager.cpython-37.pyc and b/User_Interface/__pycache__/MouseManager.cpython-37.pyc differ
index ba14e9b19275b72b58f4241c581f4e622d78c62e..04190197d6391dc79cf887c6b858f24bd25405aa 100644 (file)
Binary files a/__pycache__/Printer.cpython-37.pyc and b/__pycache__/Printer.cpython-37.pyc differ
index 4c4a01ae50d5c85c904dfb84f2a095d93931f308..8f88f1979dbb9862fd5bcb0b08f9546abaff73a0 100644 (file)
@@ -1,11 +1,11 @@
 from utils import Geometry
 
 from utils import Geometry
 
-def buildGcodePackage(points):
-               package = ''
+def buildGcodePackage(points, xyMax):
+               package = 'G0 F5000\n'
                for point in points:
                for point in points:
-                       if Geometry.pointWithinBounds(point):
+                       if Geometry.pointWithinBounds(point, xyMax):
                                x,y = point
                                x,y = point
-                               package += 'G0 F5000 X{:.3f} Y{:.3f}\n'.format(x, y)
+                               package += 'G0 X{:.3f} Y{:.3f}\n'.format(x, y)
                                package += 'M106 S300\nG4 P500\nM107\n'
                package += 'G0 F5000 X0 Y0\n'
                return package
\ No newline at end of file
                                package += 'M106 S300\nG4 P500\nM107\n'
                package += 'G0 F5000 X0 Y0\n'
                return package
\ No newline at end of file
index a0a3c0dd929ca92d0af96ee9d076b965a8490a95..f4328096ad6fd8dd177556a448a6c19413a6d431 100644 (file)
@@ -1,5 +1,9 @@
 
 def parsePrinterXY(printerData):
     xy = printerData.split('Count')[1].split('Z')[0].strip().replace('Y:', '').split(' ')[1:]
 
 def parsePrinterXY(printerData):
     xy = printerData.split('Count')[1].split('Z')[0].strip().replace('Y:', '').split(' ')[1:]
-    return (xy[0], xy[1])
-        
\ No newline at end of file
+    return (float(xy[0]), float(xy[1]))
+        
+def isHomed(xy):
+    x, y = xy
+    tolerence = 0.03
+    return x <= tolerence and x >= -tolerence and y <= tolerence and y >= -tolerence
\ No newline at end of file
index 31b7b8e73a250f398277c858944cc0076b930a54..7009844eebe72e5a025546707f85e73cf61e93d0 100644 (file)
Binary files a/utils/__pycache__/Gcode.cpython-37.pyc and b/utils/__pycache__/Gcode.cpython-37.pyc differ
diff --git a/utils/__pycache__/PrinterUtils.cpython-37.pyc b/utils/__pycache__/PrinterUtils.cpython-37.pyc
new file mode 100644 (file)
index 0000000..15a2c22
Binary files /dev/null and b/utils/__pycache__/PrinterUtils.cpython-37.pyc differ