So here is an example using a python remap.
To setup python remap in your config you will need to:
1. In your config folder create a folder named 'python'
2. save this to the 'python' folder as 'toplevel.py':
3. save this to the 'python' folder as 'remap.py'
Code:
import sys
import traceback
from interpreter import *
import emccanon
from util import lineno, call_pydevd
import hal
from tkinter import *
from tkinter import messagebox
def g69_core(self):
global coordinates
if self.task == 1:
try:
def button_pressed(value):
global coordinates
coordinates = value
ws.destroy()
ws = Tk()
# Tkinter way to find the screen resolution
screen_width = ws.winfo_screenwidth()
screen_height = ws.winfo_screenheight()
size = tuple(int(_) for _ in ws.geometry().split('+')[0].split('x'))
x = screen_width/2 - size[0]/2
y = screen_height/2 - size[1]/2
ws.geometry("400x120+%d+%d" % (x, y))
ws.title('LinuxCNC')
#ws.geometry('200x110')
Label(ws, text=("Some text here\n")).pack()
b1 = Button(ws, text=('Move to X1'), padx=10, pady=5, command=lambda: button_pressed('X1'))
b1.pack(pady=5)
b2 = Button(ws, text=('Move to X-2'), padx=10, pady=5, command=lambda: button_pressed('X-2'))
b2.pack(padx=5)
ws.mainloop()
except Exception as e:
print('ERROR: show_operator_message: ', e)
self.execute('G0' + coordinates, lineno())
yield INTERP_EXECUTE_FINISH
return INTERP_OK
4. save this as 'g69remap.ngc' to a folder listed in your ini file under [RS274NGC] SUBROUTINE_PATH
Code:
; this is the wrapper remap for G69
o<g69remap>sub
M66 L0 E0 ; force sync, stop read ahead
M469 ; call the python G69_core code
M66 L0 E0 ; force sync, stop read ahead
o<g69remap>endsub
m2
5. Add this to your ini file (if not already included)
Code:
[PYTHON]
# where to find the Python code:
# code specific for this configuration
PATH_APPEND = ./python
# import the following Python module
TOPLEVEL = ./python/toplevel.py
# the higher the more verbose tracing of the Python plugin
LOG_LEVEL = 3
6. Add this to the [RS274NGC] section of your ini file
Code:
REMAP = G69 modalgroup=1 ngc=g69remap
REMAP = M469 modalgroup=10 python3=g69_core
This should give you a new GCode 'G69' which should then open a popup window and give you two options to move:
Upon pressing a button the machine will move to the selected position and the program will continue.