Skip to content

Commit

Permalink
t5uid1: Improve Python 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Desuuuu committed May 26, 2023
1 parent bd9fd73 commit baae7f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions klippy/extras/t5uid1/dgus_reloaded/routines.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ script:
{ abort_page_switch() }
{% elif printer.toolhead.homed_axes == "xyz" %}
{% set t5uid1 = printer.t5uid1 %}
{% set x = (t5uid1.limits.x_min + t5uid1.limits.x_max) / 2 %}
{% set y = (t5uid1.limits.y_min + t5uid1.limits.y_max) / 2 %}
{% set x = (t5uid1.limits.x_min + t5uid1.limits.x_max) / 2.0 %}
{% set y = (t5uid1.limits.y_min + t5uid1.limits.y_max) / 2.0 %}
{% if printer.gcode_move.gcode_position.z < 10 %}
G1 Z10 F600
{% endif %}
Expand All @@ -136,8 +136,8 @@ script:
{ abort_page_switch() }
{% elif printer.toolhead.homed_axes == "xyz" %}
{% set t5uid1 = printer.t5uid1 %}
{% set x = (t5uid1.limits.x_min + t5uid1.limits.x_max) / 2 %}
{% set y = (t5uid1.limits.y_min + t5uid1.limits.y_max) / 2 %}
{% set x = (t5uid1.limits.x_min + t5uid1.limits.x_max) / 2.0 %}
{% set y = (t5uid1.limits.y_min + t5uid1.limits.y_max) / 2.0 %}
{% if printer.gcode_move.gcode_position.z < 5 %}
G1 Z5 F600
{% endif %}
Expand Down
14 changes: 7 additions & 7 deletions klippy/extras/t5uid1/dgus_reloaded/vars_in.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ script:
{% if "z" not in printer.toolhead.homed_axes %}
{% do set_message("Homing required") %}
{% else %}
{% set offset = data|float / 10 ** 2 %}
{% set offset = data|float / 100 %}
SET_GCODE_OFFSET Z={offset} MOVE=1
{% do start_routine("trigger_full_update") %}
{% endif %}
Expand Down Expand Up @@ -236,7 +236,7 @@ script:
{% if "z" not in printer.toolhead.homed_axes %}
{% do set_message("Homing required") %}
{% else %}
{% set offset = data|float / 10 ** 2 %}
{% set offset = data|float / 100 %}
SET_GCODE_OFFSET Z={offset} MOVE=1
{% do start_routine("trigger_full_update") %}
{% endif %}
Expand Down Expand Up @@ -289,8 +289,8 @@ script:
{% set hop = 5 %}
{% set t5uid1 = printer.t5uid1 %}
{% if data == 1 %}
{% 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 %}
{% set x = (t5uid1.limits.x_max - t5uid1.limits.x_min + t5uid1.limits.x_min_inset - t5uid1.limits.x_max_inset) / 2.0 %}
{% set y = (t5uid1.limits.y_max - t5uid1.limits.y_min + t5uid1.limits.y_min_inset - t5uid1.limits.y_max_inset) / 2.0 %}
{% elif data == 2 %}
{% set x = t5uid1.limits.x_min + t5uid1.limits.x_min_inset %}
{% set y = t5uid1.limits.y_min + t5uid1.limits.y_min_inset %}
Expand Down Expand Up @@ -442,7 +442,7 @@ script:
{% do set_message("Homing required") %}
{% else %}
{% set t5uid1 = printer.t5uid1 %}
{% set pos = data|float / 10 ** 1 %}
{% set pos = data|float / 10 %}
{% if pos < t5uid1.limits.x_min %}
{% set pos = t5uid1.limits.x_min %}
{% elif pos > t5uid1.limits.x_max %}
Expand All @@ -465,7 +465,7 @@ script:
{% do set_message("Homing required") %}
{% else %}
{% set t5uid1 = printer.t5uid1 %}
{% set pos = data|float / 10 ** 1 %}
{% set pos = data|float / 10 %}
{% if pos < t5uid1.limits.y_min %}
{% set pos = t5uid1.limits.y_min %}
{% elif pos > t5uid1.limits.y_max %}
Expand All @@ -488,7 +488,7 @@ script:
{% do set_message("Homing required") %}
{% else %}
{% set t5uid1 = printer.t5uid1 %}
{% set pos = data|float / 10 ** 1 %}
{% set pos = data|float / 10 %}
{% if pos < t5uid1.limits.z_min %}
{% set pos = t5uid1.limits.z_min %}
{% elif pos > t5uid1.limits.z_max %}
Expand Down
16 changes: 8 additions & 8 deletions klippy/extras/t5uid1/t5uid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
def map_value_range(x, in_min, in_max, out_min, out_max):
return int(round((x - in_min)
* (out_max - out_min)
/ (in_max - in_min)
// (in_max - in_min)
+ out_min))

def get_duration(seconds):
if type(seconds) is not int:
seconds = int(seconds)
if seconds < 0:
seconds = 0
minutes = seconds / 60
hours = minutes / 60
days = hours / 24
minutes = seconds // 60
hours = minutes // 60
days = hours // 24
days %= 365
hours %= 24
minutes %= 60
Expand Down Expand Up @@ -830,10 +830,10 @@ def limits(self):
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)
x_min_inset = min(self._x_min_inset, (x_max - x_min) / 2.0)
x_max_inset = min(self._x_max_inset, (x_max - x_min) / 2.0)
y_min_inset = min(self._y_min_inset, (y_max - y_min) / 2.0)
y_max_inset = min(self._y_max_inset, (y_max - y_min) / 2.0)
return {
'x_min': x_min,
'x_max': x_max,
Expand Down

0 comments on commit baae7f3

Please sign in to comment.