Skip to content

Macro for display distance on Screen

Mark edited this page Aug 30, 2024 · 2 revisions

Here is a macro for klipper that can display distance on the screen LCD12864 and on the console.

for example:

M155 S1, then it will read and display the distance every 1 second.

Disable it by M155 S0.

[gcode_macro M155]
description: read and display distance on the screen on a 'S'chedule.
variable_repeat_timer: 0
gcode:
  {% if 'S' in params %}
  {% set seconds = params.S|int %}
    #RESPOND MSG="time in seconds:"{seconds}
    SET_GCODE_VARIABLE MACRO=M155 VARIABLE=repeat_timer VALUE={seconds}
    UPDATE_DELAYED_GCODE ID=respond_temp_timer DURATION={seconds}
  {% endif %}
  
[delayed_gcode respond_temp_timer]
initial_duration: 0
gcode:
#    {% set time = params.VALUE|int %}
#    RESPOND MSG="time2 in seconds:"{params.REPEAT}%
    M102 S-2
    UPDATE_DELAYED_GCODE ID=respond_temp_timer DURATION={printer['gcode_macro M155'].repeat_timer}