From 46434bdd480a0d5072de27dfce1a9fbff3a15560 Mon Sep 17 00:00:00 2001 From: Zach Schimke Date: Mon, 16 Aug 2021 13:21:15 -0700 Subject: [PATCH] Adding caselight + RGB config. --- caselight.cfg | 135 +++++++++++++++++++++++++++++ macros.d/purge.cfg | 209 --------------------------------------------- 2 files changed, 135 insertions(+), 209 deletions(-) create mode 100644 caselight.cfg delete mode 100644 macros.d/purge.cfg diff --git a/caselight.cfg b/caselight.cfg new file mode 100644 index 0000000..e51a648 --- /dev/null +++ b/caselight.cfg @@ -0,0 +1,135 @@ +##################################################################### +# Lighting Control +##################################################################### + +## Neopixel interface +[neopixel neo_status] +pin: RGB +chain_count: 1 +#chain_count: 17 +color_order: RGB +#color_order: RGBW +initial_RED: 0.1 +initial_GREEN: 0.5 +initial_BLUE: 0.0 +#initial_WHITE: 0.0 + +##################################################################### +# Macros +##################################################################### +[gcode_macro _SET_CASELIGHT] +# use SET_CASELIGHT S0 to switch off +# use SET_Caselight S100 for full brightness +default_parameter_S: 0 +gcode: + SET_PIN PIN=_caselight VALUE={S} + +[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"' + _SET_CASELIGHT S=60 + _caselight_state + +[gcode_macro _CASELIGHT_OFF] +gcode: + SET_GCODE_VARIABLE MACRO=CASELIGHT VARIABLE=state VALUE='"off"' + _SET_CASELIGHT S=0 + _caselight_state + +[gcode_macro CASELIGHT] +variable_state: 'off' +gcode: + {%if printer['output_pin _caselight'].value == 0 %} + _CASELIGHT_ON + {% else %} + _CASELIGHT_OFF + {% endif %} + + +[delayed_gcode _LCD_INIT_KNOB] +initial_duration: 1 +gcode: + _LCD_KNOB COLOR=RED + + +[delayed_gcode _LCD_INIT_OFF] +initial_duration: 10 +gcode: + SET_GCODE_VARIABLE MACRO=DISPLAY VARIABLE=state VALUE='"off"' + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0 INDEX=1 TRANSMIT=1 + +[gcode_macro _LCD_KNOB] +default_parameter_BLINK: 0 +variable_color: 'GREEN' +variable_restore: 'GREEN' +variable_index: 2 +variable_blink: 0 +gcode: + {% set var_color=printer["gcode_macro _LCD_KNOB"].color %} + {% set var_restore=printer["gcode_macro _LCD_KNOB"].restore %} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=blink VALUE={BLINK} + UPDATE_DELAYED_GCODE ID=_BLINK_DELAY DURATION={BLINK|float} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=restore VALUE='"{var_color}"' + {% if params.COLOR == 'GREEN'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"GREEN"' + SET_LED LED=neo_display RED=0 GREEN=0.3 BLUE=0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0 GREEN=0.3 BLUE=0 INDEX=3 TRANSMIT=1 + {% elif params.COLOR == 'RED'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"RED"' + SET_LED LED=neo_display RED=0.5 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.5 GREEN=0 BLUE=0 INDEX=3 TRANSMIT=1 + {% elif params.COLOR == 'BLUE'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"BLUE"' + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0.5 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0.5 INDEX=3 TRANSMIT=1 + {% else %} + {% if var_restore == 'GREEN'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"GREEN"' + SET_LED LED=neo_display RED=0 GREEN=0.3 BLUE=0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0 GREEN=0.3 BLUE=0 INDEX=3 TRANSMIT=1 + {% elif var_restore == 'RED'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"RED"' + SET_LED LED=neo_display RED=0.5 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.5 GREEN=0 BLUE=0 INDEX=3 TRANSMIT=1 + {% elif var_restore == 'BLUE'%} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=color VALUE='"BLUE"' + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0.5 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0.5 INDEX=3 TRANSMIT=1 + {% endif %} + {% endif %} + +[delayed_gcode _BLINK_DELAY] +gcode: + {% set var_color=printer["gcode_macro _LCD_KNOB"].color %} + {% if printer["gcode_macro _LCD_KNOB"].index|int == 2 %} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=index VALUE=3 + {% if var_color == 'GREEN'%} + SET_LED LED=neo_display RED=0.0 GREEN=0.3 BLUE=0.0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=3 TRANSMIT=1 + {% elif var_color == 'RED'%} + SET_LED LED=neo_display RED=0.5 GREEN=0.0 BLUE=0.0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=3 TRANSMIT=1 + {% elif var_color == 'BLUE'%} + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.5 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=3 TRANSMIT=1 + {% endif %} + {% else %} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=index VALUE=2 + {% if var_color == 'GREEN'%} + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.0 GREEN=0.3 BLUE=0.0 INDEX=3 TRANSMIT=1 + {% elif var_color == 'RED'%} + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.5 GREEN=0.0 BLUE=0.0 INDEX=3 TRANSMIT=1 + {% elif var_color == 'BLUE'%} + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.0 INDEX=2 TRANSMIT=0 + SET_LED LED=neo_display RED=0.0 GREEN=0.0 BLUE=0.5 INDEX=3 TRANSMIT=1 + {% endif %} + {% endif %} + UPDATE_DELAYED_GCODE ID=_BLINK_DELAY DURATION={printer["gcode_macro _LCD_KNOB"].blink|float} + + diff --git a/macros.d/purge.cfg b/macros.d/purge.cfg deleted file mode 100644 index be26a47..0000000 --- a/macros.d/purge.cfg +++ /dev/null @@ -1,209 +0,0 @@ -####################################################################################################################################### - -# Sample macro config to be used in conjunction with the Decontaminator Purge Bucket & Nozzle Scrubber mod. Created by Hernsl -# (hernsl#8860 on Voron Design discord) and edited by Edwardyeeks (edwardyeeks#6042 on Voron Design Discord). - -# The goal of this macro is to provide a nozzle scrubbing and purging routine that is easily copied/referenced into your printer.cfg. -# Users can simply change parameters and enable/disable options in the first half. Descriptions are laid out in sequence to be read -# first; PLEASE READ CAREFULLY. - -# This sample config assumes the following: The user has implemented the default decontaminator purge bucket & nozzle scrubber mod -# for the VORON 1/2. - -# Features in this macro: option of putting the bucket at the rear or front of the bed. Purge routine that can be enabled/disabled. -# By default, bucket is located at rear left of bed and purge routine is enabled. - -# Default parameters are set for safe speeds and movements. Where necessary, tweak the parameters for the nozzle scrub procedure -# to fit your printer. - -# To avoid adding length of lines to your main printer.cfg config file, one can upload a config file separately into klipper and -# include it into the main printer config. Upload nozzle_scrub.cfg to the same directory as printer.cfg. Usually, it is in /home/pi/. - -# Once uploaded, add the following to your printer.cfg in the Macros section: [include /home/pi/nozzle_scrub.cfg] -# Those running mainsail will need to use the following location instead: [include /home/pi/klipper_config/nozzle_scrub.cfg] - -####################################################################################################################################### - -# Name of the macro is clean_nozzle. - -[gcode_macro clean_nozzle] - -# If you are putting your purge bucket at the rear left of the bed as per default installation, enable True on your location_bucket_rear -# variable. If you want to put your purge bucket elsewhere (perhaps the front), then set it to False. See diagrams and description -# further below on how to set your XY position. -variable_location_bucket_rear: True - -# If you want the purging routine in your bucket enabled, set to True (and vice versa). -variable_enable_purge: True - -# These parameters define your filament purging. Update as necessary. If you decided to not enable purge, you can ignore this section. -variable_purge_len: 10 ; Amount of filament, in mm, to purge. -variable_purge_spd: 150 ; Speed, in mm/s, of the purge. -variable_purge_temp_min: 235 ; Minimum nozzle temperature to permit a purge. Otherwise, purge will not occur. - -# Adjust this so that your nozzle scrubs within the brush. Currently defaulted to be a lot higher for safety. Be careful not to go too low! -variable_brush_top: 1.75 ;10 - -# These parameters define your scrubbing, travel speeds, safe z clearance and how many times you want to wipe. Update as necessary. -variable_clearance_z: 5 ; When traveling, but not cleaning, the clearance along the z-axis between nozzle and brush. -variable_wipe_qty: 3 ; Number of complete (A complete wipe: start left, go right, go left) wipes. -variable_prep_spd_xy: 3000 ; Travel (not cleaning) speed along x and y-axis in mm/min. -variable_prep_spd_z: 1500 ; Travel (not cleaning) speed along z axis in mm/min. -variable_wipe_spd_xy: 5000 ; Nozzle wipe speed in mm/min. - - -# These parameters define the size of the brush. Update as necessary. A visual reference is provided below. Note that orientation of -# parameters remain the same whether bucket is at rear or front. -# -# ← brush_width → -# _________________ ↑ -# | | ↑ If you chose location_bucket_rear = True, Y position is acquired -# brush_start (x) | | brush_depth from your stepper_y position_max. Adjust your brush physically in -# |_________________| ↓ Y so that the nozzle scrubs within the brush. -# (y) ↓ -# brush_front -# __________________________________________________________ -# PRINTER FRONT -# -# -## For V1.8, you may need to measure where your brush is on the x axis and input manually into any of the variable_brush_start uncommented. -## For V2.4 250mm build, uncomment this below: -#variable_brush_start: 25 - -## For V2.4 300mm build, uncomment this below: -#variable_brush_start: 50 - -## For V2.4 350mm build, uncomment this below: -variable_brush_start: 75 - -# This value is defaulted from brush location in CAD (rear left). Change if your brush width is different. -variable_brush_width: 52 - -## These are only used if location_bucket_rear is False. You specify a custom location in y axis for your brush - see diagram above. ## -variable_brush_front: 0 -variable_brush_depth: 0 - - -# These parameters define the size of your purge bucket. Update as necessary. If you decided to not enable purge, you can ignore -# this section. A visual reference is provided below. Note that orientation of parameters remain the same whether bucket is at rear -# or front. -# -# bucket_gap -# ← ---- → -# __________________________________________ -# | | | | -# | | | | -# bucket_start (x) | |______| | -# | | | | -# | | | | -# |_________________|. . . |_________________| -# ← ------------- → ← ------------- → -# bucket_left_width bucket_right_width -# _______________________________________________________________________________________ -# PRINTER FRONT -# -## For V2.4 250mm build, uncomment below -#variable_bucket_left_width: 42 - -## For V2.4 300mm build, uncomment below -#variable_bucket_left_width: 67 - -## For V2.4 350mm build, uncomment below -variable_bucket_left_width: 92 - -# These values are defaulted from bucket geometry in CAD (rear left location). Change only if you're using a custom bucket. -variable_bucket_right_width: 40 -variable_bucket_gap: 22 - -# For V1.8, you may need to measure where your bucket start is and input into bucket_start. Otherwise, a value of 0 is for a default -# installation of purge bucket at rear left. -variable_bucket_start: 0 - - -############################################################################################################################################### -############################################################################################################################################### - -### From here on, unless you know what you're doing, it's recommended not to change anything. - -############################################################################################################################################### -############################################################################################################################################### - -# Placeholder. The variable will contain at random a number representing the left or right bucket. -variable_bucket_pos: 1 - -gcode: - # First, check if the axes are homed. - {% if "xyz" in printer.toolhead.homed_axes %} - - ## Save the gcode state in this macro instance. - SAVE_GCODE_STATE NAME=clean_nozzle - - ## Set to absolute positioning. - G90 - - ## Grab max position of Y-axis from config to use in setting a fixed y position for location_bucket_rear = True. - {% set Ry = printer.configfile.config["stepper_y"]["position_max"]|float %} - - ## Check if user enabled purge option or not. - {% if enable_purge %} - - ### Randomly select left or right bin for purge. - SET_GCODE_VARIABLE MACRO=clean_nozzle VARIABLE=bucket_pos VALUE={(range(0, 1) | random)} - - ### Raise Z for travel. - G1 Z{brush_top + clearance_z} F{prep_spd_z} - - ### Check if user chose to use rear location. - {% if location_bucket_rear %} - G1 Y{Ry} F{prep_spd_xy} - {% else %} - G1 Y{brush_front + (brush_depth / 2)} F{prep_spd_xy} - {% endif %} - - ### Position for purge. Randomly selects middle of left or right bucket. It references from the middle of the left bucket. - G1 X{bucket_start + (bucket_left_width / 2) + (bucket_pos * bucket_gap) + (bucket_pos * (bucket_right_width / 2))} - - ### Perform purge if the temp is up to min temp. If not, it will skip and continue executing rest of macro. - {% if printer.extruder.temperature >= purge_temp_min %} - M83 ; relative mode - G1 E{purge_len} F{purge_spd} - G92 E0 ; reset extruder - {% endif %} - - {% endif %} - - ## Position for wipe. - G1 Z{brush_top + clearance_z} F{prep_spd_z} - G1 X{brush_start} F{prep_spd_xy} - - ## Check if user chose to use rear location. - {% if location_bucket_rear %} - G1 Y{Ry} - {% else %} - G1 Y{brush_front + (brush_depth / 2)} - {% endif %} - - ## Move nozzle down into brush. - G1 Z{brush_top} F{prep_spd_z} - - ## Perform wipe. - {% for wipes in range(1, (wipe_qty + 1)) %} - G1 X{brush_start + brush_width} F{wipe_spd_xy} - G1 X{brush_start} F{wipe_spd_xy} - {% endfor %} - - ## Clear from area. - M117 Cleaned! - G1 Z{brush_top + clearance_z} F{prep_spd_z} - G1 X{bucket_left_width / 4} F{prep_spd_xy} - - ## Restore the gcode state to how it was before the macro. - RESTORE_GCODE_STATE NAME=clean_nozzle - - {% else %} - - ## raise error will stop any macros that clean_nozzle is referenced in from proceeding for safety. - { action_raise_error("Please home your axes!") } - M117 Please home first! - - {% endif %}