Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/asmcnc/comms/router_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,12 @@ def jog_spindle_to_laser_datum(self, axis):

return True

def set_machine_unit_to_inch(self):
self.s.write_command('G20')

def set_machine_unit_to_mm(self):
self.s.write_command('G21')

# Realtime XYZ feed adjustment
def feed_override_reset(self):
self.s.write_realtime('\x90', altDisplayText = 'Feed override RESET')
Expand Down
6 changes: 6 additions & 0 deletions src/asmcnc/comms/serial_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ def end_stream(self):

Logger.info("Ending stream...")

# Always switch to mm, in case the job put you in inches
self.m.set_machine_unit_to_mm()

# Reset flags
self.is_job_streaming = False
self.is_stream_lines_remaining = False
Expand Down Expand Up @@ -738,6 +741,9 @@ def end_stream(self):

def cancel_stream(self):

# Always switch to mm, in case the job put you in inches
self.m.set_machine_unit_to_mm()

self.is_job_streaming = False # make grbl_scanner() stop stuffing buffer
self.is_stream_lines_remaining = False
self.m.set_pause(False)
Expand Down
17 changes: 16 additions & 1 deletion src/asmcnc/skavaUI/screen_job_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class JobRecoveryScreen(Screen):
scroll_up_event = None
scroll_down_event = None

using_inches = False

def __init__(self, **kwargs):
super(JobRecoveryScreen, self).__init__(**kwargs)
self.sm = kwargs["screen_manager"]
Expand Down Expand Up @@ -531,6 +533,14 @@ def update_display(self):
)
else:
self.pos_z = 0.0

# Check if these distances are measured in inches, so that GO XY can work correctly
unit_line = next((s for s in reversed(self.jd.job_gcode[:self.selected_line_index + 1]) if re.search("G2[0,1]", s)), None)
if unit_line:
self.using_inches = "G20" in unit_line
else:
self.using_inches = False

self.pos_label.text = "wX: %s | wY: %s | wZ: %s" % (
str(self.pos_x),
str(self.pos_y),
Expand Down Expand Up @@ -584,13 +594,18 @@ def get_info(self):
popup_info.PopupScrollableInfo(self.sm, self.l, 760, info)

def go_xy(self):
# Pick min out of safe z height and limit_switch_safety_distance, in case positive value is calculated, which causes errors
z_safe_height = min(
self.m.z_wco() + self.sm.get_screen("home").job_box.range_z[1],
-self.m.limit_switch_safety_distance,
)
# If Z is below safe height, then raise it up
if self.m.mpos_z() < z_safe_height:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that G20 changes the pos read? So this logic might not work after the unit change

self.m.s.write_command("G53 G0 Z%s F750" % z_safe_height)
self.m.s.write_command("G90 G0 X%s Y%s" % (self.pos_x, self.pos_y))
if self.using_inches:
self.m.set_machine_unit_to_inch()
self.m.s.write_command('G90 G0 X%s Y%s' % (self.pos_x, self.pos_y))
self.m.set_machine_unit_to_mm()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you switch back to mm if the recovered file is in inches? Doesn't that mean, that when you re-run the job from the recover position all subsequent moves will be in mm again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is just used for the GO XY button on the job recovery screen - it sets to inches just while it moves to the position currently being displayed on that screen, then it needs to go back to mm, and when the user runs the job recovery file, then it will insert the G20 back in


def back_to_home(self):
self.jd.reset_recovery()
Expand Down