-
Notifications
You must be signed in to change notification settings - Fork 0
/
wled_progress_RainbowShift.cfg
91 lines (80 loc) · 3.54 KB
/
wled_progress_RainbowShift.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# use NEOPIXEL_DISPLAY LED=Led_Name TYPE=template_type MODE=template_mode
# for TYPE use:
# extruder_temp :extruder temperature progress
# bed_temp :bed temperature progress
# print_percent :print progress
# printer_speed :printer speed
# for MODE use:
# progress :the leds will light up one by one
# glow :all leds will fade from one color (or non) to other color
# more info: https://github.com/digitalninja-ro/klipper-neopixel/blob/master/README.md
[delayed_gcode report_temp]
initial_duration: 1
gcode:
{% if printer.virtual_sdcard.progress > 0 %}
Print_Progress LED="DaybreakNeos" TYPE=bed_temp MODE=progress LEDLEN=13
UPDATE_DELAYED_GCODE ID=report_temp DURATION=30
{% else %}
Bed_Progress LED="DaybreakNeos" TYPE=bed_temp MODE=progress LEDLEN=13
UPDATE_DELAYED_GCODE ID=report_temp DURATION=1
{% endif %}
[gcode_macro Bed_Progress]
gcode:
{% set led = params.LED %}
{% set type = params.TYPE %}
{% set mode = params.MODE %}
#{% set led_total = params.LEDLEN|int %}
{% set param_led_total = 14 %}
{% if mode == 'progress' %}
{% for i in range(param_led_total) %}
#----- copied from Progress template as WLED does not understand this.
{% set param_led_num=i+1 %}
#{% set param_led_total=14 %}
{% 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 tempratio = 1 - printer.heater_bed.temperature / temp|float %}
{% set led_ratio = param_led_num|float / param_led_total %}
{% if ratio > led_ratio %}
{%set redratio=1%}
{% else %}
{%set redratio=0%}
{% endif %}
#-----
SET_WLED strip={led} BLUE={1-redratio} RED={redratio} INDEX={i+1}
#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 redrw=(tempratio-led_ratio)*-1%} reverse ombre effect
# SET_WLED strip='DaybreakNeos' TEMPLATE={'led_' ~ type ~ '_' ~ mode}
#{% endif %}
[gcode_macro Print_Progress]
gcode:
{% set led = params.LED %}
#{% set type = params.TYPE %}
{% set mode = params.MODE %}
{% set param_led_total = 13 %}
{% if mode == 'progress' %}
{% for i in range(13) %} # fixed to 13 leds
{% set param_led_num=i+1 %}
#----- copied from Progress template as WLED does not understand this.
{% set ratio = printer.virtual_sdcard.progress %}
#-----
{% set led_ratio = param_led_num|float / param_led_total %}
{% if ratio > led_ratio %}
{%set redratio=1%}
{% else %}
{%set redratio=0%}
{% endif %}
m117 {progratio}
SET_WLED strip={led} BLUE={1-redratio} Green={redratio} INDEX={i+1}
#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_WLED strip='DaybreakNeos' TEMPLATE={'led_' ~ type ~ '_' ~ mode}
#{% endif %}