Custom Control: Z-Offset


#1

Hello,
I have added a costum command to read and set the Z offset. But the problem is, that reading does not work (setting the value works).
When I press "Get" no value appears.

I use pure marlin. I think that the line starting with " regex:" is not correct. Anyone can explain how to set this correcty?

Output of M851 is:

Send: M851
Recv: echo:Probe Z Offset: -4.20
Recv: ok P15 B3

Anyone can have a look at my code?
Thank you!

controls:
- children:
  - command: M851
    default: ''
    name: Get
    regex: z zero offset value:(?P<offset>\d+(\.\d*))
    template: 'Current: {offset} mm'
    width: '5'
  - command: M851 Z%(offset)s
    input:
    - default: '0.00'
      name: New (mm)
      parameter: offset
      slider: false
    name: Set
    width: '5'
  - command: G28 Z0
    name: Home Z
    width: '2'
  collapsed: true
  layout: horizontal_grid
  name: Adjust Z Offset

#2

Your guess is probably right.

In OSX at a command prompt

echo "Probe Z Offset: -4.20" | sed -En 's/Probe Z Offset:[^\d]?(\d*)/\1/p'
-4.20

Not knowing exactly what's going on behind-the-scenes, you might try:

  • Edit the regex to minimally make the search closer to your reality

I'm not sure if your config.yaml variable means:

  1. Create a json object behind-the-scenes which will read like z zero offset value: -4.20
  2. Look for "z zero offset value:" in the printer response followed by something else

#3

I use this site https://www.regexpal.com/ when I have regex's to test. I have noticed though that sometimes regex's work there but not in other software and vise versa, but it seems to work there and octoprint. You could test your regexp to see if it's actually searching properly.

Copy your terminal output into its sample text box, and your regex up into the regex field up top. That's how I create my terminal filters to filter out random stuff. Usually works pretty well.