Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STEAPP-152: Added the led_effect module for use in the v630 printer #225

Merged
merged 11 commits into from
Dec 28, 2023
Merged
1,055 changes: 647 additions & 408 deletions klippy/extras/led_effect.py

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions stereotech_config/530/chamber_2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,6 @@ gcode:
UPDATE_DELAYED_GCODE ID=return_color DURATION=0.1
{% endif %}

; [led_effect strobe_efect]
; autostart:false
; frame_rate:24
; leds:
; neopixel:case_led
; layers:
; strobe 0.6 1.5 add (1.0, 1.0, 1.0),(0.0, 0.0, 1.0);
; [led_effect breathing_efect]
; autostart: false
; frame_rate: 24
; leds:
; neopixel:case_led
; layers:
; linearfade 6 0 top (1.0, 1.0, 1.0),(0.0, 0.0, 1.0);
; [led_effect fire_efect]
; autostart: false
; frame_rate: 24
; leds:
; neopixel:case_led
; layers:
; fire 95 40 top (0.0, 0.0, 1.0),(1.0, 1.0, 1.0);

[gcode_macro M106]
rename_existing: M106.1
gcode:
Expand All @@ -165,4 +143,3 @@ gcode:
{% else %}
M107.1
{% endif %}

22 changes: 22 additions & 0 deletions stereotech_config/630/board_stm32f4.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[board_pins]
aliases:
x_step_pin=PF13, x_dir_pin=PF12, x_en_pin=PF14, x_endstop_pin=PG6,
y_step_pin=PG0, y_dir_pin=PG1, y_en_pin=PF15, y_endstop_pin=PG9,
z_step_pin=PF11, z_dir_pin=PG3, z_en_pin=PG5, z_endstop_pin=PG10,
a_step_pin=PG4, a_dir_pin=PC1, a_en_pin=PA0, a_endstop_pin=PG11,
c_step_pin=PF9, c_dir_pin=PF10, c_en_pin=PG2, c_endstop_pin=PB7,
bed_heater=PA1, bed_sensor=PF5,
five_axis_pin=PG12, heatsink_fan_pin=PD12,
main_extruder_step_pin=PC13, main_extruder_dir_pin=PF0,
main_extruder_enable_pin=PF1, main_extruder_heater_pin=PA2,
main_extruder_sensor_pin=PF3,
main_extruder_filament_sensor_pin=PG14,
second_extruder_step_pin=PE2, second_extruder_dir_pin=PE3,
second_extruder_enable_pin=PD4, second_extruder_heater_pin=PA3,
second_extruder_sensor_pin=PF4,
second_extruder_filament_sensor_pin=PG15,
fiber_cut_step_pin=PE6, fiber_cut_dir_pin=PA14,
fiber_cut_enable_pin=PE0,
case_led=PE5, status_led=PB0,
# for debug
fan_pin=PD15,
166 changes: 166 additions & 0 deletions stereotech_config/630/chamber.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
[fan_generic chamber_fan]
pin: PA8

[temperature_fan bottom_fan]
pin: PD13
sensor_type: temperature_host
control: pid
pid_Kp: 15
pid_Ki: 0.5
pid_Kd: 25
min_temp: 0
max_temp: 90
target_temp: 45.0
min_speed: 0.0
gcode_id: E

[gcode_macro M106]
rename_existing: M106.1
gcode:
{% set p = params.P|default(0)|int %}
{% set s = params.S|default(0)|int %}
{% if p > 0 %}
{% if p == 3 %}
SET_FAN_SPEED FAN=chamber_fan SPEED={params.S|default(0)|int / 255}
{% endif %}
{% else %}
M106.1 S{s}
{% endif %}

[gcode_macro M107]
rename_existing: M107.1
gcode:
{% set p = params.P|default(0)|int %}
{% if p > 0 %}
{% if p == 3 %}
SET_FAN_SPEED FAN=chamber_fan SPEED=0.0
{% endif %}
{% else %}
M107.1
{% endif %}

# LED Light controls

[led case_led]
white_pin: case_led
initial_WHITE: 1

[neopixel status_led]
pin: status_led
chain_count: 100
color_order: GRBW
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0
initial_WHITE: 1.0

[delayed_gcode startup_light]
initial_duration: 0.1
gcode:
SET_LED_EFFECT EFFECT=startup REPLACE=1 FADETIME=0
SET_LED_EFFECT EFFECT=maintenance REPLACE=1 FADETIME=6.0

[gcode_macro TOGGLE_LIGHT]
gcode:
{% if printer['led case_led'].color_data[0][3] > 0.0 %}
SET_LED LED=case_led WHITE=0
{% else %}
SET_LED LED=case_led WHITE=1
{% endif %}

[gcode_macro STATUS_LED]
gcode:
{% set status = params.STATUS|default(printing) %}
{% if status == "started" %}
{% set heater = params.HEATER|default(extruder) %}
SET_LED_EFFECT EFFECT=heatup_{heater} REPLACE=1 FADETIME=2.0
{% else %}
SET_LED_EFFECT EFFECT={status} REPLACE=1 FADETIME=2.0
{% endif %}

[led_effect startup]
autostart: true
leds:
neopixel:status_led
layers:
comet 0.7 10 add (0, 1, 1), (0, .5, .5), (0, 0, 0)
comet -0.7 10 add (0, 1, 1), (0, .5, .5), (0, 0, 0)

[led_effect maintenance]
leds:
neopixel:status_led
layers:
static 0 0 add (0, 1, 1)

[led_effect idle]
leds:
neopixel:status_led
layers:
linearfade 5 0 add (0, 1, 1), (0, .5, .5)

[led_effect heatup_extruder]
leds:
neopixel:status_led
layers:
linearfade 5 0 multiply (1, 1, 1), (.5, .5, .5)
temperature 20 100 add (0, 0, 1), (1, 0, 1)
heater: extruder

[led_effect heatup_extruder1]
leds:
neopixel:status_led
layers:
linearfade 5 0 multiply (1, 1, 1), (.5, .5, .5)
temperature 20 100 add (0, 0, 1), (1, 0, 1)
heater: extruder1

[led_effect heatup_heater_bed]
leds:
neopixel:status_led
layers:
linearfade 5 0 multiply (1, 1, 1), (.5, .5, .5)
temperature 20 100 add (0, 0, 1), (1, 0, 1)
heater: heater_bed

[led_effect printing]
leds:
neopixel:status_led
layers:
linearfade 5 0 multiply (1, 1, 1), (.5, .5, .5)
progress 99 0 add (0, .6, .6), (0, 1, 1)
static 0 0 add (.1, .1, .1)

[led_effect paused]
leds:
neopixel:status_led
layers:
progress 99 0 add (.6, .6, 0), (1, 1, 00)
static 0 0 add (.1, .1, .1)

[led_effect error_paused]
leds:
neopixel:status_led
layers:
linearfade 5 0 multiply (1, 1, 1), (.5, .5, .5)
progress 99 0 add (.6, .6, 0), (1, 1, 0)
static 0 0 add (.1, .1, .1)

[led_effect cancelled]
leds:
neopixel:status_led
layers:
progress 99 0 add (.6, 0, 0), (1, 0, 0)
static 0 0 add (.1, .1, .1)

[led_effect error]
run_on_error: true
leds:
neopixel:status_led (1-7)
layers:
strobe .6 .1 top (1, 0, 0)

[led_effect completed]
leds:
neopixel:status_led
layers:
linearfade 5 0 add (0, 1, 0), (0, .5, 0)
12 changes: 11 additions & 1 deletion stereotech_config/750/print_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gcode:
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% set fan_speed = printer.fan.speed * 255 | int %}
{% set status_led = params.STATUS_LED|default('paused') %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
Expand All @@ -42,7 +43,7 @@ gcode:
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT=360000
PAUSE_BASE
STATUS_LED STATUS=paused
STATUS_LED STATUS={status_led}
{% if printer.probe %}
{% if printer.heater_bed.temperature > 5 %}
BED_MESH_CLEAR
Expand Down Expand Up @@ -306,3 +307,12 @@ gcode:
G1 Z{z_safe} F1600
{% endif %}
G90

[gcode_macro SET_STATUS_TO_PRINT_QUEUE]
description: installing the print_queue server module in a maintenance or idle state, and set state to led_effect
gcode:
{% set new_status = params.NEW_STATUS|default('maintenance')|lower %}
{action_call_remote_method('set_status_print_queue', new_status=new_status)}
{% if printer['neopixel status_led'] %}
STATUS_LED STATUS={new_status}
{% endif %}
4 changes: 2 additions & 2 deletions stereotech_config/HTE630-0-C-23.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ path: /home/ste/uploads

[display_status]

[include config/common/board_stm32f4.cfg]
[include config/630/board_stm32f4.cfg]

[include config/630/kinematics.cfg]
[include config/630/kinematics_tmc.cfg]
[include config/630/homing_override.cfg]
[include config/common/homing_macros.cfg]

[include config/530/chamber_2.cfg]
[include config/630/chamber.cfg]

[include config/common/printhead.cfg]

Expand Down
2 changes: 1 addition & 1 deletion stereotech_config/common/extruder_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ gcode:
[gcode_macro M109]
rename_existing: M1091
gcode:
STATUS_LED STATUS=started
{% set extruder = params.T|default(-1)|int %}
{% set temp =params.S|int %}
{% set extruder_name = printer.toolhead.extruder %}
{% set heat_phase = "_heating" if temp > 50 else "_cooling" %}
{% if extruder >= 0 %}
{% set extruder_name = "extruder" if extruder == 0 else "extruder" ~ extruder %}
{% endif %}
STATUS_LED STATUS=started HEATER={extruder_name}
M117 {extruder_name ~ heat_phase}
{% if extruder >= 0 %}
M1091 T{extruder} S{temp}
Expand Down
4 changes: 2 additions & 2 deletions stereotech_config/common/filament_control.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ gcode:
SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=0
{% endif %}
{% if not printer.pause_resume.is_paused %}
PAUSE TURN_OFF_EXTRUDERS=0 E=0
PAUSE TURN_OFF_EXTRUDERS=0 E=0 STATUS_LED=error_paused
{% endif %}
{% if printer["gcode_macro RECOVER_EXTRUSION"].enable_prime and (printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count or printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown) %}
RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor}
Expand Down Expand Up @@ -87,7 +87,7 @@ gcode:
{action_respond_warning('419: Algorithm the recover extrusion is disable.')}
SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_triggered_sensor VALUE={printer["gcode_macro RECOVER_EXTRUSION"].count_triggered_sensor + 1}
{% if not printer.pause_resume.is_paused %}
PAUSE TURN_OFF_EXTRUDERS=1 E=0
PAUSE TURN_OFF_EXTRUDERS=1 E=0 STATUS_LED=error_paused
{% endif %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion stereotech_config/common/module_3d_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gcode:
rename_existing: M191
gcode:
{% if printer["gcode_button five_axis_module"].state == "RELEASED" %}
STATUS_LED STATUS=started
STATUS_LED STATUS=started HEATER=heater_bed
M117 platform_heating
M191 S{ params.S }
STATUS_LED STATUS=printing
Expand Down
12 changes: 11 additions & 1 deletion stereotech_config/common/print_macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gcode:
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% set fan_speed = printer.fan.speed * 255 | int %}
{% set status_led = params.STATUS_LED|default('paused') %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
Expand All @@ -41,7 +42,7 @@ gcode:
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT=360000
PAUSE_BASE
STATUS_LED STATUS=paused
STATUS_LED STATUS={status_led}
{% if printer.probe %}
{% if printer["gcode_button five_axis_module"].state == "RELEASED" %}
BED_MESH_CLEAR
Expand Down Expand Up @@ -322,3 +323,12 @@ gcode:
G1 Z{z_safe} F1600
{% endif %}
G90

[gcode_macro SET_STATUS_TO_PRINT_QUEUE]
description: installing the print_queue server module in a maintenance or idle state, and set state to led_effect
gcode:
{% set new_status = params.NEW_STATUS|default('maintenance')|lower %}
{action_call_remote_method('set_status_print_queue', new_status=new_status)}
{% if printer['neopixel status_led'] %}
STATUS_LED STATUS={new_status}
{% endif %}
Loading