Skip to content

Commit

Permalink
Merge branch 'experimental' of github.com:kliment/Printrun into exper…
Browse files Browse the repository at this point in the history
…imental

Conflicts:
	pronterface.py
  • Loading branch information
kliment committed Aug 20, 2012
2 parents 4a5e13f + 4d39b26 commit 930a433
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 46 deletions.
13 changes: 1 addition & 12 deletions .pronsolerc.example → dot.pronsolerc.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# Sample .pronsolerc file - copy this into your home directory and rename it to .pronsolerc
!print "Loaded " + self.rc_filename

macro loud
!if self.p.loud:
!self.p.loud = 0
!if hasattr(self,"cur_button") and self.cur_button is not None:
!self.onecmd('button %d "loud (off)" /c green loud' % self.cur_button)
!else:
!self.p.loud = 1
!if hasattr(self,"cur_button") and self.cur_button is not None:
!self.onecmd('button %d "loud (on)" /c yellow loud' % self.cur_button)
button 0 "loud (off)" /c "green" loud

macro fan
!global _fan
!if '_fan' in globals() and _fan:
Expand All @@ -24,4 +13,4 @@ macro fan
M106
!if hasattr(self,"cur_button") and self.cur_button is not None:
!self.onecmd('button %d "fan (on)" /c yellow fan' % self.cur_button)
button 1 "fan (off)" /c "green" fan
button 0 "fan (off)" /c "green" fan
18 changes: 12 additions & 6 deletions printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,19 @@ def _listen(self):
pass
#callback for errors
pass
# Teststrings for resend parsing # Firmware exp. result
# line="rs N2 Expected checksum 67" # Teacup 2
if line.lower().startswith("resend") or line.startswith("rs"):
try:
toresend=int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1])
except:
if line.startswith("rs"):
toresend=int(line.split()[1])
self.resendfrom=toresend
line=line.replace("N:"," ").replace("N"," ").replace(":"," ")
linewords=line.split()
while len(linewords) != 0:
try:
toresend=int(linewords.pop(0))
self.resendfrom=toresend
#print str(toresend)
break
except:
pass
self.clear=True
self.clear=True
#callback for disconnect
Expand Down
11 changes: 8 additions & 3 deletions pronsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ def help_disconnect(self):
print "Disconnects from the printer"

def do_load(self,l):
self._do_load(l)

def _do_load(self,l):
if len(l)==0:
print "No file name given."
return
Expand All @@ -631,7 +634,7 @@ def do_load(self,l):
self.f=[i.replace("\n","").replace("\r","") for i in open(l)]
self.filename=l
print "Loaded ",l,", ",len(self.f)," lines."

def complete_load(self, text, line, begidx, endidx):
s=line.split()
if len(s)>2:
Expand Down Expand Up @@ -874,14 +877,16 @@ def help_shell(self):
def default(self,l):
if(l[0] in self.commandprefixes.upper()):
if(self.p and self.p.online):
print "SENDING:"+l
if(not self.p.loud):
print "SENDING:"+l
self.p.send_now(l)
else:
print "Printer is not online."
return
elif(l[0] in self.commandprefixes.lower()):
if(self.p and self.p.online):
print "SENDING:"+l.upper()
if(not self.p.loud):
print "SENDING:"+l.upper()
self.p.send_now(l.upper())
else:
print "Printer is not online."
Expand Down
79 changes: 54 additions & 25 deletions pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def __init__(self, filename=None,size=winsize):
self.webInterface=webinterface.WebInterface(self)
self.webThread = Thread(target=webinterface.StartWebInterfaceThread, args=(self.webInterface, ))
self.webThread.start()
if(self.filename is not None):
self.do_load(self.filename)

def startcb(self):
self.starttime=time.time()
Expand Down Expand Up @@ -434,6 +436,12 @@ def popmenu(self):
self.Bind(wx.EVT_MENU, lambda *e:options(self), m.Append(-1,_("&Options"),_(" Options dialog")))

self.Bind(wx.EVT_MENU, lambda x:threading.Thread(target=lambda :self.do_skein("set")).start(), m.Append(-1,_("Slicing Settings"),_(" Adjust slicing settings")))

mItem = m.AppendCheckItem(-1, _("Debug G-code"),
_("Print all G-code sent to and received from the printer."))
m.Check(mItem.GetId(), self.p.loud)
self.Bind(wx.EVT_MENU, self.setloud, mItem)

#try:
# from SkeinforgeQuickEditDialog import SkeinforgeQuickEditDialog
# self.Bind(wx.EVT_MENU, lambda *e:SkeinforgeQuickEditDialog(self), m.Append(-1,_("SFACT Quick Settings"),_(" Quickly adjust SFACT settings for active profile")))
Expand Down Expand Up @@ -483,14 +491,14 @@ def edit_macro(self,macro):
if macro == "": return self.new_macro()
if self.macros.has_key(macro):
old_def = self.macros[macro]
elif hasattr(self.__class__,"do_"+macro):
print _("Name '%s' is being used by built-in command") % macro
return
elif len([c for c in macro if not c.isalnum() and c != "_"]):
print _("Macro name may contain only alphanumeric symbols and underscores")
elif len([c for c in macro.encode("ascii","replace") if not c.isalnum() and c != "_"]):
print _("Macro name may contain only ASCII alphanumeric symbols and underscores")
if webavail:
self.webInterface.AddLog("Macro name may contain only alphanumeric symbols and underscores")
return
elif hasattr(self.__class__,"do_"+macro):
print _("Name '%s' is being used by built-in command") % macro
return
else:
old_def = ""
self.start_macro(macro,old_def)
Expand Down Expand Up @@ -541,14 +549,15 @@ def popwindow(self):
self.rescanbtn=wx.Button(self.panel,-1,_("Port"),size=buttonSize)
self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports"))
self.rescanbtn.Bind(wx.EVT_BUTTON,self.rescanports)

uts.Add(self.rescanbtn,0,wx.TOP|wx.LEFT,0)

self.serialport = wx.ComboBox(self.panel, -1,
choices=self.scanserial(),
style=wx.CB_DROPDOWN, size=(100, 25))
self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
self.rescanports()
uts.Add(self.serialport)

uts.Add(wx.StaticText(self.panel,-1,"@"),0,wx.RIGHT|wx.ALIGN_CENTER,0)
self.baud = wx.ComboBox(self.panel, -1,
choices=["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
Expand All @@ -560,20 +569,22 @@ def popwindow(self):
except:
pass
uts.Add(self.baud)

self.connectbtn=wx.Button(self.panel,-1,_("Connect"), size=buttonSize)
uts.Add(self.connectbtn)
self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
uts.Add(self.connectbtn)

self.resetbtn=wx.Button(self.panel,-1,_("Reset"),style=wx.BU_EXACTFIT,size=(-1,buttonSize[1]))
self.resetbtn.Bind(wx.EVT_BUTTON,self.reset)
self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer"))
uts.Add(self.resetbtn)
#self.minibtn=wx.Button(self.panel,-1,_("Mini mode"),style=wx.BU_EXACTFIT)
#self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)

#uts.Add((25,-1))

#uts.Add((15,-1),flag=wx.EXPAND)
#self.minibtn=wx.Button(self.panel,-1,_("Mini mode"),style=wx.BU_EXACTFIT)
#self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)
#uts.Add(self.minibtn,0,wx.ALIGN_CENTER)

#SECOND ROW
Expand Down Expand Up @@ -948,7 +959,10 @@ def cbuttons_reload(self):
b.SetToolTip(wx.ToolTip(_("click to add new custom button")))
b.Bind(wx.EVT_BUTTON,self.cbutton_edit)
else:
continue
b=wx.Button(self.panel,-1,".",size=(1,1))
#b=wx.StaticText(self.panel,-1,"",size=(72,22),style=wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable()
#continue
b.custombutton=i
b.properties=btndef
if btndef is not None:
Expand Down Expand Up @@ -1112,25 +1126,32 @@ def editbutton(self,e):
if not hasattr(self,"dragging"):
# init dragging of the custom button
if hasattr(obj,"custombutton") and obj.properties is not None:
self.newbuttonbutton.SetLabel("")
self.newbuttonbutton.SetFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_NORMAL))
self.newbuttonbutton.SetForegroundColour("black")
self.newbuttonbutton.SetSize(obj.GetSize())
if self.upperbottomsizer.GetItem(self.newbuttonbutton) is not None:
self.upperbottomsizer.SetItemMinSize(self.newbuttonbutton,obj.GetSize())
self.topsizer.Layout()
#self.newbuttonbutton.SetLabel("")
#self.newbuttonbutton.SetFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_NORMAL))
#self.newbuttonbutton.SetForegroundColour("black")
#self.newbuttonbutton.SetSize(obj.GetSize())
#if self.upperbottomsizer.GetItem(self.newbuttonbutton) is not None:
# self.upperbottomsizer.SetItemMinSize(self.newbuttonbutton,obj.GetSize())
# self.topsizer.Layout()
for b in self.custombuttonbuttons:
#if b.IsFrozen(): b.Thaw()
if b.properties is None:
b.Enable()
b.SetLabel("")
b.SetFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_NORMAL))
b.SetForegroundColour("black")
b.SetSize(obj.GetSize())
if self.upperbottomsizer.GetItem(b) is not None:
self.upperbottomsizer.SetItemMinSize(b,obj.GetSize())
self.topsizer.Layout()
# b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER)
self.dragging = wx.Button(self.panel,-1,obj.GetLabel(),style=wx.BU_EXACTFIT)
self.dragging.SetBackgroundColour(obj.GetBackgroundColour())
self.dragging.SetForegroundColour(obj.GetForegroundColour())
self.dragging.sourcebutton = obj
self.dragging.Raise()
self.dragging.Disable()
self.dragging.SetPosition(self.panel.ScreenToClient(scrpos))
for b in self.custombuttonbuttons:
#if b.IsFrozen(): b.Thaw()
if b.properties is None:
b.Enable()
# b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER)
self.last_drag_dest = obj
self.dragging.label = obj.s_label = obj.GetLabel()
self.dragging.bgc = obj.s_bgc = obj.GetBackgroundColour()
Expand Down Expand Up @@ -1311,6 +1332,8 @@ def addtexttolog(self,text):
if webavail:
self.webInterface.AppendLog(text)

def setloud(self,e):
self.p.loud=e.IsChecked()

def sendline(self,e):
command=self.commandbox.GetValue()
Expand Down Expand Up @@ -1409,7 +1432,7 @@ def recvcb(self,l):
pass
tstring=l.rstrip()
#print tstring
if (tstring!="ok") and (tstring!="wait") and ("ok T:" not in tstring):
if (tstring!="ok") and (tstring!="wait") and ("ok T:" not in tstring) and (not self.p.loud):
# print "*"+tstring+"*"
# print "[" + time.strftime('%H:%M:%S',time.localtime(time.time())) + "] " + tstring
wx.CallAfter(self.addtexttolog,tstring+"\n");
Expand Down Expand Up @@ -1538,6 +1561,12 @@ def skein(self,filename):
thread(target=self.skein_func).start()
thread(target=self.skein_monitor).start()

def do_load(self,l):
if hasattr(self, 'skeining'):
self.loadfile(None, l)
else:
self._do_load(l)

def loadfile(self,event,filename=None):
if self.skeining and self.skeinp is not None:
self.skeinp.terminate()
Expand Down Expand Up @@ -2067,10 +2096,10 @@ def paint(self,ev):
#gc.DrawText(text,29,-2)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD),wx.WHITE))
gc.DrawText(self.title,x0+19,y0+4)
gc.DrawText(text, x0+133,y0+4)
gc.DrawText(text, x0+119,y0+4)
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD)))
gc.DrawText(self.title,x0+18,y0+3)
gc.DrawText(text, x0+132,y0+3)
gc.DrawText(text, x0+118,y0+3)

if __name__ == '__main__':
app = wx.App(False)
Expand Down
64 changes: 64 additions & 0 deletions testfiles/PCB-milling-and-(comment).gcode
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
(Created by G-code exporter)
(Fri Apr 27 22:20:09 2012)
(Board size: 100.00 x 130.00 mm)
(---------------------------------)
G21
G90
G0 X14.392 Y30.94113 Z1.
G4
M104 S255
G1 Z-0.2 F60
G1 X14.05334 Y30.60247
G1 X12.02134 Y30.60247
G1 X11.598 Y30.85647
G1 X11.00534 Y31.5338
G1 X10.074 Y32.5498
G1 X9.98933 Y34.41247
G0 Z1.
(RepRap Gen7 v1.4)
G0 Z1.
(R)
G0 X9.9753 Y6.9723
G1 Z-0.20 F60
G1 X11.4761 Y6.9723 F250
G1 X11.8514 Y6.5971
G1 X11.8514 Y5.8467
G1 X11.4761 Y5.4715
G1 X10.3505 Y5.4715
G1 X11.8514 Y3.9456
G0 Z1.
G0 X10.3505 Y6.9723
G1 Z-0.20 F60
G1 X10.3505 Y3.9456 F250
G0 Z1.
(e)
G0 X12.7519 Y4.696
G1 Z-0.20 F60
G1 X14.2778 Y4.696 F250
G1 X14.2778 Y5.0962
G1 X13.9025 Y5.4715
G1 X13.1271 Y5.4715
G1 X12.7519 Y5.0962
G1 X12.7519 Y4.3208
G1 X13.1271 Y3.9456
G1 X14.2778 Y3.9456
G0 Z1.
(p)
G0 X15.5535 Y2.8199
G1 Z-0.20 F60
G1 X15.5535 Y5.0962 F250
G1 X15.1783 Y5.4715
G1 X15.5535 Y5.0962
G1 X15.9287 Y5.4715
G1 X16.6792 Y5.4715
G1 X17.0544 Y5.0962
G1 X17.0544 Y4.3208
G1 X16.6792 Y3.9456
G1 X15.9287 Y3.9456
G1 X15.5535 Y4.3208
G0 Z1.
G4
M104 S0
(tool change position)
G1 X2. Y2. Z40. F400
M2

0 comments on commit 930a433

Please sign in to comment.