z_tilt: expose an 'applied' status to allow macros to skip QGL/Z_TILT_ADJUST (#4313)

This is useful for macros that'd like to skip QGL if already leveled,
e.g.:

```
    {% if not printer.quad_gantry_level.applied %}
        QUAD_GANTRY_LEVEL
    {% endif %}
```

Signed-off-by: Michael Rose <elementation@gmail.com>
This commit is contained in:
Michael Rose 2021-06-02 09:11:19 -06:00 committed by GitHub
parent c148f17ea3
commit 27f8cf025e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 2 deletions

View file

@ -33,6 +33,7 @@ class QuadGantryLevel:
if len(self.probe_helper.probe_points) != 4:
raise config.error(
"Need exactly 4 probe points for quad_gantry_level")
self.z_status = z_tilt.ZAdjustStatus(self.printer)
self.z_helper = z_tilt.ZAdjustHelper(config, 4)
gantry_corners = config.get('gantry_corners').split('\n')
try:
@ -54,6 +55,7 @@ class QuadGantryLevel:
cmd_QUAD_GANTRY_LEVEL_help = (
"Conform a moving, twistable gantry to the shape of a stationary bed")
def cmd_QUAD_GANTRY_LEVEL(self, gcmd):
self.z_status.reset()
self.retry_helper.start(gcmd)
self.probe_helper.start_probe(gcmd)
def probe_finalize(self, offsets, positions):
@ -114,7 +116,9 @@ class QuadGantryLevel:
speed = self.probe_helper.get_lift_speed()
self.z_helper.adjust_steppers(z_adjust, speed)
return self.retry_helper.check_retry(z_positions)
return self.z_status.check_retry_result(
self.retry_helper.check_retry(z_positions))
def linefit(self,p1,p2):
if p1[1] == p2[1]:
# Straight line
@ -124,6 +128,8 @@ class QuadGantryLevel:
return m,b
def plot(self,f,x):
return f[0]*x + f[1]
def get_status(self, eventtime):
return self.z_status.get_status(eventtime)
def load_config(config):
return QuadGantryLevel(config)