diff --git a/caselight.cfg b/caselight.cfg index 2a1a113..7b68568 100644 --- a/caselight.cfg +++ b/caselight.cfg @@ -15,7 +15,9 @@ initial_WHITE: 0.1 ##################################################################### # Macros ##################################################################### -[gcode_macro _VAR_LEDS] + +[gcode_macro _CASELIGHT] +default_parameter_COLOR: 'white' 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), @@ -33,29 +35,22 @@ variable_colors: { 'red': (1.0, 0.0, 0.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)} -gcode: - -[gcode_macro _SET_LEDS] -default_parameter_color: 'WHITE' -default_parameter_index: (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) + '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 R=printer["gcode_macro _VAR_LEDS"].colors.[params.COLOR][0] %} - {% set G=printer["gcode_macro _VAR_LEDS"].colors.[params.COLOR][1] %} - {% set B=printer["gcode_macro _VAR_LEDS"].colors.[params.COLOR][2] %} - {% set W=printer["gcode_macro _VAR_LEDS"].colors.[params.COLOR][3] %} + {% set tuple = colors.get(COLOR|lower, (0.0, 0.0, 0.0, 0.7)) %} + {% set R = tuple[0] %} + {% set G = tuple[1] %} + {% set B = tuple[2] %} + {% set W = tuple[3] %} - {% for I in index %} - SET_LED LED=neo_leds RED={R} GREEN={G} BLUE={B} WHITE={W} INDEX={I} TRANSMIT={{ loop.last }} SYNC=0 + {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] -default_parameter_COLOR: 'WHITE' -variable_index: (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) -gcode: - _SET_LED color={COLOR} index={var_index} - [gcode_macro _caselight_state] gcode: {action_respond_info("Caselight %s" % (printer["gcode_macro CASELIGHT"].state))} @@ -73,9 +68,9 @@ gcode: _caselight_state [gcode_macro CASELIGHT] -variable_state: 'off' +variable_state: 'on' gcode: - {%if printer['output_pin _caselight'].value == 0 %} + {%if printer['gcode_macro CASELIGHT'].state == "off" %} _CASELIGHT_ON {% else %} _CASELIGHT_OFF @@ -91,6 +86,7 @@ default_parameter_BLINK: 0 variable_color: 'ORANGE' variable_restore: 'GREEN' variable_index: 17 +variable_blink: 0 variable_blinkNext: 0 gcode: {% set var_color=printer["gcode_macro _STATUS_LED"].color %} @@ -99,9 +95,9 @@ gcode: UPDATE_DELAYED_GCODE ID=_STATUS_LED_BLINK_DELAY DURATION={BLINK|float} SET_GCODE_VARIABLE MACRO=_STATUS_LED VARIABLE=restore VALUE='"{var_color}"' {% if params.COLOR %} - _SET_LED color={COLOR} index={var_index} + #_SET_LEDS color={COLOR} index={var_index} {% else %} - _SET_LED color={var_restore} index={var_index} + #_SET_LEDS color={var_restore} index={var_index} {% endif %} [delayed_gcode _STATUS_LED_BLINK_DELAY] @@ -117,3 +113,4 @@ gcode: UPDATE_DELAYED_GCODE ID=_BLINK_DELAY DURATION={printer["gcode_macro _STATUS_LED"].blink|float} +