def buildGcodePackage(points, xyMax, withSpike): package = 'G0 F10000\n' #Set printer head speed for point in points: if Geometry.pointWithinBounds(point, xyMax): x, y = point package += 'G0 X{:.1f} Y{:.1f}\n'.format(x, y) #Positioning format #Pnumatic trigger on/off if withSpike: package += 'M106 S300\n' package += 'G4 P100\n' if withSpike: package += 'M107\n' package += 'G0 X0 Y0\n' return package
def writePoint(self, xy): x, y = xy x = self.max_X - x self.position = xy command = 'G0 F5000 X%d Y%d\n' % ( x, y) + 'G4 P1000\n' + 'G0 F5000 X0 Y0\n' if self.printerSerial is not None and Geometry.pointWithinBounds( xy, (self.max_X, self.max_Y)): self.printerSerial.write(command.encode()) return 1 else: return 0