Skip to content

Commit f3ba5a1

Browse files
authored
Merge pull request #278 from Carvera-Community/pr_fix_set_origin
fixed the set origin popup to calculate the offsets on pressing the different options
2 parents 58872a1 + 54814a9 commit f3ba5a1

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fix: Resolve the keysboard_mode config load error that occurs when reconnecting the Controller after it loses connection
1212
- Fix: Red origin dot in preview visualisation on config-and-run screen returned
1313
- Fix: Last open folder was using temp directory instead of actual user selected location
14+
- Fix: Set origin popup now properly shows the current offset to the anchors when switching options. When set to 'current pos' the offset default to 0.
1415

1516
[0.9.1]
1617
- Fix: 3D Probe tool number missing a "9". Should be 999990 not 99990

carveracontroller/main.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,12 @@ def on_open(self):
315315
if self.coord_popup.config['origin']['anchor'] == 2:
316316
x = round(CNC.vars['wcox'] + laser_x - CNC.vars["anchor1_x"] - CNC.vars["anchor2_offset_x"], 4)
317317
y = round(CNC.vars['wcoy'] + laser_y - CNC.vars["anchor1_y"] - CNC.vars["anchor2_offset_y"], 4)
318-
else:
318+
elif self.coord_popup.config['origin']['anchor'] == 1:
319319
x = round(CNC.vars['wcox'] + laser_x - CNC.vars["anchor1_x"], 4)
320320
y = round(CNC.vars['wcoy'] + laser_y - CNC.vars["anchor1_y"], 4)
321+
else:
322+
x = 0
323+
y = 0
321324
self.txt_x_offset.text = str(x)
322325
Utils.bind_auto_select_to_text_input(self.txt_x_offset)
323326
self.txt_y_offset.text = str(y)
@@ -331,6 +334,29 @@ def selected_anchor(self):
331334
elif self.cbx_current_position.active:
332335
return 4
333336
return 1
337+
338+
def update_offsets(self):
339+
# Use the same logic as CoordPopup.load_origin_label to set offsets
340+
app = App.get_running_app()
341+
x = 0
342+
y = 0
343+
if app.has_4axis:
344+
x = round(CNC.vars["wcox"] - CNC.vars['anchor1_x'] - CNC.vars['rotation_offset_x'], 4)
345+
y = round(CNC.vars['wcoy'] - CNC.vars['anchor1_y'] - CNC.vars['rotation_offset_y'], 4)
346+
else:
347+
laser_x = CNC.vars['laser_module_offset_x'] if CNC.vars['lasermode'] else 0.0
348+
laser_y = CNC.vars['laser_module_offset_y'] if CNC.vars['lasermode'] else 0.0
349+
if self.cbx_anchor1.active:
350+
x = round(CNC.vars['wcox'] + laser_x - CNC.vars["anchor1_x"], 4)
351+
y = round(CNC.vars['wcoy'] + laser_y - CNC.vars["anchor1_y"], 4)
352+
elif self.cbx_anchor2.active:
353+
x = round(CNC.vars['wcox'] + laser_x - CNC.vars["anchor1_x"] - CNC.vars["anchor2_offset_x"], 4)
354+
y = round(CNC.vars['wcoy'] + laser_y - CNC.vars["anchor1_y"] - CNC.vars["anchor2_offset_y"], 4)
355+
elif self.cbx_current_position.active:
356+
x = 0
357+
y = 0
358+
self.txt_x_offset.text = str(x)
359+
self.txt_y_offset.text = str(y)
334360

335361
class ZProbePopup(ModalView):
336362
def __init__(self, coord_popup, **kwargs):

carveracontroller/makera.kv

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,36 +1402,48 @@
14021402
id: cbx_anchor1
14031403
group: 'anchor'
14041404
active: True
1405+
on_press: root.update_offsets()
14051406
disabled: app.has_4axis
14061407
MCQLabel:
1407-
on_press: cbx_anchor1._do_press()
1408+
on_press:
1409+
cbx_anchor1._do_press()
1410+
root.update_offsets()
14081411
text: tr._('Anchor1')
14091412
disabled: app.has_4axis
14101413
MCQCheckBox:
14111414
id: cbx_anchor2
14121415
group: 'anchor'
14131416
active: False
1417+
on_press: root.update_offsets()
14141418
disabled: app.has_4axis
14151419
MCQLabel:
1416-
on_press: cbx_anchor2._do_press()
1420+
on_press:
1421+
cbx_anchor2._do_press()
1422+
root.update_offsets()
14171423
text: tr._('Anchor2')
14181424
disabled: app.has_4axis
14191425
MCQCheckBox:
14201426
id: cbx_4axis_origin
14211427
group: 'anchor'
14221428
active: False
1429+
on_press: root.update_offsets()
14231430
disabled: not app.has_4axis
14241431
MCQLabel:
1425-
on_press: cbx_4axis_origin._do_press()
1432+
on_press:
1433+
cbx_4axis_origin._do_press()
1434+
root.update_offsets()
14261435
text: tr._('4Axis Origin')
14271436
disabled: not app.has_4axis
14281437
MCQCheckBox:
14291438
id: cbx_current_position
14301439
group: 'anchor'
14311440
active: False
1441+
on_press: root.update_offsets()
14321442
disabled: app.has_4axis
14331443
MCQLabel:
1434-
on_press: cbx_current_position._do_press()
1444+
on_press:
1445+
cbx_current_position._do_press()
1446+
root.update_offsets()
14351447
text: tr._('Current Pos')
14361448
disabled: app.has_4axis
14371449
# Label:

0 commit comments

Comments
 (0)