From a3d6b64ba4daf0ba45ee3cf6d0a0cab706e8682d Mon Sep 17 00:00:00 2001 From: Desuuuu Date: Wed, 24 Mar 2021 14:48:06 +0100 Subject: [PATCH] add x/y limits for touchscreen moves --- config/sample-t5uid1.cfg | 20 ++++++++++++++------ klippy/extras/t5uid1/t5uid1.py | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/sample-t5uid1.cfg b/config/sample-t5uid1.cfg index cc9518fc..dc067503 100644 --- a/config/sample-t5uid1.cfg +++ b/config/sample-t5uid1.cfg @@ -30,11 +30,19 @@ firmware: dgus_reloaded #y_max_inset: 30.0 # The distance (in mm) from the maximum Y position used by the manual leveling # screen. +#x_min: +# This can be used to provide a lower limit (in mm) to X moves done using the +# touschreen. Movements will still be limited by your [stepper_x] +# configuration values. +#x_max: +# This can be used to provide an upper limit (in mm) to X moves done using the +# touschreen. Movements will still be limited by your [stepper_x] +# configuration values. +#y_min: +# Same as x_min for the Y axis. +#y_max: +# Same as x_max for the Y axis. #z_min: -# 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. +# Same as x_min for the Z axis. #z_max: -# 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. +# Same as x_max for the Z axis. diff --git a/klippy/extras/t5uid1/t5uid1.py b/klippy/extras/t5uid1/t5uid1.py index c8537d84..203bf065 100644 --- a/klippy/extras/t5uid1/t5uid1.py +++ b/klippy/extras/t5uid1/t5uid1.py @@ -138,6 +138,10 @@ class T5UID1: 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._x_min = config.getfloat('x_min', None) + self._x_max = config.getfloat('x_max', None) + self._y_min = config.getfloat('y_min', None) + self._y_max = config.getfloat('y_max', None) self._z_min = config.getfloat('z_min', None) self._z_max = config.getfloat('z_max', None) @@ -798,6 +802,22 @@ class T5UID1: x_min, x_max = kin.rails[0].get_range() y_min, y_max = kin.rails[1].get_range() z_min, z_max = kin.rails[2].get_range() + if (self._x_min is not None + and self._x_min > x_min + and self._x_min < x_max): + x_min = self._x_min + if (self._x_max is not None + and self._x_max < x_max + and self._x_max > x_min): + x_max = self._x_max + if (self._y_min is not None + and self._y_min > y_min + and self._y_min < y_max): + y_min = self._y_min + if (self._y_max is not None + and self._y_max < y_max + and self._y_max > y_min): + y_max = self._y_max if (self._z_min is not None and self._z_min > z_min and self._z_min < z_max):