So I'm experimenting with macros in Pronterface,

So I’m experimenting with macros in Pronterface, but figured I’d have to know python to do some more advanced stuff. Which I don’t, unfortunately.

Basically, what I want to do is to make a conditional loop based on M114 (endstops status):

do if z_min=H, else , or maybe
while z_min=L, do

I’ve checked the Printrun manual, but it assumes one already knows python :-/ Please help!

Didn’t @foosel rant about this a while ago?

Python is the easy part, most of the difficulty is because pronterface is not tightly coupled with the firmware. There is no easy way to directly read the status of an endstop.

What you need to do is

  1. Send a command to query the status
  2. Wait for a response.
  3. Parse the response for the result.

(And this gets messed up if you have the temperature graph enabled.)

! # Send the probe down
! self.p.send(‘G1 Z0’)
! # This should send “ok” immediately, then “echo:endstops hit” if it hits a stop
! # We can monitor for an incoming line using the self.p.clear flag
! self.p.clear = False
! for my_wait in range(0, pz_wait_long):
! time.sleep(0.001)
! if self.p.clear:
! break
! self.p.clear = True
! _CurrentLastLine = self.p.log[-1]
! # Line should say “echo:endstops hit: Z:nnn”
! if (not _CurrentLastLine.startswith(‘echo:endstops hit: Z:’)):
! pz_args = 0
! return

I started with this: