- in CNCJob UI Autolevelling - added handlers for GRBL report and for getting GRBL parameters
This commit is contained in:
parent
56ac489466
commit
3afcabe559
|
@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta
|
|||
- in Doublesided Tool cleaned up the UI
|
||||
- in CNCJob UI Autolevelling - in COntrol section added buttons for Jog an individual axes zeroing
|
||||
- in CNCJob UI Autolevelling - added handlers for: jogging, reset, sending commands
|
||||
- in CNCJob UI Autolevelling - added handlers for GRBL report and for getting GRBL parameters
|
||||
|
||||
17.08.2020
|
||||
|
||||
|
|
|
@ -2293,7 +2293,6 @@ class CNCObjectUI(ObjectUI):
|
|||
grbl_send_grid.setColumnStretch(1, 1)
|
||||
grbl_send_grid.setColumnStretch(2, 0)
|
||||
self.gr_send_tab_layout.addLayout(grbl_send_grid)
|
||||
self.gr_send_tab_layout.addStretch(1)
|
||||
|
||||
# CUSTOM COMMAND
|
||||
self.grbl_command_label = FCLabel('%s:' % _("CMD"))
|
||||
|
@ -2320,6 +2319,37 @@ class CNCObjectUI(ObjectUI):
|
|||
)
|
||||
grbl_send_grid.addWidget(self.grbl_get_heightmap_button, 4, 0, 1, 3)
|
||||
|
||||
# GET Report
|
||||
self.grbl_report_button = FCButton(_("Get Report"))
|
||||
self.grbl_report_button.setToolTip(
|
||||
_("Print in shell the GRBL report.")
|
||||
)
|
||||
grbl_send_grid.addWidget(self.grbl_report_button, 5, 0, 1, 3)
|
||||
|
||||
grbl_send2_grid = QtWidgets.QGridLayout()
|
||||
grbl_send2_grid.setColumnStretch(0, 0)
|
||||
grbl_send2_grid.setColumnStretch(1, 1)
|
||||
grbl_send2_grid.setColumnStretch(2, 0)
|
||||
self.gr_send_tab_layout.addLayout(grbl_send2_grid)
|
||||
self.gr_send_tab_layout.addStretch(1)
|
||||
|
||||
# Get Parameter
|
||||
self.grbl_get_param_label = FCLabel('%s:' % _("Parameter"))
|
||||
self.grbl_get_param_label.setToolTip(
|
||||
_("A GRBL parameter.")
|
||||
)
|
||||
|
||||
self.grbl_parameter_entry = FCEntry()
|
||||
|
||||
self.grbl_get_param_button = QtWidgets.QToolButton()
|
||||
self.grbl_get_param_button.setText(_("Get"))
|
||||
self.grbl_get_param_button.setToolTip(
|
||||
_("Get the value of a specified GRBL parameter.")
|
||||
)
|
||||
grbl_send2_grid.addWidget(self.grbl_get_param_label, 2, 0)
|
||||
grbl_send2_grid.addWidget(self.grbl_parameter_entry, 2, 1)
|
||||
grbl_send2_grid.addWidget(self.grbl_get_param_button, 2, 2)
|
||||
|
||||
self.grbl_frame.hide()
|
||||
# #############################################################################################################
|
||||
|
||||
|
|
|
@ -561,15 +561,20 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.ui.controller_reset_button.clicked.connect(self.on_grbl_reset)
|
||||
self.ui.com_connect_button.clicked.connect(self.on_connect_grbl)
|
||||
self.ui.grbl_send_button.clicked.connect(self.on_send_grbl_command)
|
||||
self.ui.grbl_command_entry.returnPressed.connect(self.on_send_grbl_command)
|
||||
|
||||
#Jog
|
||||
self.ui.jog_up_button.clicked.connect(lambda: self.on_jog(dir='yplus', step=5.0))
|
||||
self.ui.jog_down_button.clicked.connect(lambda: self.on_jog(dir='yminus', step=5.0))
|
||||
self.ui.jog_right_button.clicked.connect(lambda: self.on_jog(dir='xplus', step=5.0))
|
||||
self.ui.jog_left_button.clicked.connect(lambda: self.on_jog(dir='xminus', step=5.0))
|
||||
self.ui.jog_z_up_button.clicked.connect(lambda: self.on_jog(dir='zplus', step=5.0))
|
||||
self.ui.jog_z_down_button.clicked.connect(lambda: self.on_jog(dir='zminus', step=5.0))
|
||||
self.ui.jog_up_button.clicked.connect(lambda: self.on_jog(direction='yplus', step=5.0))
|
||||
self.ui.jog_down_button.clicked.connect(lambda: self.on_jog(direction='yminus', step=5.0))
|
||||
self.ui.jog_right_button.clicked.connect(lambda: self.on_jog(direction='xplus', step=5.0))
|
||||
self.ui.jog_left_button.clicked.connect(lambda: self.on_jog(direction='xminus', step=5.0))
|
||||
self.ui.jog_z_up_button.clicked.connect(lambda: self.on_jog(direction='zplus', step=5.0))
|
||||
self.ui.jog_z_down_button.clicked.connect(lambda: self.on_jog(direction='zminus', step=5.0))
|
||||
|
||||
# Sender
|
||||
self.ui.grbl_report_button.clicked.connect(lambda: self.send_grbl_command(command='?'))
|
||||
self.ui.grbl_get_param_button.clicked.connect(
|
||||
lambda: self.get_grbl_parameter(param=self.ui.grbl_parameter_entry.get_value()))
|
||||
self.ui.view_h_gcode_button.clicked.connect(self.on_view_probing_gcode)
|
||||
self.ui.h_gcode_button.clicked.connect(self.on_generate_probing_gcode)
|
||||
self.ui.import_heights_button.clicked.connect(self.on_import_height_map)
|
||||
|
@ -1010,23 +1015,38 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
except Exception as e:
|
||||
log.debug("CNCJobObject.send_grbl_command() --> %s" % str(e))
|
||||
|
||||
def on_jog(self, dir=None, step=5.0):
|
||||
if dir is None:
|
||||
def get_grbl_parameter(self, param):
|
||||
if '$' in param:
|
||||
param = param.replace('$','')
|
||||
|
||||
snd = '$$\n'
|
||||
self.grbl_ser_port.write(snd.encode('utf-8'))
|
||||
grbl_out = self.grbl_ser_port.readlines()
|
||||
for line in grbl_out:
|
||||
decoded_line = line.decode('utf-8')
|
||||
par = '$%s' % str(param)
|
||||
if par in decoded_line:
|
||||
result = float(decoded_line.rpartition('=')[2])
|
||||
self.app.shell_message("GRBL Parameter: %s = %s" % (str(param), str(result)), show=True)
|
||||
return result
|
||||
|
||||
def on_jog(self, direction=None, step=5.0):
|
||||
if direction is None:
|
||||
return
|
||||
cmd = ''
|
||||
|
||||
if dir == 'xplus':
|
||||
if direction == 'xplus':
|
||||
cmd = "$J=G91 %s X%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
if dir == 'xminus':
|
||||
if direction == 'xminus':
|
||||
cmd = "$J=G91 %s X-%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
if dir == 'yplus':
|
||||
if direction == 'yplus':
|
||||
cmd = "$J=G91 %s Y%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
if dir == 'yminus':
|
||||
if direction == 'yminus':
|
||||
cmd = "$J=G91 %s Y-%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
|
||||
if dir == 'zplus':
|
||||
if direction == 'zplus':
|
||||
cmd = "$J=G91 %s Z%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
if dir == 'zminus':
|
||||
if direction == 'zminus':
|
||||
cmd = "$J=G91 %s Z-%s F1000" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step))
|
||||
|
||||
self.send_grbl_command(command=cmd, echo=False)
|
||||
|
|
Loading…
Reference in New Issue