Skip to content

Commit

Permalink
- Added user selectable choice for other controllers
Browse files Browse the repository at this point in the history
- If smoothie is selected all g-code is converted to upper case
  Some commands are translated to Smoothie equivalent
  • Loading branch information
vlachoudis committed Jan 28, 2016
1 parent 95ac7f5 commit f29b670
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 38 deletions.
21 changes: 20 additions & 1 deletion FilePage.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,21 @@ def __init__(self, master, app):

# ---
row += 1
b= Checkbutton(self, text=_("Connect on startup"),
b = Label(self, text=_("Controller:"), background=Ribbon._BACKGROUND)
b.grid(row=row,column=col,sticky=E)

self.ctrlCombo = tkExtra.Combobox(self, True,
background="White",
command=self.ctrlChange)
self.ctrlCombo.grid(row=row, column=col+1, sticky=EW)
tkExtra.Balloon.set(self.ctrlCombo, _("Select controller board"))
self.ctrlCombo.fill(sorted(Utils.CONTROLLER.keys()))
self.ctrlCombo.set(Utils.controllerName(app.controller))
self.addWidget(self.ctrlCombo)

# ---
row += 1
b= Checkbutton(self, text=_("Connect on startup"),
variable=self.autostart)
b.grid(row=row, column=col, columnspan=2, sticky=W)
tkExtra.Balloon.set(b, _("Connect to serial on startup of the program"))
Expand All @@ -271,9 +285,14 @@ def __init__(self, master, app):
tkExtra.Balloon.set(self.connectBtn, _("Open/Close serial port"))
self.grid_columnconfigure(1, weight=1)

#-----------------------------------------------------------------------
def ctrlChange(self):
self.app.controller = Utils.CONTROLLER.get(self.ctrlCombo.get(), 0)

#-----------------------------------------------------------------------
def saveConfig(self):
# Connection
Utils.setStr("Connection", "controller", Utils.controllerName(self.app.controller))
Utils.setStr("Connection", "port", self.portCombo.get())
Utils.setStr("Connection", "baud", self.baudCombo.get())
Utils.setBool("Connection", "openserial", self.autostart.get())
Expand Down
51 changes: 40 additions & 11 deletions Sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self):
self.pendant = Queue() # Command queue to be executed from Pendant
self.serial = None
self.thread = None
self.controller = Utils.CONTROLLER["Grbl"]

self._posUpdate = False # Update position
self._probeUpdate= False # Update probe
Expand All @@ -135,7 +136,8 @@ def quit(self, event=None):

#----------------------------------------------------------------------
def loadConfig(self):
Pendant.port = Utils.getInt("Connection","pendantport",Pendant.port)
self.controller = Utils.CONTROLLER.get(Utils.getStr("Connection", "controller"), 0)
Pendant.port = Utils.getInt("Connection","pendantport",Pendant.port)
GCode.LOOP_MERGE = Utils.getBool("File","dxfloopmerge")
self.loadHistory()

Expand Down Expand Up @@ -277,6 +279,17 @@ def executeCommand(self, line):
elif rexx.abbrev("UNLOCK",cmd,3):
self.unlock()

# Send commands to SMOOTHIE
elif self.controller == Utils.SMOOTHIE:
if line[0] in ( "help", "version", "mem", "ls",
"cd", "pwd", "cat", "rm", "mv",
"remount", "play", "progress", "abort",
"reset", "dfu", "break", "config-get",
"config-set", "get", "set_temp", "get",
"get", "net", "load", "save", "upload",
"calc_thermistor", "thermistors", "md5sum"):
self.serial.write(oline+"\n")

else:
return _("unknown command"),_("Invalid command %s")%(oline)

Expand Down Expand Up @@ -442,7 +455,10 @@ def hardReset(self):
#----------------------------------------------------------------------
def softReset(self):
if self.serial:
self.serial.write(b"\030")
if self.controller == Utils.GRBL:
self.serial.write(b"\030")
elif self.controller == Utils.SMOOTHIE:
self.serial.write("reset\n")
self.stopProbe()
self._alarm = False

Expand All @@ -458,34 +474,46 @@ def home(self):

#----------------------------------------------------------------------
def viewSettings(self):
self.sendGrbl("$$\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$$\n")

def viewParameters(self):
self.sendGrbl("$#\n$G\n")
self.sendGrbl("$#\n")

def viewState(self):
self.sendGrbl("$G\n")

def viewBuild(self):
self.sendGrbl("$I\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$I\n")
elif self.controller == Utils.SMOOTHIE:
self.serial.write("version\n")

def viewStartup(self):
self.sendGrbl("$N\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$N\n")

def checkGcode(self):
self.sendGrbl("$C\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$C\n")

def grblHelp(self):
self.sendGrbl("$\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$\n")
elif self.controller == Utils.SMOOTHIE:
self.serial.write("help\n")

def grblRestoreSettings(self):
self.sendGrbl("$RST=$\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$RST=$\n")

def grblRestoreWCS(self):
self.sendGrbl("$RST=#\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$RST=#\n")

def grblRestoreAll(self):
self.sendGrbl("$RST=#\n")
if self.controller == Utils.GRBL:
self.sendGrbl("$RST=#\n")

#----------------------------------------------------------------------
def goto(self, x=None, y=None, z=None):
Expand Down Expand Up @@ -815,6 +843,7 @@ def serialIO(self):
# if not tosend: tosend = None

#print ">S>",repr(tosend),"stack=",sline,"sum=",sum(cline)
if self.controller==Utils.SMOOTHIE: tosend = tosend.upper()
self.serial.write(bytes(tosend))
# self.serial.flush()

Expand Down
1 change: 1 addition & 0 deletions TerminalPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, master, app):
text=_("Settings"),
compound=LEFT,
anchor=W,
#state=app.controller==Utils.GRBL and NORMAL or DISABLED,
command=self.app.viewSettings,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
Expand Down
11 changes: 11 additions & 0 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@

_FONT_SECTION = "Font"

GRBL = 0
SMOOTHIE = 1
CONTROLLER = {"Grbl":0, "Smoothie":1}

#------------------------------------------------------------------------------
def loadIcons():
global icons
Expand Down Expand Up @@ -236,6 +240,13 @@ def setUtf(section, name, value):
setInt = setStr
setFloat = setStr

#-------------------------------------------------------------------------------
def controllerName(idx):
for n,i in CONTROLLER.items():
if i==idx:
return n
return "unknown"

#-------------------------------------------------------------------------------
# Add Recent
#-------------------------------------------------------------------------------
Expand Down
53 changes: 27 additions & 26 deletions bCNC.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,48 @@ terminal.ribbon = Commands Terminal
terminal.page = DRO Terminal*

[Connection]
baud = 115200
port =
pendant = 1
baud = 115200
port =
pendant = 1
pendantport = 8080
openserial = 0
openserial = 0
errorreport = 1
controller = Grbl

[Control]
step = 1
wcs = 54
step = 1
wcs = 54
;zstep = 1
step1=0.1
step2=1
step3=10
step1 = 0.1
step2 = 1
step3 = 10

[Canvas]
view = X-Y
view = X-Y
workarea = 1
margin = 1
grid = 1
axes = 1
probe = 1
rapid = 1
paths = 1
margin = 1
grid = 1
axes = 1
probe = 1
rapid = 1
paths = 1

[Error]

[Probe]
x =
y =
z =
xmin = 0.0
xmax = 100.0
xn = 5
ymin = 0.0
ymax = 100.0
yn = 5
zmin = -10.0
zmax = 5.0
feed = 10.0
tlo = 0.0
xmin = 0.0
xmax = 100.0
xn = 5
ymin = 0.0
ymax = 100.0
yn = 5
zmin = -10.0
zmax = 5.0
feed = 10.0
tlo = 0.0
center = 10.0
cmd = G38.2
toolpolicy = 1
Expand Down

0 comments on commit f29b670

Please sign in to comment.