add x/y limits for touchscreen moves

This commit is contained in:
Desuuuu 2021-03-24 14:48:06 +01:00
parent 278b1c0210
commit a3d6b64ba4
No known key found for this signature in database
GPG Key ID: 85943F4B2C2CE0DC
2 changed files with 34 additions and 6 deletions

View File

@ -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.

View File

@ -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):