-
Notifications
You must be signed in to change notification settings - Fork 4
/
caselight.cfg
133 lines (121 loc) · 4.91 KB
/
caselight.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#####################################################################
# Lighting Control
#####################################################################
## Neopixel interface
[neopixel neo_leds]
pin: RGB
chain_count: 17
color_order: GRBW
initial_RED: 0.0
initial_GREEN: 0.0
initial_BLUE: 0.0
initial_WHITE: 0.1
#####################################################################
# Macros
#####################################################################
[gcode_macro _CASELIGHT]
variable_colors: { 'red': (1.0, 0.0, 0.0, 0.0),
'orange': (1.0, 0.5, 0.0, 0.0),
'yellow': (1.0, 1.0, 0.0, 0.0),
'charteuse': (0.5, 1.0, 0.0, 0.0),
'green': (0.0, 1.0, 0.0, 0.0),
'turquiose': (0.0, 1.0, 0.5, 0.0),
'springgreen': (0.0, 1.0, 0.5, 0.0),
'cyan': (0.0, 1.0, 1.0, 0.0),
'azure': (0.0, 0.5, 1.0, 0.0),
'ocean': (0.0, 0.5, 1.0, 0.0),
'blue': (0.0, 0.0, 1.0, 0.0),
'violet': (0.5, 0.0, 1.0, 0.0),
'purple': (0.5, 0.0, 1.0, 0.0),
'magenta': (1.0, 0.0, 1.0, 0.0),
'raspberry': (1.0, 0.0, 0.5, 0.0),
'rose': (1.0, 0.0, 0.5, 0.0),
'white': (0.0, 0.0, 0.0, 4.0),
'off': (0.0, 0.0, 0.0, 0.0) }
variable_leds: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
gcode:
# Grab the color values
{% set RGBW = colors.get(COLOR|default('white')|lower, (0.0, 0.0, 0.0, 0.7)) %}
{% set R = RGBW[0] %}
{% set G = RGBW[1] %}
{% set B = RGBW[2] %}
{% set W = RGBW[3] %}
{action_respond_info("LED Tuple: {0}".format(tuple))}
{% for I in leds %}
SET_LED LED=neo_leds RED={R} GREEN={G} BLUE={B} WHITE={W} INDEX={I} TRANSMIT={loop.last|int} SYNC=0
{% endfor %}
[gcode_macro _caselight_state]
gcode:
{action_respond_info("Caselight %s" % (printer["gcode_macro CASELIGHT"].state))}
[gcode_macro _CASELIGHT_ON]
gcode:
SET_GCODE_VARIABLE MACRO=CASELIGHT VARIABLE=state VALUE='"on"'
_CASELIGHT
_caselight_state
[gcode_macro _CASELIGHT_OFF]
gcode:
SET_GCODE_VARIABLE MACRO=CASELIGHT VARIABLE=state VALUE='"off"'
_CASELIGHT color='"off"'
_caselight_state
[gcode_macro CASELIGHT]
variable_state: 'on'
gcode:
{%if printer['gcode_macro CASELIGHT'].state == "off" %}
_CASELIGHT_ON
{% else %}
_CASELIGHT_OFF
{% endif %}
[delayed_gcode _STATUS_LED_INIT]
initial_duration: 1
gcode:
_STATUS_LED COLOR=BLUE
[gcode_macro _STATUS_LED]
variable_color: 'GREEN'
variable_restore: 'GREEN'
variable_index: 17
variable_blink: 0
variable_blank: 1
gcode:
{% set var_color=printer["gcode_macro _STATUS_LED"].color %}
{% set var_restore=printer["gcode_macro _STATUS_LED"].restore %}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=blink VALUE={BLINK|default(0)}
UPDATE_DELAYED_GCODE ID=_STATUS_LED_BLINK_DELAY DURATION={BLINK|default(0)|float}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=restore VALUE='"{var_color}"'
{% if params.COLOR == 'GREEN'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"GREEN"'
SET_LED LED=neo_leds RED=0 GREEN=0.3 BLUE=0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif params.COLOR == 'RED'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"RED"'
SET_LED LED=neo_leds RED=0.5 GREEN=0 BLUE=0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif params.COLOR == 'BLUE'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"BLUE"'
SET_LED LED=neo_leds RED=0 GREEN=0 BLUE=0.5 INDEX=17 TRANSMIT=1 SYNC=0
{% else %}
{% if var_restore == 'GREEN'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"GREEN"'
SET_LED LED=neo_leds RED=0 GREEN=0.3 BLUE=0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif var_restore == 'RED'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"RED"'
SET_LED LED=neo_leds RED=0.5 GREEN=0 BLUE=0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif var_restore == 'BLUE'%}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=color VALUE='"BLUE"'
SET_LED LED=neo_leds RED=0 GREEN=0 BLUE=0.5 INDEX=17 TRANSMIT=1 SYNC=0
{% endif %}
{% endif %}
[delayed_gcode _STATUS_LED_BLINK_DELAY]
gcode:
{% set var_color=printer["gcode_macro _STATUS_LED"].color %}
{% if printer["gcode_macro _STATUS_LED_BLINK_DELAY"].blank == 1 %}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=blank VALUE=0
SET_LED LED=neo_leds RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=17 TRANSMIT=1 SYNC=0
{% else %}
SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=blank VALUE=1
{% if var_color == 'GREEN'%}
SET_LED LED=neo_leds RED=0.0 GREEN=0.3 BLUE=0.0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif var_color == 'RED'%}
SET_LED LED=neo_leds RED=0.5 GREEN=0.0 BLUE=0.0 INDEX=17 TRANSMIT=1 SYNC=0
{% elif var_color == 'BLUE'%}
SET_LED LED=neo_leds RED=0.0 GREEN=0.0 BLUE=0.5 INDEX=17 TRANSMIT=1 SYNC=0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_STATUS_LED_BLINK_DELAY DURATION={printer["gcode_macro _STATUS_LED"].blink|float}