From a8e13181a27db78f9052fbb160b89d6b65922817 Mon Sep 17 00:00:00 2001 From: Desuuuu Date: Sat, 30 Jan 2021 12:19:43 +0100 Subject: [PATCH] add configuration option for manual leveling inset --- config/sample-t5uid1.cfg | 22 +++++++++++++++---- .../extras/t5uid1/dgus_reloaded/vars_in.cfg | 21 +++++++++--------- klippy/extras/t5uid1/t5uid1.py | 15 ++++++++++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/config/sample-t5uid1.cfg b/config/sample-t5uid1.cfg index 8ecb5944..cc9518fc 100644 --- a/config/sample-t5uid1.cfg +++ b/config/sample-t5uid1.cfg @@ -18,9 +18,23 @@ firmware: dgus_reloaded #notification_sound: # The index of the sound to play when certain events happened. Defaults to # being provided by the selected firmware. +#x_min_inset: 30.0 +# The distance (in mm) from the minimum X position used by the manual leveling +# screen. +#x_max_inset: 30.0 +# The distance (in mm) from the maximum X position used by the manual leveling +# screen. +#y_min_inset: 30.0 +# The distance (in mm) from the minimum Y position used by the manual leveling +# screen. +#y_max_inset: 30.0 +# The distance (in mm) from the maximum Y position used by the manual leveling +# screen. #z_min: -# This can be used to provide a lower limit to Z moves. Movements will still -# be limited by your [stepper_z] configuration values. +# This can be used to provide a lower limit (in mm) to Z moves done using the +# touschreen. Movements will still be limited by your [stepper_z] +# configuration values. #z_max: -# This can be used to provide an upper limit to Z moves. Movements will still -# be limited by your [stepper_z] configuration values. +# This can be used to provide an upper limit (in mm) to Z moves done using the +# touschreen. Movements will still be limited by your [stepper_z] +# configuration values. diff --git a/klippy/extras/t5uid1/dgus_reloaded/vars_in.cfg b/klippy/extras/t5uid1/dgus_reloaded/vars_in.cfg index 287307d6..633fa455 100644 --- a/klippy/extras/t5uid1/dgus_reloaded/vars_in.cfg +++ b/klippy/extras/t5uid1/dgus_reloaded/vars_in.cfg @@ -274,24 +274,23 @@ script: {% elif is_busy() %} {% do set_message("Busy") %} {% else %} - {% set inset = 30 %} {% set hop = 5 %} {% set t5uid1 = printer.t5uid1 %} {% if data == 1 %} - {% set x = (t5uid1.limits.x_max - t5uid1.limits.x_min) / 2 %} - {% set y = (t5uid1.limits.y_max - t5uid1.limits.y_min) / 2 %} + {% set x = (t5uid1.limits.x_max - t5uid1.limits.x_min + t5uid1.limits.x_min_inset - t5uid1.limits.x_max_inset) / 2 %} + {% set y = (t5uid1.limits.y_max - t5uid1.limits.y_min + t5uid1.limits.y_min_inset - t5uid1.limits.y_max_inset) / 2 %} {% elif data == 2 %} - {% set x = t5uid1.limits.x_min + inset %} - {% set y = t5uid1.limits.y_min + inset %} + {% set x = t5uid1.limits.x_min + t5uid1.limits.x_min_inset %} + {% set y = t5uid1.limits.y_min + t5uid1.limits.y_min_inset %} {% elif data == 3 %} - {% set x = t5uid1.limits.x_max - inset %} - {% set y = t5uid1.limits.y_min + inset %} + {% set x = t5uid1.limits.x_max - t5uid1.limits.x_max_inset %} + {% set y = t5uid1.limits.y_min + t5uid1.limits.y_min_inset %} {% elif data == 4 %} - {% set x = t5uid1.limits.x_max - inset %} - {% set y = t5uid1.limits.y_max - inset %} + {% set x = t5uid1.limits.x_max - t5uid1.limits.x_max_inset %} + {% set y = t5uid1.limits.y_max - t5uid1.limits.y_max_inset %} {% elif data == 5 %} - {% set x = t5uid1.limits.x_min + inset %} - {% set y = t5uid1.limits.y_max - inset %} + {% set x = t5uid1.limits.x_min + t5uid1.limits.x_min_inset %} + {% set y = t5uid1.limits.y_max - t5uid1.limits.y_max_inset %} {% endif %} SAVE_GCODE_STATE NAME=state_level_manual_point G90 diff --git a/klippy/extras/t5uid1/t5uid1.py b/klippy/extras/t5uid1/t5uid1.py index 2e0445b6..c8537d84 100644 --- a/klippy/extras/t5uid1/t5uid1.py +++ b/klippy/extras/t5uid1/t5uid1.py @@ -15,6 +15,7 @@ T5UID1_firmware_cfg = { DEFAULT_VOLUME = 75 DEFAULT_BRIGHTNESS = 100 +DEFAULT_INSET = 30.0 T5UID1_CMD_WRITEVAR = 0x82 T5UID1_CMD_READVAR = 0x83 @@ -133,6 +134,10 @@ class T5UID1: self._notification_sound = config.getint('notification_sound', firmware_cfg['notification_sound'], minval=-1, maxval=255) + self._x_min_inset = config.getfloat('x_min_inset', DEFAULT_INSET, minval=0.0) + self._x_max_inset = config.getfloat('x_max_inset', DEFAULT_INSET, minval=0.0) + self._y_min_inset = config.getfloat('y_min_inset', DEFAULT_INSET, minval=0.0) + self._y_max_inset = config.getfloat('y_max_inset', DEFAULT_INSET, minval=0.0) self._z_min = config.getfloat('z_min', None) self._z_max = config.getfloat('z_max', None) @@ -801,13 +806,21 @@ class T5UID1: and self._z_max < z_max and self._z_max > z_min): z_max = self._z_max + x_min_inset = min(self._x_min_inset, (x_max - x_min) / 2) + x_max_inset = min(self._x_max_inset, (x_max - x_min) / 2) + y_min_inset = min(self._y_min_inset, (y_max - y_min) / 2) + y_max_inset = min(self._y_max_inset, (y_max - y_min) / 2) return { 'x_min': x_min, 'x_max': x_max, 'y_min': y_min, 'y_max': y_max, 'z_min': z_min, - 'z_max': z_max + 'z_max': z_max, + 'x_min_inset': x_min_inset, + 'x_max_inset': x_max_inset, + 'y_min_inset': y_min_inset, + 'y_max_inset': y_max_inset } def set_message(self, message):