digitalninja-ro/klipper-neopixel

Octoprint Print Progress

Puffball101961 opened this issue · 11 comments

Does the progress not properly work with octoprint? I have tried to implement the macro, the temperature progress does not work when printing through octoprint.

The macro is for Klipper, so should work regardless UI (fluidd, mainsail or octoprint). Did your NeoPixel led works without macro? Can you turn on/off or change the color? Can you post your [neopixel] section from config and how you call the macro?

Thank you

I am able to control my leds fine, and the extruded heating progress mode works fine when I put it in the gcode. The print progress however doesn't do anything.

How and when do you call the macros? Write down the macro calls and specify where/when do you run the macro. A klippy.log will help. Thank you.

Sorry for the late reply,

I have the macros in my cura start gcode:

M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
NEOPIXEL_DISPLAY LED=neo TYPE=extruder_temp MODE=progress
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
NEOPIXEL_DISPLAY LED=neo TYPE=bed_temp MODE=progress
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
G28 ; Home all axes
M117 Purging extruder
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
NEOPIXEL_DISPLAY LED=neo TYPE=print_percent MODE=progress
M117 Printing...

For reference: The extruder_temp and bed_temp lines work fine, its just the print_percent line that isn't doing anything. I changed in the macro file the "background" colour for the print progress to be white. When the print starts it changes the leds from red (from the temperature progress) to white, but during the print they all stay white.

Klippy.log:

===== Config file =====
[stepper_x]
step_pin = PB13
dir_pin = !PB12
enable_pin = !PB14
microsteps = 16
rotation_distance = 40
endstop_pin = ^PC0
position_endstop = 0
position_max = 245
homing_speed = 50

[tmc2209 stepper_x]
uart_pin = PC11
tx_pin = PC10
uart_address = 0
run_current = 0.580
stealthchop_threshold = 999999

[stepper_y]
step_pin = PB10
dir_pin = !PB2
enable_pin = !PB11
microsteps = 16
rotation_distance = 40
endstop_pin = ^PC1
position_endstop = 0
position_max = 245
homing_speed = 50

[tmc2209 stepper_y]
uart_pin = PC11
tx_pin = PC10
uart_address = 2
run_current = 0.580
stealthchop_threshold = 999999

[stepper_z]
step_pin = PB0
dir_pin = PC5
enable_pin = !PB1
microsteps = 16
rotation_distance = 8
endstop_pin = probe:z_virtual_endstop
position_max = 250
position_min = -1.0

[tmc2209 stepper_z]
uart_pin = PC11
tx_pin = PC10
uart_address = 1
run_current = 0.580
stealthchop_threshold = 999999

[extruder]
step_pin = PB3
dir_pin = !PB4
enable_pin = !PD2
microsteps = 16
rotation_distance = 33.500
nozzle_diameter = 0.400
filament_diameter = 1.750
heater_pin = PC8
sensor_type = EPCOS 100K B57560G104F
sensor_pin = PA0
min_temp = 0
max_temp = 250
pressure_advance = 0.25
control = pid
pid_kp = 26.010
pid_ki = 1.213
pid_kd = 139.478

[tmc2209 extruder]
uart_pin = PC11
tx_pin = PC10
uart_address = 3
run_current = 0.650
stealthchop_threshold = 999999

[heater_bed]
heater_pin = PC9
sensor_type = ATC Semitec 104GT-2
sensor_pin = PC3
control = pid
pid_kp = 54.027
pid_ki = 0.770
pid_kd = 948.182
min_temp = 0
max_temp = 130

[heater_fan nozzle_cooling_fan]
pin = PC7

[fan]
pin = PC6

[mcu]
serial = /dev/serial/by-id/usb-Klipper_stm32f103xe_30FFD6054255353842650157-if00

[printer]
kinematics = cartesian
max_velocity = 300
max_accel = 3000
max_z_velocity = 5
max_z_accel = 100

[neopixel neo]
pin = PA8
chain_count = 13
color_order = GRB
initial_red = 0.9
initial_green = 0.9
initial_blue = 0.9

[bltouch]
sensor_pin = PC14
control_pin = PA1
x_offset = -42
y_offset = -5
pin_move_time = 0.4
samples = 3
z_offset = 1.551

[safe_z_home]
home_xy_position = 117.5,117.5
speed = 100
z_hop = 10
z_hop_speed = 10

[screws_tilt_adjust]
screw1 = 74,47
screw1_name = front left screw
screw2 = 245, 47
screw2_name = front right screw
screw3 = 245, 217
screw3_name = rear right screw

screw4 = 74,217
screw4_name = rear left screw
screw_thread = CW-M4

[static_digital_output usb_pullup_enable]
pins = !PA14

[board_pins]
aliases =
        EXP1_1=PB5,  EXP1_3=PA9,   EXP1_5=PA10, EXP1_7=PB8,  EXP1_9=<GND>,
        EXP1_2=PA15, EXP1_4=<RST>, EXP1_6=PB9,  EXP1_8=PB15, EXP1_10=<5V>

[display]
lcd_type = st7920
cs_pin = EXP1_7
sclk_pin = EXP1_6
sid_pin = EXP1_8
encoder_pins = ^EXP1_5, ^EXP1_3
click_pin = ^!EXP1_2

[output_pin beeper]
pin = EXP1_1

[pause_resume]

[virtual_sdcard]
path = ~/.octoprint/uploads

[gcode_macro NEOPIXEL_DISPLAY]
gcode =
        {% set led = params.LED %}
        {% set type = params.TYPE %}
        {% set mode = params.MODE %}
        {% set my_neopixel = printer.configfile.config['neopixel ' ~ led] %}
        {% if mode == 'progress' %}
        {% for i in range(my_neopixel.chain_count|int) %}
        SET_LED_TEMPLATE LED={led} INDEX={i+1} TEMPLATE={'led_' ~ type ~ '_' ~ mode} param_led_num={i+1} param_led_total={my_neopixel.chain_count|int}
        {% endfor %}
        {% endif %}
        {% if mode == 'glow' %}
        SET_LED_TEMPLATE LED={led} TEMPLATE={'led_' ~ type ~ '_' ~ mode}
        {% endif %}

[display_template led_extruder_temp_glow]
text =
        {% if printer.extruder.target > 0.0 %}
        {%  set temp = printer.extruder.target %}
        {% else %}
        {% set temp = printer.configfile.config.extruder.max_temp %}
        {% endif %}
        {% set ratio = printer.extruder.temperature / temp|float %}
        {ratio}, 0.0, {1-ratio}, 0.0

[display_template led_extruder_temp_progress]
param_led_num = 0
param_led_total = 1
text =
        {% if printer.extruder.target > 0.0 %}
        {%  set temp = printer.extruder.target %}
        {% else %}
        {% set temp = printer.configfile.config.extruder.max_temp %}
        {% endif %}
        {% set ratio = printer.extruder.temperature / temp|float %}
        {% set led_ratio = param_led_num|float / param_led_total %}
        {% if ratio > led_ratio %}
        {led_ratio}, 0.0, 0.0, 0.0
        {% else %}
        0.0, 0.0, 0.0, 0.0
		        {% endif %}

[display_template led_bed_temp_glow]
text =
        {% if printer.heater_bed.target > 0.0 %}
        {%  set temp = printer.heater_bed.target %}
        {% else %}
        {% set temp = printer.configfile.config.heater_bed.max_temp %}
        {% endif %}
        {% set ratio = printer.heater_bed.temperature / temp|float %}
        {ratio}, 0.0, {1-ratio}, 0.0

[display_template led_bed_temp_progress]
param_led_num = 0
param_led_total = 1
text =
        {% if printer.heater_bed.target > 0.0 %}
        {%  set temp = printer.heater_bed.target %}
        {% else %}
        {% set temp = printer.configfile.config.heater_bed.max_temp %}
        {% endif %}
        {% set ratio = printer.heater_bed.temperature / temp|float %}
        {% set led_ratio = param_led_num|float / param_led_total %}
		        {% if ratio > led_ratio %}
        {led_ratio}, 0.0, 0.0, 0.0
        {% else %}
        0.0, 0.0, 0.0, 0.0
        {% endif %}

[display_template led_print_percent_glow]
text =
        {% set ratio = printer.virtual_sdcard.progress %}
        0.0, {ratio}, 0.0, 0.0

[display_template led_print_percent_progress]
param_led_num = 0
param_led_total = 1
text =
        {% set ratio = printer.virtual_sdcard.progress %}
        {% set led_ratio   = param_led_num|float / param_led_total %}
        {% if ratio > led_ratio %}
        0.0, {led_ratio}, 0.0, 0.0
        {% else %}
        1.0, 1.0, 1.0, 0.0
        {% endif %}
		[display_template led_printer_speed_glow]
text =
        {% set ratio  = printer.motion_report.live_velocity|float /  printer.configfile.config.printer.max_velocity|float %}
        0.0, {ratio}, 0.0, 0.0

[display_template led_printer_speed_progress]
param_led_num = 0
param_led_total = 1
text =
        {% set ratio  = printer.motion_report.live_velocity|float /  printer.configfile.config.printer.max_velocity|float %}
        {% set led_ratio    = param_led_num|float / param_led_total %}
        {% if ratio > led_ratio %}
        0.0, {led_ratio}, 0.0, 0.0
        {% else %}
        0.0, 0.0, 0.0, 0.0
        {% endif %}
=======================
Args: ['/home/pi/klipper/klippy/klippy.py', '/home/pi/printer.cfg', '-l', '/tmp/klippy.log', '-a', '/tmp/klippy_uds']
Git version: 'v0.10.0-557-gf7e29b27'
CPU: 4 core ARMv7 Processor rev 4 (v7l)
Python: '2.7.16 (default, Oct 10 2019, 22:02:15) \n[GCC 8.3.0]'
webhooks client 1971511168: {'program': 'Moonraker', 'version': 'v0.7.1-651-ge3cafb5'}

I don't see your START_PRINT or END_PRINT macro. Also, during print you can try to run the macro from console with any parameters you want without affecting the print. After print start try to execute from console:

NEOPIXEL_DISPLAY LED=neo TYPE=print_percent MODE=progress

Your first led should turn on after aprox 8% of print (100/13). If the led works then is something with your start macro call. If it doesn't I'll investigate further.

I have created a START_PRINT and END_PRINT macro but they dont seem to be executing properly, the temperature leds only turn on at the very end, and the print percent progress shows the background colour but no change during the print. I also tried running the macro in the middle of the print, however it didn't change anything.

Don't you get any error in console? Can you zip your whole klippy log and drag&drop it here in a comment.
Thank you

I'm looking at your log for 2 hours and I have no idea why doesn't work for you. Did the NEOPIXEL_DISPLAY LED=neo TYPE=print_percent MODE=glow works? You could change between modes during print from console.

After 5 days without an answer, I assume @Puffball101961 did find the solution or give up.

Like the Original Poster I found the 'led_print_percent_progress' macro did not work.

After looking into it I realised this macro is tracking the progress on the 'virtual-SD_card' object which is not in use.

I changed the object to 'printer.display_status.progress' and now it works perfectly.

[display_template led_print_percent_glow]
text:
    #{% set ratio = printer.virtual_sdcard.progress %}
    {% set ratio = printer.display_status.progress %}
    0.0, {ratio}, 0.0, 0.0

[display_template led_print_percent_progress]
param_led_num:  0
param_led_total: 1
text:
    #{% set ratio = printer.virtual_sdcard.progress %}
    {% set ratio = printer.display_status.progress %}
    {% set led_ratio   = param_led_num|float / param_led_total %}
    {% if ratio > led_ratio %}
        0.0, {led_ratio}, 0.0, 0.0
    {% else %}
        0.0, 0.0, 0.0, 0.0
    {% endif %}

Thanks for the useful macros.