def main(port, baud): print >> sys.stderr, "Attemping to print at {0} with baud {1}\n\n".format( port, baud) p = printcore(port, baud) p.loud = True time.sleep(2) print >> sys.stderr, "###", "Building gcode stream..." setup_codes = [ "G28", # home "G0 X100 Y100", "M116", # wait "G28", "M18", # stfu "M21", # init sd card "M28 vppjob.gco", # begin write ] job_codes = [line.strip() for line in sys.stdin.readlines()] teardown_codes = [ "M116", "M29", # stop writing to sd card #"M23 vppjob.gco", # select job "M24", # start print ] print >> sys.stderr, "###", "Sending Gcode stream to printer..." p.startprint(setup_codes + job_codes + teardown_codes) print >> sys.stderr, "###", "Done printing!"
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey=None self.p=printcore.printcore() self.p.recvcb=self.recvcb self.recvlisteners=[] self.prompt="PC>" self.p.onlinecb=self.online self.f=None self.listing=0 self.sdfiles=[] self.paused=False self.sdprinting=0 self.temps={"pla":"185","abs":"230","off":"0"} self.bedtemps={"pla":"60","abs":"110","off":"0"} self.percentdone=0 self.tempreadings="" self.macros={} self.rc_loaded=False self.processing_rc=False self.processing_args=False self.settings = Settings() self.settings._port_list = self.scanserial self.settings._temperature_abs_cb = self.set_temp_preset self.settings._temperature_pla_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset self.monitoring=0
def __init__(self, config): super(printcoredriver, self).__init__(config) self.p = printcore.printcore() self.p.loud = False time.sleep(2) self.log = logging.getLogger('botqueue')
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey=None self.p=printcore.printcore() self.p.recvcb=self.recvcb self.recvlisteners=[] self.prompt="PC>" self.p.onlinecb=self.online self.f=None self.listing=0 self.sdfiles=[] self.paused=False self.sdprinting=0 self.temps={"pla":"210","abs":"230","off":"0"} self.bedtemps={"pla":"60","abs":"110","off":"0"} self.percentdone=0 self.tempreadings="" self.macros={} self.processing_rc=False self.lastport = (None,None) self.monitoring=0 self.feedxy=3000 self.feedz=200 self.feede=300
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey = None self.p = printcore.printcore() self.p.recvcb = self.recvcb self.recvlisteners = [] self.prompt = "PC>" self.p.onlinecb = self.online self.f = None self.listing = 0 self.sdfiles = [] self.paused = False self.sdprinting = 0 self.temps = {"pla": "185", "abs": "230", "off": "0"} self.bedtemps = {"pla": "60", "abs": "110", "off": "0"} self.percentdone = 0 self.tempreadings = "" self.macros = {} self.rc_loaded = False self.processing_rc = False self.processing_args = False self.settings = Settings() self.settings._port_list = self.scanserial self.settings._temperature_abs_cb = self.set_temp_preset self.settings._temperature_pla_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset self.monitoring = 0
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey = None self.p = printcore.printcore() self.p.recvcb = self.recvcb self.recvlisteners = [] self.prompt = "PC>" self.p.onlinecb = self.online self.f = None self.listing = 0 self.sdfiles = [] self.paused = False self.sdprinting = 0 self.temps = {"pla": "185", "abs": "230", "off": "0"} self.bedtemps = {"pla": "60", "abs": "110", "off": "0"} self.percentdone = 0 self.tempreadings = "" self.macros = {} self.rc_loaded = False self.processing_rc = False self.processing_args = False self.settings = Settings() self.settings._port_list = self.scanserial self.settings._temperature_abs_cb = self.set_temp_preset self.settings._temperature_pla_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset self.monitoring = 0 self.helpdict = {} self.helpdict["baudrate"] = _("Communications Speed (default: 115200)") self.helpdict["bedtemp_abs"] = _( "Heated Build Platform temp for ABS (default: 110 deg C)") self.helpdict["bedtemp_pla"] = _( "Heated Build Platform temp for PLA (default: 60 deg C)") self.helpdict["e_feedrate"] = _( "Feedrate for Control Panel Moves in Extrusions (default: 300mm/min)" ) self.helpdict["port"] = _("Port used to communicate with printer") self.helpdict["slicecommand"] = _( "Slice command\n default:\n python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)" ) self.helpdict["sliceoptscommand"] = _( "Slice settings command\n default:\n python skeinforge/skeinforge_application/skeinforge.py" ) self.helpdict["temperature_abs"] = _( "Extruder temp for ABS (default: 230 deg C)") self.helpdict["temperature_pla"] = _( "Extruder temp for PLA (default: 185 deg C)") self.helpdict["xy_feedrate"] = _( "Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)" ) self.helpdict["z_feedrate"] = _( "Feedrate for Control Panel Moves in Z (default: 200mm/min)") self.helpdict["final_command"] = _( "Executable to run when the print is finished") self.commandprefixes = 'MGT$'
def __init__(self): # Core printer object self.printcore = printcore() # Statuses self.connected = False self.printing = False # Keep track of xyz position, since the RepRap apparently doesn't # make this easy to access self.xyz = False
def connect(tty, baud): global p, h p = printcore.printcore(tty, baud, True) h = MyHandler() p.event_handler.append(h) while not p.online: print('not online, reset()...') p.reset() time.sleep(3) if p.online: print('online') return p
def startPrint(self, jobfile): self.p = printcore.printcore() self.p.loud = False try: self.printing=True self.connect() while not self.isConnected(): time.sleep(1) self.log.debug("Waiting for driver to connect.") self.p.startprint(jobfile.localFile) self.printThread = Thread(target=self.printThreadEntry).start() except Exception as ex: self.log.error("Error starting print: %s" % ex) self.disconnect() raise ex
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey = None self.p = printcore.printcore() self.p.recvcb = self.recvcb self.recvlisteners = [] self.prompt = "PC>" self.p.onlinecb = self.online self.f = None self.listing = 0 self.sdfiles = [] self.paused = False self.sdprinting = 0 self.temps = {"pla":"185", "abs":"230", "off":"0"} self.bedtemps = {"pla":"60", "abs":"110", "off":"0"} self.percentdone = 0 self.tempreadings = "" self.macros = {} self.rc_loaded = False self.processing_rc = False self.processing_args = False self.settings = Settings() self.settings._port_list = self.scanserial self.settings._temperature_abs_cb = self.set_temp_preset self.settings._temperature_pla_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset self.settings.sliceconfig = "" self.monitoring = 0 self.helpdict = {} self.helpdict["baudrate"] = _("Communications Speed (default: 115200)") self.helpdict["bedtemp_abs"] = _("Heated Build Platform temp for ABS (default: 110 deg C)") self.helpdict["bedtemp_pla"] = _("Heated Build Platform temp for PLA (default: 60 deg C)") self.helpdict["e_feedrate"] = _("Feedrate for Control Panel Moves in Extrusions (default: 300mm/min)") self.helpdict["port"] = _("Port used to communicate with printer") self.helpdict["slicecommand"] = _("Slice command\n default:\n python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)") self.helpdict["sliceoptscommand"] = _("Slice settings command\n default:\n python skeinforge/skeinforge_application/skeinforge.py") self.helpdict["temperature_abs"] = _("Extruder temp for ABS (default: 230 deg C)") self.helpdict["temperature_pla"] = _("Extruder temp for PLA (default: 185 deg C)") self.helpdict["xy_feedrate"] = _("Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)") self.helpdict["z_feedrate"] = _("Feedrate for Control Panel Moves in Z (default: 200mm/min)") self.helpdict["final_command"] = _("Executable to run when the print is finished") self.commandprefixes='MGT$' self.webrequested = False self.web_config = None self.web_auth_config = None
def __init__(self): cmd.Cmd.__init__(self) if not READLINE: self.completekey = None self.p = printcore.printcore() self.p.recvcb = self.recvcb self.recvlisteners = [] self.prompt = "PC>" self.p.onlinecb = self.online self.f = None self.listing = 0 self.sdfiles = [] self.paused = False self.sdprinting = 0 self.temps = {"pla":"185", "abs":"230", "off":"0"} self.bedtemps = {"pla":"60", "abs":"110", "off":"0"} self.percentdone = 0 self.tempreadings = "" self.macros = {} self.rc_loaded = False self.processing_rc = False self.processing_args = False self.settings = Settings() self.settings._port_list = self.scanserial self.settings._temperature_abs_cb = self.set_temp_preset self.settings._temperature_pla_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset self.monitoring = 0 self.helpdict = {} self.helpdict["baudrate"] = _("Скорость соединения (по умолчанию: 115200)") self.helpdict["bedtemp_abs"] = _("Нагрев стола для ABS (по умолчанию: 110 град. Цельсия)") self.helpdict["bedtemp_pla"] = _("Нагрев стола для PLA (по умолчанию: 60 град. Цельсия)") self.helpdict["e_feedrate"] = _("Скорость подачи пластика в экструдер (по умолчанию: 300 мм/мин)") self.helpdict["port"] = _("Порт, использующийся для соединения с принтером") self.helpdict["slicecommand"] = _("Slice command\n default:\n python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)") self.helpdict["sliceoptscommand"] = _("Slice settings command\n default:\n python skeinforge/skeinforge_application/skeinforge.py") self.helpdict["temperature_abs"] = _("Температура экструдера для ABS (по умолчанию: 230 град. Цельсия)") self.helpdict["temperature_pla"] = _("Температура экструдера для PLA (по умолчанию: 185 град. Цельсия)") self.helpdict["xy_feedrate"] = _("Скорость перемещения по X и Y (по умолчанию: 3000 мм/мин)") self.helpdict["z_feedrate"] = _("Скорость перемещения по Z (по умолчанию: 200 мм/мин)") self.helpdict["final_command"] = _("Команда, запускающаяся, когда печать закончена") self.commandprefixes='MGT$' self.webrequested = False self.web_config = None self.web_auth_config = None
def __init__(self, port="/dev/ttyACM0", baud=115200): self.p = printcore.printcore() self.p.connect(port, baud) self.camerapos = (300, 300) self.downcam = usbcam(0) self.upcam = rpicam() self.pumpon = 0 self.defaulth = 42 self.camoffset = (15.3, 40.1) self.pinoffset = (0, 0) self.blcomp = 0.5 self.upcamrot = 90 self.upcamillum = 127 self.camrot = 77 self.camstep = 111 self.parts = {} self.parts["0603"] = part("0603", (1.6, 0.8, 0.5))
def __init__(self, master=None): self.master = master Frame.__init__(self, master, relief=SUNKEN, bd=2) self.gcode = [] self.slicing = False self.printing = False self.connected = False self.monitorTemp = False self.paused = False self.sdpresent = False self.sdlisting = False self.sdchecking = False self.sdprinting = False self.sdpaused = False self.sduploading = False self.sdbytes = 0 self.sdmaxbytes = 0 self.insidelisting = False self.readingFirmware = False self.sdfiles = [] self.bedtemp = float(0) self.bedtarget = float(0) self.exttemp = float(0) self.exttarget = float(0) self.acceleration = 0 self.m114count = 0 self.speedcount = 0 self.location = [0, 0, 0, 0] self.pausePoint = [0, 0, 0, 0] self.percent = 0.0 self.ets = "??" self.gcodeInfo = None self.GCodeFile = None self.StlFile = None self.Profile = None self.printStartLine = 0 self.startTime = 0 self.endTime = 0 self.elapsedTime = 0 self.FanSpeed = 0 self.FeedMultiply = 100 self.ExtrudeMultiply = 100 self.timingReport = None self.filamentReport = None self.measurementsReport = None self.macroButtons = None self.rpt1re = re.compile(" *T:([0-9\.]+) *E:[0-9\.]+ *B:([0-9\.]+)") self.rpt2re = re.compile(" *T:([0-9\.]+) *E:[0-9\.]+ *W:.*") self.locrptre = re.compile("^X:([0-9\.\-]+)Y:([0-9\.\-]+)Z:([0-9\.\-]+)E:([0-9\.\-]+) *Count") self.speedrptre = re.compile("Fan speed:([0-9]+) Feed Multiply:([0-9]+) Extrude Multiply:([0-9]+)") self.sdre = re.compile("SD printing byte *([0-9]+) *\/ *([0-9]+)") self.printer = printcore() self.settings = Settings() self.settings.cmdFolder = cmd_folder self.logger = Logger(self) if self.settings.speedcommand is not None: allow_while_printing.append(self.settings.speedcommand) self.acceleration = self.settings.acceleration self.dataLoggers = {} for d in DLLIST: self.dataLoggers[d] = DataLogger(self, d) self.skeinforge = Skeinforge(self.settings) self.slic3r = Slic3r(self.settings) self.httpServer = RepRapServer(self, self.printer, self.settings, self.logger, self.settings.port) self.menubar = Menu(self) self.filemenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="File", menu=self.filemenu) self.filemenu.add_command(label="Slice", command=self.openSTLFile) self.filemenu.add_command(label="Load GCode", command=self.openGCodeFile) self.slicemenuindex = self.filemenu.index("Slice") self.loadgcodemenuindex = self.filemenu.index("Load GCode") self.filemenu.add_separator() self.filemenu.add_command(label="Exit", command=self.quitApp) self.editmenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="Edit", menu=self.editmenu) self.editmenu.add_command(label="Settings", command=self.editSettings) self.editmenu.add_command(label="Firmware Settings", command=self.FirmwareSettings) self.editmenu.add_separator() self.editmenu.add_command(label=GCODE_MENU_TEXT, command=self.doGEdit, state=DISABLED) self.slicermenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="Slicer", menu=self.slicermenu) self.rbSlicer = StringVar() self.slicermenu.add_radiobutton( label="Skeinforge", command=self.selSlicer, value=SKEINFORGE, variable=self.rbSlicer ) self.slicermenu.add_command(label="Settings", command=self.skeinforgeSettings) self.slicermenu.add_command(label="Choose Profile", command=self.chooseSFProfile) self.SFprofileindex = self.slicermenu.index("Choose Profile") self.setSFProfileMenuText() self.slicermenu.add_command(label="Alterations", command=self.doEditAlterations) self.slicermenu.add_separator() self.slicermenu.add_radiobutton(label="Slic3r", command=self.selSlicer, value=SLIC3R, variable=self.rbSlicer) self.slicermenu.add_command(label="Settings", command=self.slic3rSettings) self.slicermenu.add_command(label="Choose Profile", command=self.chooseS3Profile) self.S3profileindex = self.slicermenu.index("Choose Profile") self.setS3ProfileMenuText() self.rbSlicer.set(self.settings.slicer) self.macromenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="Macros", menu=self.macromenu) self.macromenu.add_command(label="New", command=self.doNewMacro) self.macromenu.add_command(label="Edit", command=self.doEditMacro) self.macromenu.add_command(label="Delete", command=self.doDelMacro) self.macromenu.add_separator() self.cbShowMacroButtons = BooleanVar() self.cbShowMacroButtons.set(self.settings.showmacrobuttons) self.macromenu.add_checkbutton( label="Show Macro Buttons", command=self.doShowButtons, onvalue=True, offvalue=False, variable=self.cbShowMacroButtons, ) self.macromenu.add_separator() self.runmacromenu = Menu(self.macromenu, tearoff=0) self.loadMacros() self.macromenu.add_cascade(label="Run", menu=self.runmacromenu) self.reportmenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="View", menu=self.reportmenu) self.cbShowPrevious = BooleanVar() self.cbShowPrevious.set(self.settings.showprevious) self.reportmenu.add_checkbutton( label="Show Previous Layer", command=self.toggleShowPrevious, onvalue=True, offvalue=False, variable=self.cbShowPrevious, ) self.cbShowMoves = BooleanVar() self.cbShowMoves.set(self.settings.showmoves) self.reportmenu.add_checkbutton( label="Show Non-extrusion Moves", command=self.toggleShowMoves, onvalue=True, offvalue=False, variable=self.cbShowMoves, ) self.reportmenu.add_separator() self.reportmenu.add_command(label="Show Hours of Usage", command=self.doDataLogReport) self.reportmenu.add_command(label="Reset Hours of Usage", command=self.doDataLogReset) self.reportmenu.add_separator() self.reportmenu.add_command(label="Layer by Layer Timing", command=self.doTimingReport) self.reportmenu.add_command(label="Layer by Layer Filament Usage", command=self.doFilamentReport) self.reportmenu.add_command(label="GCode Measurements", command=self.doMeasurementsReport) self.toolsmenu = Menu(self.menubar, tearoff=0) n = 0 if self.settings.platercmd is not None: n += 1 self.toolsmenu.add_command(label="Plater", command=self.doPlater) if self.settings.gcodeviewcmd is not None: n += 1 self.toolsmenu.add_command(label="GCode Viewer", command=self.doGCodeView) if self.settings.stlviewcmd is not None: n += 1 self.toolsmenu.add_command(label="STL Viewer", command=self.doSTLView) if self.settings.openscadcmd is not None: n += 1 self.toolsmenu.add_command(label="OpenSCAD", command=self.doOpenSCAD) if n > 0: self.menubar.add_cascade(label="Tools", menu=self.toolsmenu) try: self.master.config(menu=self.menubar) except AttributeError: self.master.tk.call(master, "config", "-menu", self.menubar) self.toolbar = ToolBar(self, self.printer, self.settings, self.logger) self.toolbar.grid(row=1, column=1, columnspan=4, sticky=W) self.ctl = MoveControl(self, self.printer, self.settings, self.logger) self.ctl.grid(row=2, column=1, rowspan=3, sticky=N) self.extr = Extruder(self, self.printer, self.settings, self.logger) self.extr.grid(row=2, column=2, rowspan=1, sticky=N + E + W) self.temps = Temperatures(self, self.printer, self.settings, self.logger) self.temps.grid(row=3, column=2, rowspan=2, sticky=N + E + W) self.gc = GcFrame(self, None, [], self.settings, self.logger) self.gc.grid(row=2, column=3, rowspan=3, sticky=N) self.statline = Status(self, self.printer, self.settings, self.logger) self.statline.grid(row=5, column=1, columnspan=4, sticky=E + W) self.logger.grid(row=2, column=4, rowspan=2, sticky=N + E + W) self.sendgcode = SendGCode(self, self.printer, self.settings, self.logger) self.sendgcode.grid(row=4, column=4, sticky=N + E + W) self.printer.errorcb = self.errorcb self.printer.sendcb = self.sendcb self.printer.recvcb = self.recvcb self.sd = SDCard(self, self.printer, self.settings, self.logger) self.firmware = FirmwareParms(self, self.printer, self.settings, self.logger) self.bind(MWM_FIRMWARECOMPLETE, self.firmwareReportComplete) self.bind(MWM_SLICERCOMPLETE, self.sliceComplete) self.bind(MWM_GCODELOADCOMPLETE, self.loadgcodeFinished) self.bind(MWM_GEDITMEASURECOMPLETE, self.geditMeasureComplete) self.bind(MWM_REQUESTPOSITIONREPORT, self.requestPosition) self.doShowButtons()
stop = 0 def grabimg(): global img global flag stream = cv2.VideoCapture(0) while (not stop): i = stream.read() if i[0] and flag: img = i[1] flag = 0 stream.release() p = printcore.printcore() p.loud = True threading.Thread(target=grabimg).start() p.connect(port="/dev/ttyACM0", baud=115200) for i in xrange(10): if (p.online): break time.sleep(1) print("printer online") time.sleep(2) x = 260 y = 210 try: p.send_now("G28") p.send_now("G1 X200 Y150 F15000") p.send_now("M400")
parser.add_option("", "--tilt_speed", dest="tilt_speed", default=300, help="Z Tilt Distance (Default 300mm/min)") parser.add_option("", "--tilt_hold_ms", dest="tilt_hold_ms", default=500, help="ms to wait between each z move") (options, args) = parser.parse_args() if options.printfile == None: sys.exit("Missing an Input File!") printerSerial = printcore.printcore() if options.simulate == False: print "Connecting to printer... (Port: ", options.port, " Baud: ", options.baud, ")" printerSerial.connect(options.port, options.baud) if options.stl and options.slic3r_path != None: #Generate SVG File from Slic3r cmd = options.slic3r_path + " --export-svg --layer-height " + str( options.layer_height) + " --first-layer-height " + str( options.layer_height) + " " + options.printfile svg_file = options.printfile.replace(".stl", ".svg") svg_file = svg_file.replace(".STL", ".svg") if os.name == "nt": subprocess.call(cmd) else:
pixels.append(y/12.5) a = np.array(pixels, np.float32).reshape(-1,2) b = np.array(tool_position, np.float32).reshape(-1,2) if clicks > 3: H,matches = cv2.findHomography(a, b, cv2.RANSAC) print H xrob = uniform(250,280) yrob = uniform(25,45) command = 'G1 X%d Y%d F10000' % (xrob,yrob) p.send_now(command) tool_position.append(xrob) tool_position.append(yrob) import printcore p=printcore.printcore("/dev/tty.usbserial-A4008eY6",115200) time.sleep(5) p.send_now("M43 P1 S50") time.sleep(5) p.send_now("G28") #homing time.sleep(5) capture=cv.CaptureFromCAM(1) image=cv.QueryFrame(capture) intrinsic = cv.Load("../CamCalibration/Intrinsics.xml") distortion = cv.Load("../CamCalibration/Distortion.xml") mapx = cv.CreateImage( cv.GetSize(image), cv.IPL_DEPTH_32F, 1 ); mapy = cv.CreateImage( cv.GetSize(image), cv.IPL_DEPTH_32F, 1 );
def __init__(self, parent): wx.Frame.__init__(self, parent, -1, 'CEIT Fabrication Manager', (100,100), (1050, 300)) panel = wx.Panel(self) gridPanel = wx.Panel(panel) self.grid = grid.Grid(gridPanel) self.grid.SetRowLabelSize(0) self.grid.CreateGrid(10, 8) self.grid.EnableEditing(False) self.grid.SetSelectionMode(1) self.grid.EnableScrolling(True, True) self.grid.SetColLabelValue(0, 'Name') self.grid.SetColLabelValue(1, 'Time(min)') self.grid.SetColLabelValue(2, 'Filament (m)') self.grid.SetColLabelValue(3, 'Filament (g)') self.grid.SetColLabelValue(4, 'Material') self.grid.SetColLabelValue(5, 'Cost') self.grid.SetColLabelValue(6, 'Owner') self.grid.SetColLabelValue(7, 'ID') self.grid.AutoSize() sb = wx.StaticBox(gridPanel, label='Jobs:') boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) boxsizer.Add(self.grid, flag=wx.EXPAND) gridPanel.SetSizer(boxsizer) controlPanel = wx.Panel(panel) self.printButton = wx.Button(controlPanel, -1, '&Print',) self.cancelButton = wx.Button(controlPanel, -1, '&Cancel') self.deleteButton = wx.Button(controlPanel, -1, '&Delete') self.Bind(wx.EVT_BUTTON, self.OnPrint, self.printButton) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancelButton) self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton) sb = wx.StaticBox(controlPanel, label='Controls:') boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) boxsizer.Add(self.printButton, flag=wx.EXPAND) boxsizer.Add(self.cancelButton, flag=wx.EXPAND) boxsizer.Add(self.deleteButton, flag=wx.EXPAND) controlPanel.SetSizer(boxsizer) infoPanel = wx.Panel(panel) self.status = wx.StaticText(infoPanel, -1, 'Idle') font = wx.Font(15, wx.SWISS, wx.NORMAL, wx.NORMAL) self.status.SetFont(font) self.status.SetForegroundColour('dark green') self.progressGauge = wx.Gauge(infoPanel, -1) self.progressGauge.SetRange(100) self.timeleft = wx.StaticText(infoPanel, -1, 'Remaining: 00:00') sb = wx.StaticBox(infoPanel, label='Status:') boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) boxsizer.Add(self.status) boxsizer.Add(self.progressGauge) boxsizer.Add(self.timeleft) infoPanel.SetSizer(boxsizer) sizer = wx.GridBagSizer() sizer.Add(controlPanel, (0,1), span=(1,1), flag=wx.EXPAND) sizer.Add(infoPanel, (1,1), span=(1,1)) sizer.Add(gridPanel, (0,3), span=(2,1), flag=wx.EXPAND) panel.SetSizer(sizer) self.ultipath = os.path.split(os.path.abspath(__file__))[0] self.ultipath = self.ultipath[:self.ultipath.rfind('/')+1] self.joblist = [] self.printnum = None self.progress = 0 self.stage = 'Idle' self.p = printcore.printcore() self.gcodelist = [] self.setup()
'': 'application/octet-stream', # Default '.py': 'text/plain', '.c': 'text/plain', '.h': 'text/plain', }) serial_port = '/dev/ttyACM0' baud_rate = 115200 dummy = False if len(sys.argv) == 2 and sys.argv[1]=="dummy": dummy = True if (not dummy): from printcore import printcore core = printcore(serial_port, baud_rate) core.loud = True recvcb = core.recvcb core.recvcb = received_msg_from_fw PORT = 8000 import SocketServer httpd = SocketServer.TCPServer(("", PORT), TreeDeePrinterRequestHandler) httpd.allow_reuse_address=True print "serving at http://127.0.0.1:%d/3dprintwebgl.html" % (PORT) httpd.serve_forever()
parser.add_option("", "--batch", action="store_true", dest="batch_inkscape", default=False, help="Batch Inkscape Commands (faster, but not supported everywhere)") parser.add_option("", "--power", dest="power", default=1000, help="Laser Power (20-1000)") parser.add_option("", "--xscale", dest="xscale", default=0.999, help="X Scale for Laser Scan (0.001-0.999)") parser.add_option("", "--yscale", dest="yscale", default=0.999, help="Y Scale for Laser Scan (0.001-0.999)") parser.add_option("", "--baud", dest="baud", default=250000, help="Serial Baud Rate") parser.add_option("", "--port", dest="port", default="COM5", help="Serial Port") parser.add_option("", "--tilt", dest="tilt", default=5.0, help="Z Tilt Distance (Default 5.0mm)") parser.add_option("", "--tilt_speed", dest="tilt_speed", default=300, help="Z Tilt Distance (Default 300mm/min)") parser.add_option("", "--tilt_hold_ms", dest="tilt_hold_ms", default=500, help="ms to wait between each z move") (options, args) = parser.parse_args() if options.printfile == None: sys.exit("Missing an Input File!") printerSerial=printcore.printcore() if options.simulate == False: print "Connecting to printer... (Port: ",options.port," Baud: ",options.baud,")" printerSerial.connect(options.port, options.baud) if options.stl and options.slic3r_path != None: #Generate SVG File from Slic3r cmd=options.slic3r_path+" --export-svg --layer-height "+str(options.layer_height)+" --first-layer-height "+str(options.layer_height)+" "+options.printfile svg_file=options.printfile.replace(".stl",".svg") svg_file=svg_file.replace(".STL",".svg") if os.name == "nt": subprocess.call(cmd) else: os.system(cmd)
while(printer.printing): time.sleep(1) sys.stdout.write("\b\b\b\b%02.1f%%" % (100*float(printer.queueindex)/len(printer.mainqueue),) ) sys.stdout.flush() printer.send_now("M29 "+dosify(filename)) print "Done uploading, disconnecting with a 5 second timeout in case the printer has something important to say." printer.disconnect() time.sleep(5) print "Upload complete. Goodbye!" except: print "Abort, disconnecting with a 5 second timeout in case the printer has something important to say." printer.disconnect() if __name__ == '__main__': #print "Usage: python blupload.py filename.gcode" filename="../prusamendel/sellsx_export.gcode" tfilename=filename if len(sys.argv)>1: filename=sys.argv[1] tfilename=os.path.basename(sys.argv[1]) print "Uploading: "+filename," as "+dosify(tfilename) p=printcore.printcore('/dev/ttyUSB0',115200) p.loud=False time.sleep(2) blupload(p,tfilename,filename) else: print "Usage: python blupload.py filename.gcode"
flag=0 img=None stop=0 def grabimg(): global img global flag stream=cv2.VideoCapture(0) while(not stop): i=stream.read() if i[0] and flag: img=i[1] flag=0 stream.release() p=printcore.printcore() p.loud=True threading.Thread(target=grabimg).start() p.connect(port="/dev/ttyACM0",baud=115200) for i in xrange(10): if(p.online): break time.sleep(1) print("printer online") time.sleep(2) x=260 y=210 try: p.send_now("G28") p.send_now("G1 X200 Y150 F15000") p.send_now("M400")
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "OpenSL SLA Print Control Panel", size=(500, 750)) self.panel = wx.Panel(self, -1) self.imagePreviewPanel = wx.Panel(self, -1) self.PhotoMaxSize = 350 img = wx.EmptyImage(self.PhotoMaxSize, self.PhotoMaxSize) self.imageCtrl = wx.StaticBitmap(self.imagePreviewPanel, wx.ID_ANY, wx.BitmapFromImage(img)) self.currentImagePath = "" self.imagePreviewPanel.SetBackgroundColour(wx.BLACK) buttonPanel = wx.Panel(self, -1) consolePanel = wx.Panel(self, -1) connectPanel = wx.Panel(self, -1) menubar = wx.MenuBar() file = wx.Menu() file.Append(101, '&quit', 'Quit application') # menubar.Append(file, '&File') self.connectToLaserSharkButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/connect-button.png'), 32, 32)) self.disconnectFromLaserSharkButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/disconnect-button.png'), 32, 32)) self.selectFileToPrintButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/browse-button.png'), 32, 32)) self.printButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/print-button.png'), 32, 32)) self.simulateButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/simulate-button.png'), 32, 32)) self.pauseButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/pause-button.png'), 32, 32)) self.homeZButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/home-z-button.png'), 32, 32)) self.ZUpButton = wx.BitmapButton( buttonPanel, -1, scale_bitmap(wx.Bitmap('icons/z-up-button.png'), 32, 32)) self.Bind(wx.EVT_BUTTON, self.startLaserShark, self.connectToLaserSharkButton) self.Bind(wx.EVT_BUTTON, self.stopLaserShark, self.disconnectFromLaserSharkButton) self.Bind(wx.EVT_BUTTON, self.selectFileToPrint, self.selectFileToPrintButton) self.Bind(wx.EVT_BUTTON, self.printClicked, self.printButton) self.Bind(wx.EVT_BUTTON, self.simulateClicked, self.simulateButton) self.Bind(wx.EVT_BUTTON, self.pauseClicked, self.pauseButton) self.Bind(wx.EVT_BUTTON, self.HomeZ, self.homeZButton) self.Bind(wx.EVT_BUTTON, self.ZUp, self.ZUpButton) self.disconnectFromLaserSharkButton.Disable() self.pauseButton.Disable() wx.StaticBox(consolePanel, label='Scan Configuration', pos=(5, 5), size=(220, 170)) self.rbPreview = wx.RadioButton(consolePanel, -1, 'Preview Scan', (18, 30), style=wx.RB_GROUP) self.rbLaser = wx.RadioButton(consolePanel, -1, 'Laser!', (18, 50)) wx.StaticText(consolePanel, label='Laser Power', pos=(15, 80)) self.laserPowerSpin = wx.SpinCtrl(consolePanel, value='1000', pos=(107, 80), size=(80, -1), min=1, max=1000) wx.StaticText(consolePanel, label='X Scale', pos=(15, 110)) self.xScaleSpin = wx.SpinCtrl(consolePanel, value='100', pos=(107, 110), size=(60, -1), min=1, max=100) wx.StaticText(consolePanel, label='Y Scale', pos=(15, 140)) self.yScaleSpin = wx.SpinCtrl(consolePanel, value='100', pos=(107, 140), size=(60, -1), min=1, max=100) wx.StaticBox(consolePanel, label='Z-Axis Configuration', pos=(225, 5), size=(270, 170)) self.rbZControlOn = wx.RadioButton(consolePanel, -1, 'Z Axis Control On', (238, 30), style=wx.RB_GROUP) self.rbZControlOff = wx.RadioButton(consolePanel, -1, 'Z Axis Control Off', (238, 50)) wx.StaticText(consolePanel, label='Layer Height (mm)', pos=(235, 80)) self.zLayerHeightSpin = wx.SpinCtrl(consolePanel, value='1', pos=(402, 80), size=(80, -1), min=1, max=5) wx.StaticText(consolePanel, label='Z Motor Speed (mm/min)', pos=(235, 110)) self.zMotorSpeedSpin = wx.SpinCtrl(consolePanel, value='240', pos=(422, 110), size=(60, -1), min=100, max=300) wx.StaticText(consolePanel, label='Tilt Step Height (mm)', pos=(235, 140)) self.zTiltHeightSpin = wx.SpinCtrl(consolePanel, value='5', pos=(422, 140), size=(60, -1), min=1, max=20) self.progress = wx.Slider(buttonPanel, -1, 0, 0, 100, size=(500, -1)) vbox = wx.BoxSizer(wx.VERTICAL) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox3 = wx.BoxSizer(wx.HORIZONTAL) hbox2.Add(self.connectToLaserSharkButton) hbox2.Add(self.disconnectFromLaserSharkButton, flag=wx.RIGHT, border=10) hbox2.Add(self.selectFileToPrintButton, flag=wx.RIGHT, border=20) hbox2.Add(self.printButton, flag=wx.RIGHT, border=5) hbox2.Add(self.simulateButton) hbox2.Add(self.pauseButton) hbox2.Add(self.homeZButton, flag=wx.LEFT, border=20) hbox2.Add(self.ZUpButton) vbox.Add(hbox3, 1, wx.EXPAND) vbox.Add(hbox2, 1, wx.EXPAND) buttonPanel.SetSizer(vbox) #connectPanel.SetSizer(vbox) sizer = wx.BoxSizer(wx.VERTICAL) listSerial = self.scanserial() self.rescanbtn = wx.Button(connectPanel, 0, "Refresh", size=(80, 25)) self.rescanbtn.SetToolTip( wx.ToolTip("Communication Settings\nClick to rescan ports")) self.rescanbtn.Bind(wx.EVT_BUTTON, self.rescanports) self.port = "" hbox3.Add(self.rescanbtn, 0, wx.TOP | wx.LEFT, 0) hbox3.Add(wx.StaticText(connectPanel, -1, " Port: "), 0, wx.RIGHT, 0) self.serialport = wx.ComboBox(connectPanel, -1, choices=listSerial, style=wx.CB_DROPDOWN, size=(100, 25), pos=(5, 100)) self.serialport.SetToolTip( wx.ToolTip("Select Port Printer is connected to")) self.rescanports() hbox3.Add(self.serialport) hbox3.Add(wx.StaticText(connectPanel, -1, " Baud: "), 0, wx.RIGHT, 0) self.baud = wx.ComboBox(connectPanel, -1, choices=[ "2400", "9600", "19200", "38400", "57600", "115200", "250000" ], style=wx.CB_DROPDOWN, size=(100, 25)) self.baud.SetToolTip( wx.ToolTip("Select Baud rate for printer communication")) try: self.baud.SetValue("115200") except: pass hbox3.Add(self.baud) hbox3.Add((500, -1), 1, flag=wx.EXPAND | wx.TOP | wx.ALIGN_RIGHT) sizer.Add(connectPanel, flag=wx.EXPAND) sizer.Add(self.imagePreviewPanel, 1, flag=wx.EXPAND) sizer.Add(buttonPanel, flag=wx.EXPAND, border=10) sizer.Add(consolePanel, flag=wx.BOTTOM | wx.EXPAND) self.SetMinSize((350, 300)) self.SetMenuBar(menubar) self.CreateStatusBar() self.SetSizer(sizer) self.Centre() self.print_loaded = False self.connected = False self.start_print_index = 0 global simulate_timer_ms self.simulate_timer_ms = simulate_timer_ms global OPENLASE_PATH self.OPENLASE_PATH = OPENLASE_PATH global LASERSHARK_HOST_PATH self.LASERSHARK_HOST_PATH = LASERSHARK_HOST_PATH if os.name != "nt": if (os.getuid() != 0): wx.MessageBox( 'You must launch this script as root! (sudo) \n\n Try again with "sudo python SlaPrint.py"', 'Error', wx.OK | wx.ICON_ERROR) sys.exit(1) if os.name == "nt": self.cmd_prefix = "echo " else: self.cmd_prefix = "sudo " self.printerSerial = printcore.printcore()
import sys, os sys.path.append(os.path.abspath("/home/pi/Printrun")) from printcore import printcore from printrun import gcoder print "Enter printer path: " printer_path = raw_input() print "Enter file path: //try /home/pi/Pcore_Testing/calib.gcode" file_path = raw_input() if len(printer_path) < 4: printer_path="/dev/ttyACM0" if len(file_path) < 4: file_path="/home/pi/Pcore_Testing/calib.gcode" # Need to accept path as parameter lol if multiple printers are up p = printcore(printer_path, 115200) # p = printcore('/dev/ttyACM0',115200) # p = printcore('/dev/ttyACM1',115200) p.send_now("G28") # Home all axes p.send_now("M104 S200") # Extruder temp, don't wait # This line should be rewritten to accept file path as param #gcode = [i.strip() for i in open('/home/pi/Pcore_Testing/calib.gcode')] gcode = [i.strip() for i in open(file_path)] # Following line is using (deprecated?) Gcode, as opposed to current LightGCode # This line is relevant to updated version of Printrun. gcode = gcoder.LightGCode(gcode) #gcode = gcoder.GCode(gcode) p.startprint(gcode)
def __init__(self, config): super(printcoredriver, self).__init__(config) self.p = printcore.printcore() self.p.loud = False time.sleep(2)
def __init__(self, configInfo): self.p = printcore.printcore(configInfo['port'],115200) sleep(3) self.ci = configInfo
sys.stdout.write( "\b\b\b\b%02.1f%%" % (100 * float(printer.queueindex) / len(printer.mainqueue), )) sys.stdout.flush() printer.send_now("M29 " + dosify(filename)) print "Done uploading, disconnecting with a 5 second timeout in case the printer has something important to say." printer.disconnect() time.sleep(5) print "Upload complete. Goodbye!" except: print "Abort, disconnecting with a 5 second timeout in case the printer has something important to say." printer.disconnect() if __name__ == '__main__': #print "Usage: python blupload.py filename.gcode" filename = "../prusamendel/sellsx_export.gcode" tfilename = filename if len(sys.argv) > 1: filename = sys.argv[1] tfilename = os.path.basename(sys.argv[1]) print "Uploading: " + filename, " as " + dosify(tfilename) p = printcore.printcore('/dev/ttyUSB0', 115200) p.loud = False time.sleep(2) blupload(p, tfilename, filename) else: print "Usage: python blupload.py filename.gcode"